<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Sql on David Lang</title>
    <link>https://www.davidlang.tech/tags/sql/</link>
    <description>Recent content in Sql on David Lang</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Thu, 16 Nov 2023 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.davidlang.tech/tags/sql/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Using dynamic SQL query in Redshift database</title>
      <link>https://www.davidlang.tech/posts/using-sql-dynamic-queries-in-redshift-database/</link>
      <pubDate>Thu, 16 Nov 2023 00:00:00 +0000</pubDate>
      <guid>https://www.davidlang.tech/posts/using-sql-dynamic-queries-in-redshift-database/</guid>
      <description>&lt;p&gt;While working with a client, we had a requirement to perform bulk insert/update using &lt;strong&gt;&lt;a href=&#34;https://docs.retool.com/docs/working-with-tables&#34;&gt;Retool table&lt;/a&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;a href=&#34;https://aws.amazon.com/redshift/&#34;&gt;Redshift database&lt;/a&gt;&lt;/strong&gt;. For this situation, We had to loop through the table records and execute a dynamic SQL query in Redshift.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Redshift database&lt;/strong&gt; supports execution of &lt;strong&gt;dynamic SQL&lt;/strong&gt; with the help of &lt;strong&gt;Prepared Statements&lt;/strong&gt; or &lt;strong&gt;Stored Procedures&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;prepared-statements&#34;&gt;Prepared Statements&lt;/h2&gt;&#xA;&lt;p&gt;We use prepared statements when we want to execute dynamic SQL queries directly without a stored procedure. When a prepared statement is executed, the SQL statement is parsed, rewritten, and planned. We then &lt;strong&gt;EXECUTE&lt;/strong&gt; the prepared statement.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
