<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Prepare statement with null values in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669607#M1867982</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm surprised about this behaviour, because the code is a snippet of a productive program. I haven't got any idea why the null value is not set in your case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding your wishes for more convenience, I agree with you that it is rather much overhead. Sometimes, coding the native sql (without OO-approach) is faster and there you can specify the null values directly - but this is only possible if the null values are set for the same fields in each case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Oct 2014 06:58:57 GMT</pubDate>
    <dc:creator>former_member201285</dc:creator>
    <dc:date>2014-10-30T06:58:57Z</dc:date>
    <item>
      <title>Prepare statement with null values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669604#M1867979</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using&amp;nbsp;&amp;nbsp; cl_sql_prepared_statement&amp;nbsp; from cl_sql_connection classes to insert data to a non SAP database.&amp;nbsp; The problem I'm finding is that I'm not able to inert null values to a column: if the value is initial it sets an empty string or if I try to set 'NULL' to the column it sets 'NULL' as the content of a varchar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way to insert null value to a column using prepared statements ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;An example of the code I'm using, I want to insert name1 as NULL, not '' or 'NULL'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt; CLEAR lv_insert&lt;SPAN class="L0S70"&gt;-&lt;/SPAN&gt;name1.&lt;/P&gt;
&lt;P&gt; lv_insert&lt;SPAN class="L0S70"&gt;-&lt;/SPAN&gt;status_sap &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;&lt;SPAN class="L0S32"&gt;1&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt; p_con_ref &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;cl_sql_connection&lt;SPAN class="L0S70"&gt;=&amp;gt;&lt;/SPAN&gt;get_connection&lt;SPAN class="L0S55"&gt;( &lt;/SPAN&gt;cv_con_name &lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt; l_stmt &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;&lt;SPAN class="L0S33"&gt;'INSERT dbo.contacts ( Name1, Status_SAP ) VALUES ( ?, ? )'&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt; l_prepstmt_ref &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;p_con_ref&lt;SPAN class="L0S70"&gt;-&amp;gt;&lt;/SPAN&gt;prepare_statement&lt;SPAN class="L0S55"&gt;( &lt;/SPAN&gt;statement &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;l_stmt &lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt; &lt;SPAN class="L0S31"&gt;*&amp;nbsp; CATCH cx_sql_exception.&amp;nbsp;&amp;nbsp;&amp;nbsp; "&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; &lt;SPAN class="L0S52"&gt;GET &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;REFERENCE &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;OF &lt;/SPAN&gt;lv_insert &lt;SPAN class="L0S52"&gt;INTO &lt;/SPAN&gt;l_dref&lt;SPAN class="L0S55"&gt;. &lt;/SPAN&gt;&lt;SPAN class="L0S31"&gt;" set output table&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt; l_prepstmt_ref&lt;SPAN class="L0S70"&gt;-&amp;gt;&lt;/SPAN&gt;set_param_struct&lt;SPAN class="L0S55"&gt;( &lt;/SPAN&gt;l_dref &lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt; l_prepstmt_ref&lt;SPAN class="L0S70"&gt;-&amp;gt;&lt;/SPAN&gt;execute_update&lt;SPAN class="L0S55"&gt;( &lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 12:27:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669604#M1867979</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-10-29T12:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Prepare statement with null values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669605#M1867980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrés,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this code snippet could help you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA: dref_null_indicator &lt;SPAN class="L0S52"&gt;TYPE &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;REF &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;TO &lt;/SPAN&gt;int2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S52" style="font-size: 10pt;"&gt;CONSTANTS&lt;/SPAN&gt;&lt;SPAN class="L0S55" style="font-size: 10pt;"&gt;: &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;gc_null_indicator &lt;/SPAN&gt;&lt;SPAN class="L0S52" style="font-size: 10pt;"&gt;TYPE &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;int2 &lt;/SPAN&gt;&lt;SPAN class="L0S52" style="font-size: 10pt;"&gt;VALUE &lt;/SPAN&gt;&lt;SPAN class="L0S33" style="font-size: 10pt;"&gt;'-1'&lt;/SPAN&gt;&lt;SPAN class="L0S55" style="font-size: 10pt;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55" style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55" style="font-size: 10pt;"&gt;&lt;STRONG&gt;* Pass a null value&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;GET &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;REFERENCE &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;OF my_field&lt;/SPAN&gt; &lt;SPAN class="L0S52"&gt;INTO &lt;/SPAN&gt;dref&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="L0S52"&gt;GET &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;REFERENCE &lt;/SPAN&gt;&lt;SPAN class="L0S52"&gt;OF &lt;/SPAN&gt;gc_null_indicator &lt;SPAN class="L0S52"&gt;INTO &lt;/SPAN&gt;dref_null_indicator&lt;SPAN class="L0S55"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; prepstmt_ref&lt;SPAN class="L0S70"&gt;-&amp;gt;&lt;/SPAN&gt;set_param&lt;SPAN class="L0S55"&gt;( &lt;/SPAN&gt;data_ref &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;dref&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ind_ref &lt;SPAN class="L0S55"&gt;= &lt;/SPAN&gt;dref_null_indicator &lt;SPAN class="L0S55"&gt;)&lt;/SPAN&gt;&lt;SPAN class="L0S55"&gt;.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S55"&gt;Ulrich&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 12:59:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669605#M1867980</guid>
      <dc:creator>former_member201285</dc:creator>
      <dc:date>2014-10-29T12:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: Prepare statement with null values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669606#M1867981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It stills uses the empty value of my_field and not of the ind_ref with the null indicator.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Besides it would be nice something that does it from SET_PARAM_STRUCTURE so I don't have to go field by field. Or at least if I could use the SET_PARAM after pasing the structure so I just have to reset the initial fields to null.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Oct 2014 14:55:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669606#M1867981</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-10-29T14:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: Prepare statement with null values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669607#M1867982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm surprised about this behaviour, because the code is a snippet of a productive program. I haven't got any idea why the null value is not set in your case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding your wishes for more convenience, I agree with you that it is rather much overhead. Sometimes, coding the native sql (without OO-approach) is faster and there you can specify the null values directly - but this is only possible if the null values are set for the same fields in each case.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 06:58:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669607#M1867982</guid>
      <dc:creator>former_member201285</dc:creator>
      <dc:date>2014-10-30T06:58:57Z</dc:date>
    </item>
    <item>
      <title>Re: Prepare statement with null values</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669608#M1867983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your help, finally we have decided to use native SQL, the 'only' reason we were trying to use the OO approach was to avoid SQL Injection and give the code a clean and more standarized look.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Oct 2014 10:23:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/prepare-statement-with-null-values/m-p/10669608#M1867983</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-10-31T10:23:39Z</dc:date>
    </item>
  </channel>
</rss>

