<?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>Question Re: SQL function returning NULL value . in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233853#M4153448</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Swapnil,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I checked the DEPARTMENT with max function it is working fine. I have tried by changing the variable data type to date&amp;nbsp; from datetime it is working . What is the problem with the datetime data type here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Ramana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 03 Aug 2015 14:00:26 GMT</pubDate>
    <dc:creator>venkataramana_paidi</dc:creator>
    <dc:date>2015-08-03T14:00:26Z</dc:date>
    <item>
      <title>SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaq-p/11233850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to capture the max date from the table and I am using the below function .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$G_LastUpdate = sql('Omega00', 'select max(LAST_UPDATE) from EMP_DIM');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print($G_LastUpdate);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it is returning the NULL value instead of the value. I have tried different varchar field in the&amp;nbsp; table but it is returning the value properly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jiveImage" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/761514" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/761508" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/761513" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jiveImage" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please suggest what is wrong here . Why not it is working for datetime and working for varchar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried in the SQL editor it is working fine . But It is not giving the DS script .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/761525" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Venkata Ramana Paidi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 13:34:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaq-p/11233850</guid>
      <dc:creator>venkataramana_paidi</dc:creator>
      <dc:date>2015-08-03T13:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233851#M4153446</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please check the connection of datastore !! It may be possbile your datastore is pointing to some other database!&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;SB&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 13:53:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233851#M4153446</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-08-03T13:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233852#M4153447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I change the data type for $G_LastUpdate&amp;nbsp; from datetime to date it is working. But&amp;nbsp; I don't understand why it is not working for datetime datatype&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 13:58:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233852#M4153447</guid>
      <dc:creator>venkataramana_paidi</dc:creator>
      <dc:date>2015-08-03T13:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233853#M4153448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Swapnil,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I checked the DEPARTMENT with max function it is working fine. I have tried by changing the variable data type to date&amp;nbsp; from datetime it is working . What is the problem with the datetime data type here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Ramana&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 14:00:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233853#M4153448</guid>
      <dc:creator>venkataramana_paidi</dc:creator>
      <dc:date>2015-08-03T14:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233854#M4153449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your backend database?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 14:13:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233854#M4153449</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-08-03T14:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233855#M4153450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sybase ASE&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 14:16:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233855#M4153450</guid>
      <dc:creator>venkataramana_paidi</dc:creator>
      <dc:date>2015-08-03T14:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233856#M4153451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is a limitation with timestamp column.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found it in SAP BODS technical manual 4.2..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/761526" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 14:21:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233856#M4153451</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-08-03T14:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233857#M4153452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Swapnil, May be it wont working with Sybase ASE datetime data type .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 14:27:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233857#M4153452</guid>
      <dc:creator>venkataramana_paidi</dc:creator>
      <dc:date>2015-08-03T14:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233858#M4153453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No.. It is generalized limitation not specific to any database!!! For all database it would be same.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 14:32:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233858#M4153453</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-08-03T14:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233859#M4153454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have you tried this - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$G_LastUpdate = sql('Omega00', 'select to_char(max(LAST_UPDATE),\'DD-MM-YYYY\') from EMP_DIM'); &lt;/P&gt;&lt;P&gt;$G_ConvertedDate = to_date($G_LastUpdate,'DD-MM-YYY');&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Aug 2015 21:54:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233859#M4153454</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2015-08-03T21:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233860#M4153455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To avoid this type of problems &lt;STRONG&gt;never&lt;/STRONG&gt; use date(time) variables as results of a DS sql function (which actually returns varchar results only) and always convert your database date(time)s to varchar in the select statement. Both internal and external date(time) formats may differ significantly from one environment to another.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; 
&lt;P&gt;$G_LastUpdate = sql('Omega00', 'select to_char(max(LAST_UPDATE),\'DD-MM-YYYY\') from EMP_DIM'); &lt;/P&gt;
&lt;P&gt;$G_ConvertedDate = to_date($G_LastUpdate,'DD-MM-YYY');&lt;/P&gt;
&lt;P style="min-height: 8pt; height: 8pt; padding: 0px;"&gt;&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;To make this work, make sure to declare $G_LastUpdate as varchar(10) and $G_ConvertedDate as date.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Aug 2015 06:54:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233860#M4153455</guid>
      <dc:creator>former_member187605</dc:creator>
      <dc:date>2015-08-04T06:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: SQL function returning NULL value .</title>
      <link>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233861#M4153456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Venkata ramana paidi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how did u achieve this , I am facing same problem with Sybase ASE in sap bods,I want to capture the date time in a variable like this format &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2016.04.14 15:03:31.450000000 &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help me in that&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Narendra &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Apr 2016 12:53:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sql-function-returning-null-value/qaa-p/11233861#M4153456</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2016-04-22T12:53:02Z</dc:date>
    </item>
  </channel>
</rss>

