<?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: WHILE TO UPDATE LOCAL TEMPORARY TABLE in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/while-to-update-local-temporary-table/m-p/12731438#M2020464</link>
    <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;roseavi&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Just give it a try .. &lt;BR /&gt;You can replace the while loop with a cursor in HANA. &lt;A href="https://help.sap.com/docs/SAP_HANA_PLATFORM/de2486ee947e43e684d39702027f8a94/6b2f29bbddcc431da72d9602a3049d93.html" target="_blank"&gt;Cursors are used to retrieve data from the result set of a SELECT statement one row at a time, instead of retrieving the entire result set at once&lt;/A&gt;&lt;A href="https://help.sap.com/docs/SAP_HANA_PLATFORM/de2486ee947e43e684d39702027f8a94/6b2f29bbddcc431da72d9602a3049d93.html" target="_blank"&gt;&lt;SUP&gt;1&lt;/SUP&gt;&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/59883756/while-loop-is-ending-to-early-in-sap-hana-sql-procedure" target="_blank"&gt;Here is an example of how to use a cursor in HANA&lt;/A&gt;&lt;A href="https://stackoverflow.com/questions/59883756/while-loop-is-ending-to-early-in-sap-hana-sql-procedure" target="_blank"&gt;&lt;SUP&gt;2&lt;/SUP&gt;&lt;/A&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DECLARE cursor_name CURSOR FOR SELECT column1, column2 FROM table_name;
OPEN cursor_name;
FETCH NEXT FROM cursor_name INTO @variable1, @variable2;
WHILE @@FETCH_STATUS = 0
BEGIN
    -- Do something with the variables
    FETCH NEXT FROM cursor_name INTO @variable1, @variable2;
