{"id":1764,"date":"2023-03-26T21:50:54","date_gmt":"2023-03-26T19:50:54","guid":{"rendered":"https:\/\/blog.sqlora.com\/en\/?p=1764"},"modified":"2023-03-26T22:58:41","modified_gmt":"2023-03-26T20:58:41","slug":"what-does-chatgpt-think-about-sql-macros","status":"publish","type":"post","link":"https:\/\/blog.sqlora.com\/en\/what-does-chatgpt-think-about-sql-macros\/","title":{"rendered":"What does ChatGPT &#8220;think&#8221; about SQL Macros?"},"content":{"rendered":"\n<p>After some weeks of reading and hearing in almost every news report about generative AI and ChatGPT in particular, and how it will change a developer&#8217;s life or even make developers obsolete, I was really curious to check it out myself and ask some developer questions. Since I&#8217;ve posted quite lot about SQL macros in the past few years, I thought aksing about them could be a good start point. One more argument to start with the topic I&#8217;m pretending to know lot about, is to be able to easily distinguish the truth from <a rel=\"noreferrer noopener\" href=\"https:\/\/en.wikipedia.org\/wiki\/Hallucination_(artificial_intelligence)\" target=\"_blank\">AI hallucination<\/a>.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>But what are the chances that there was some information about SQL macros in the data ChatGPT was trained on, so that it could even &#8220;know&#8221; something about them? One can read that ChatGPT&#8217;s training data cuts off in 2021. Oracle documentation, 20c back then, some blog posts, tweets, etc. were avaiable at the beginning of 2020. So let&#8217;s try&#8230;  <\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik.png\"><img loading=\"lazy\" decoding=\"async\" width=\"975\" height=\"573\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik.png\" alt=\"\" class=\"wp-image-1769\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik.png 975w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-300x176.png 300w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-768x451.png 768w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-624x367.png 624w\" sizes=\"auto, (max-width: 975px) 100vw, 975px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>At this point I was a little bit confused! Have I missed the new syntax for creating a SQL Macro?! But also the explanation above told me, it must be something wrong here. It doesn&#8217;t reflect what SQL macros in Oracle are and how they work. Doing some google search I could find out that this probably was an example and a definition from <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.teradata.com\/r\/Teradata-VantageTM-SQL-Fundamentals\/July-2021\/Database-Objects\/Macros\" target=\"_blank\">Teradata<\/a>, which happens to have SQL macros as well but the whole idea is totally different there. <\/p>\n\n\n\n<p>Well, will ChatGPT admit its mistake? <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"909\" height=\"549\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-1.png\" alt=\"\" class=\"wp-image-1776\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-1.png 909w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-1-300x181.png 300w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-1-768x464.png 768w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-1-624x377.png 624w\" sizes=\"auto, (max-width: 909px) 100vw, 909px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Yes! But even more: now it says there are no SQL macros at all in Oracle database! <\/p>\n\n\n\n<p>I think, it&#8217;s time to give some hint:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"922\" height=\"656\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-2.png\" alt=\"\" class=\"wp-image-1778\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-2.png 922w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-2-300x213.png 300w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-2-768x546.png 768w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-2-624x444.png 624w\" sizes=\"auto, (max-width: 922px) 100vw, 922px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>And again apologies follow. But look what happens: the right information (which was actually present in  the question itself) is again followed by the inappropriate definition and example from Teradata.<\/p>\n\n\n\n<p>Maybe I can confuse ChatGPT too?  <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"898\" height=\"505\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-3.png\" alt=\"\" class=\"wp-image-1779\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-3.png 898w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-3-300x169.png 300w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-3-768x432.png 768w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-3-624x351.png 624w\" sizes=\"auto, (max-width: 898px) 100vw, 898px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Ha-ha! The word REPLACE was wrong! Well, i think it makes no sense to ask further in this direction. Maybe asking specific questions will be more successful? For example, we know that there are scalar and table SQL macros. Can ChatGPT explain the difference?<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"923\" height=\"597\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-4.png\" alt=\"\" class=\"wp-image-1781\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-4.png 923w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-4-300x194.png 300w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-4-768x497.png 768w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-4-624x404.png 624w\" sizes=\"auto, (max-width: 923px) 100vw, 923px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Obviously, my question was too general, which led ChatGPT again using the &#8220;named sequence of SQL statements&#8221; explanation, but also freely inventing the two types and their definitions. At least I have not found anything about &#8220;inline&#8221; macros by Teradata. <\/p>\n\n\n\n<p>And about the last sentence &#8211; SQL macros in Oracle are involved earlier, at parsing time. They only return text &#8211; a part of the SQL statement &#8211; but no data.<\/p>\n\n\n\n<p>But&#8230; The answer itself sounds very &#8230; meaningful for someone who don&#8217;t know it is incorrect!<\/p>\n\n\n\n<p>Next and the last try asking about scalar and table macros: <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"915\" height=\"671\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-6.png\" alt=\"\" class=\"wp-image-1789\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-6.png 915w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-6-300x220.png 300w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-6-768x563.png 768w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-6-624x458.png 624w\" sizes=\"auto, (max-width: 915px) 100vw, 915px\" \/><\/a><\/figure>\n\n\n\n<p>and further:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"859\" height=\"665\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-7.png\" alt=\"\" class=\"wp-image-1791\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-7.png 859w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-7-300x232.png 300w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-7-768x595.png 768w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2023\/03\/grafik-7-624x483.png 624w\" sizes=\"auto, (max-width: 859px) 100vw, 859px\" \/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Okay, one wrong answer more. That&#8217;s not how things work. None of these examples will work in Oracle database. I think it&#8217;s enough. The conversation was a quite funny experience, now I&#8217;m ready to draw my conclusions. <\/p>\n\n\n\n<p>Actually, I think one can classify everything we have seen as a AI hallucination. In fact, I believe there was no suitable training data to be able to answer questions from such a deep technological field. Maybe we should try again, when we will have a ChatGPT model fine tuned on Oracle documentation, <a href=\"https:\/\/asktom.oracle.com\/pls\/apex\/f?p=100:1000::::::\" target=\"_blank\" rel=\"noreferrer noopener\">AskTom<\/a> questions and other trustworthy resources.  <\/p>\n\n\n\n<p>I think we&#8217;re seeing what huge steps generative AI is making right now and ChatGPT is indeed really great! But at this point it is simply dangerous to use ChatGPT <strong>instead<\/strong> of other resources. You should doublecheck everything! See how confident it is, it never says: &#8220;I don&#8217;t know&#8221;. You will get your answer and the answer is looking perfect. Unless you know it doesn&#8217;t&#8230;  <\/p>\n\n\n\n<p><\/p>\n\n\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-2925154690547867\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-client=\"ca-pub-2925154690547867\" \ndata-ad-slot=\"2727403138\" \ndata-ad-layout=\"in-article\"\ndata-ad-format=\"fluid\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n\n\n\n<p><sub>Bild von <a href=\"https:\/\/pixabay.com\/de\/users\/tumisu-148124\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=7834467\">Tumisu<\/a> auf <a href=\"https:\/\/pixabay.com\/de\/\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=7834467\">Pixabay<\/a><\/sub><\/p>\n","protected":false},"excerpt":{"rendered":"<p>After some weeks of reading and hearing in almost every news report about generative AI and ChatGPT in particular, and how it will change a developer&#8217;s life or even make developers obsolete, I was really curious to check it out myself and ask some developer questions. Since I&#8217;ve posted quite lot about SQL macros in the past few years, I thought aksing about them could be a good start point. One more argument to start with the topic I&#8217;m pretending to know lot about, is to be able to easily distinguish the truth from AI hallucination.<\/p>\n","protected":false},"author":1,"featured_media":1800,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,100],"tags":[117,116,103],"class_list":["post-1764","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general","category-sql-macros","tag-ai","tag-chatgpt","tag-sql-macros"],"_links":{"self":[{"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/posts\/1764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/comments?post=1764"}],"version-history":[{"count":31,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/posts\/1764\/revisions"}],"predecessor-version":[{"id":1804,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/posts\/1764\/revisions\/1804"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/media\/1800"}],"wp:attachment":[{"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/media?parent=1764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/categories?post=1764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/tags?post=1764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}