END;
CLOSE cursor_name;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 31 May 2023 04:29:50 GMT</pubDate>
    <dc:creator>Yogananda</dc:creator>
    <dc:date>2023-05-31T04:29:50Z</dc:date>
    <item>
      <title>WHILE TO UPDATE LOCAL TEMPORARY TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/while-to-update-local-temporary-table/m-p/12731437#M2020463</link>
      <description>&lt;P&gt;Hello everyone&lt;/P&gt;
  &lt;P&gt;I am working on a query which by means of 3 temporary tables is built.&lt;/P&gt;
  &lt;P&gt;The first two tables feed the third but I have no way of being able to translate from SQL to hana a while loop that updates one of the fields of the third temporary table, SAP tells me that it does not support the condition-&lt;/P&gt;
  &lt;P&gt;Could someone tell me how I can replace this cycle or how I would have to structure it.&lt;/P&gt;
  &lt;P&gt;DECLARE I smallint;&lt;/P&gt;
  &lt;P&gt;DECLARE FechaI date;&lt;/P&gt;
  &lt;P&gt;DECLARE FechaF date;&lt;/P&gt;
  &lt;P&gt;I := 0;&lt;/P&gt;
  &lt;P&gt;FechaI := '2022-01-01'; &lt;/P&gt;
  &lt;P&gt;FechaF := '2022-12-31';&lt;/P&gt;
  &lt;P&gt;CREATE LOCAL TEMPORARY COLUMN TABLE #BASEVESAS (&lt;/P&gt;
  &lt;P&gt;) ;&lt;/P&gt;
  &lt;P&gt;CREATE LOCAL TEMPORARY COLUMN TABLE # BASEAAS (&lt;/P&gt;
  &lt;P&gt;) ;&lt;/P&gt;
  &lt;P&gt;CREATE LOCAL TEMPORARY COLUMN TABLE #ESTRLAS (SELECT * FROM (SELECT * FROM #BASEVESAS UNION ALL SELECT * FROM #BASEAAS ) AS T1 ORDER BY T1."GroupMask", T1."GrpLine");&lt;/P&gt;
  &lt;P&gt;WHILE :I &amp;lt; 5 &lt;/P&gt;
  &lt;P&gt;DO UPDATE #ESTRUCTURAFINAL &lt;/P&gt;
  &lt;P&gt;SET #ESTRUCTURAFINAL."Monto" = &lt;/P&gt;
  &lt;P&gt;IFNULL(&lt;/P&gt;
  &lt;P&gt;(SELECT SUM(T0."Monto") FROM #ESTRLAS T0 WHERE T0."FatherNum" = #ESTRLAS ."Cuenta" AND T0."ProfitCode" = #ESTRLAS ."ProfitCode"), 0)&lt;/P&gt;
  &lt;P&gt; WHERE #ESTRUCTURAFINAL."Postable" = 'N';&lt;/P&gt;
  &lt;P&gt;I := :I + 1;&lt;/P&gt;
  &lt;P&gt;END WHILE;&lt;/P&gt;
  &lt;P&gt;ALL THE INSERTS ----&lt;/P&gt;
  &lt;P&gt;SELECT * FROM #ESTRLAS T1 LEFT OUTER JOIN OPRC T2 ON T1."ProfitCode" = T2."PrcCode" ORDER BY T1."GroupMask", T1."GrpLine";&lt;/P&gt;
  &lt;P&gt;DROP TABLE #BASEVES;&lt;/P&gt;
  &lt;P&gt;DROP TABLE #BASEA;&lt;/P&gt;
  &lt;P&gt;DROP TABLE #ESTRL;&lt;/P&gt;
  &lt;P&gt;Like this is the structure, can you help me!&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 22:08:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/while-to-update-local-temporary-table/m-p/12731437#M2020463</guid>
      <dc:creator>former_member858819</dc:creator>
      <dc:date>2023-05-30T22:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: WHILE TO UPDATE LOCAL TEMPORARY TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/while-to-update-local-temporary-table/m-p/12731438#M2020464</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;roseavi&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Just give it a try .. &lt;BR /&gt;You can replace the while loop with a cursor in HANA. &lt;A href="https://help.sap.com/docs/SAP_HANA_PLATFORM/de2486ee947e43e684d39702027f8a94/6b2f29bbddcc431da72d9602a3049d93.html" target="_blank"&gt;Cursors are used to retrieve data from the result set of a SELECT statement one row at a time, instead of retrieving the entire result set at once&lt;/A&gt;&lt;A href="https://help.sap.com/docs/SAP_HANA_PLATFORM/de2486ee947e43e684d39702027f8a94/6b2f29bbddcc431da72d9602a3049d93.html" target="_blank"&gt;&lt;SUP&gt;1&lt;/SUP&gt;&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/59883756/while-loop-is-ending-to-early-in-sap-hana-sql-procedure" target="_blank"&gt;Here is an example of how to use a cursor in HANA&lt;/A&gt;&lt;A href="https://stackoverflow.com/questions/59883756/while-loop-is-ending-to-early-in-sap-hana-sql-procedure" target="_blank"&gt;&lt;SUP&gt;2&lt;/SUP&gt;&lt;/A&gt;:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DECLARE cursor_name CURSOR FOR SELECT column1, column2 FROM table_name;
OPEN cursor_name;
FETCH NEXT FROM cursor_name INTO @variable1, @variable2;
WHILE @@FETCH_STATUS = 0
BEGIN
    -- Do something with the variables
    FETCH NEXT FROM cursor_name INTO @variable1, @variable2;
END;
CLOSE cursor_name;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 May 2023 04:29:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/while-to-update-local-temporary-table/m-p/12731438#M2020464</guid>
      <dc:creator>Yogananda</dc:creator>
      <dc:date>2023-05-31T04:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: WHILE TO UPDATE LOCAL TEMPORARY TABLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/while-to-update-local-temporary-table/m-p/12731439#M2020465</link>
      <description>&lt;P&gt;Thank so much, it works&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 10:46:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/while-to-update-local-temporary-table/m-p/12731439#M2020465</guid>
      <dc:creator>former_member858819</dc:creator>
      <dc:date>2023-06-01T10:46:10Z</dc:date>
    </item>
  </channel>
</rss>

