<?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: How to do a WHILE DO loop on data from a SQL Calculation View in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877088#M3547173</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jody - please see my response to Shree&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 01 Dec 2013 20:17:01 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2013-12-01T20:17:01Z</dc:date>
    <item>
      <title>How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaq-p/9877083</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class="blurb respectLineBreaks"&gt;&lt;SPAN class="comment-block respectLineBreaks less-block"&gt;I would like to do a WHILE DO loop, I am pulling columns from a SQL Calculation View to Do the iteration. I want to start with a value AD = 2 and iterate until a condition is met. In addition to the columns I pull in, I also need to calculate 6 new columns (AT1, AU, AE, X, AV, and V). These columns could be combined into one but I have been keeping them separate to keep the final formula for V shorter.&amp;nbsp; These values will &lt;SPAN class="comment-block respectLineBreaks more-block"&gt; change as a function of AD until the condition for V is met. I can pull in the columns from my SQL Calculation View, I just am not able to iterate.&lt;BR /&gt;My code looks something this (I have simplified the formulas some to make it shorter) but it gives you an idea what I am trying to do.&lt;BR /&gt;DECLARE AD DOUBLE := 2;&lt;BR /&gt;WHILE :V &amp;gt; 0 DO&lt;BR /&gt;SELECT MATNR, WERKS, YEAR1, AVG_QUANTITY, STDDEV_QUANTITY,&lt;BR /&gt;AVG_ACTUAL, STDDEV_ACTUAL, STDDEV_YIELD, ZSTCT, LOSFX,&lt;BR /&gt;ZSTCC, LGRAD, VERPR, LKOST, ITERATION, DEMAND_TERM, DEMAND_TERM_SQD,&lt;BR /&gt;SUPPLY_TERM, SUPPLY_TERM_SQD, YIELD_TERM, YIELD_TERM_SQD,&lt;BR /&gt;SUM_OF_SQUARES, STDDEV_DEMAND_LT,&lt;BR /&gt;AT1 := ((:AD)/(STDDEV_DEMAND_LT)),&lt;BR /&gt;AV := (SQRT(20/POWER( :AT1 ,2))),&lt;BR /&gt;AU := ((5.6211054 * :AV) + (-3.883683 * (POWER(:AV,2)))),&lt;BR /&gt;AE := (STDDEV_DEMAND_LT)* :AU,&lt;BR /&gt;X := :AE/(52*(AVG_QUANTITY)),&lt;BR /&gt;V := ((:AD+ITERATION)-:AD)*((1-ZSTCT)+(ZSTCC* :X))&lt;BR /&gt;FROM "_SYS_BIC"."sts/SQLEPQ1";&lt;BR /&gt;IF :V &amp;lt; 0 THEN&lt;BR /&gt;INSERT INTO "_SYS_BIC"."sts/SQLEPQ2" VALUES (:AD);&lt;BR /&gt;END IF;&lt;BR /&gt;AD := :AD+ITERATION;&lt;BR /&gt;END WHILE;&lt;BR /&gt;I keep getting an error "Internal deployment of object failed;Repository: Encountered an error in repository runtime extension;Internal Error:Deploy Calculation View: SQL: sql syntax error: incorrect syntax near "DECLARE": line 8 col 1" . I have tried many ways and get errors around the DECLARE or WHILE.&lt;BR /&gt;If there is a better way - I am open&lt;BR /&gt; &lt;BR /&gt;Thanks&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="blurb respectLineBreaks"&gt;&lt;SPAN class="comment-block respectLineBreaks less-block"&gt;&lt;SPAN class="comment-block respectLineBreaks more-block"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Nov 2013 03:56:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaq-p/9877083</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-11-26T03:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877084#M3547169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please pardon my ignorance as I did not go through the full code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But&lt;/P&gt;&lt;P&gt;&lt;SPAN class="comment-block respectLineBreaks less-block"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;SPAN class="comment-block respectLineBreaks more-block"&gt;INSERT INTO "_SYS_BIC"."sts/SQLEPQ2" VALUES (:AD)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This won't work as SQLEPQ2 is just a View and you cannot insert data into a view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="comment-block respectLineBreaks less-block"&gt;&lt;SPAN class="comment-block respectLineBreaks more-block"&gt;--&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="comment-block respectLineBreaks less-block"&gt;&lt;SPAN class="comment-block respectLineBreaks more-block"&gt;Shreepad Patil&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2013 14:46:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877084#M3547169</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-11-27T14:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877085#M3547170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As implied by Shreepad, please provide a simplified version of your code. I suspect there are more issues than the (useful) one Shree mentioned. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then folks can help address the errors, and you can then re-factor all of your code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;Jody&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2013 16:52:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877085#M3547170</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-11-27T16:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877086#M3547171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Couple of points from my side.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may wish to use SELECT ... INTO ... statement to populate the declared variables. I am not sure if the direct value assignment to the variable in the SELECT statement is supported.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Secondly as mentioned above, the HANA information models (HANA Views) are column views as read only objects. These are not data bearing objects, hence you cannot insert data to the views directly. Instead you may want to insert data to the underlying physical tables. Once the data is inserted to the underlying physical tables, it will be reflected in the view.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ravi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Nov 2013 20:20:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877086#M3547171</guid>
      <dc:creator>Ravi_Channe</dc:creator>
      <dc:date>2013-11-27T20:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877087#M3547172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Shree, Jody, and Ravi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ignorance is all my end - I apologize and appreciate your help. I agree there are many issues. I have cleaned up the code and resolved many of the issues. I now can create the table, create the procedure, and call the procedure. Unfortunately I obtained 0 rows of data. Please see my TXT file attached.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create a table with 3 primary keys/attributes and 2 measures from another calculation view(SQL). I also add 8 variable columns to this table. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then create the procedure to build the table that contain the While Do statement.&amp;nbsp; The goal is to iterate on the 8 variable columns until the condition is met. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally I call the procedure.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Dec 2013 20:10:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877087#M3547172</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-12-01T20:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877088#M3547173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Jody - please see my response to Shree&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Dec 2013 20:17:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877088#M3547173</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-12-01T20:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877089#M3547174</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Ravi - please see my response to Shree&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 01 Dec 2013 20:17:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877089#M3547174</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-12-01T20:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877090#M3547175</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a few things in mind after going through the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. I have a feeling that Table2 is view. Now if this is an Analytic View then the select query would not work as it requires group by clause.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. I have not tried it but I think in the query when you say 'AS VAR_2', it creates an &lt;STRONG&gt;alias&lt;/STRONG&gt; which is different from the &lt;STRONG&gt;variable&lt;/STRONG&gt; VAR_2. So when you are referencing to &lt;STRONG&gt;:&lt;/STRONG&gt;VAR_2. It will fetch the value of &lt;STRONG&gt;variable&lt;/STRONG&gt; VAR_2, which is not initialized at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Recommend you to check the SELECT query progressively on the SQL Editor and/or within the procedure itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Shreepad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Dec 2013 06:49:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877090#M3547175</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-12-02T06:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877091#M3547176</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Shree&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your suggestions make total sense, Yes, Table 2 is an analytic view so I added an Group By and Order By.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also see what you mean by VAR_2 so I eliminated VAR_2 through VAR_7 because they feed Var_8. This makes formulas longer but eliminate this issue as one formula variable feeds the next. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since I am trying to do a While Do against Var_8, should I be adding a output variable against the procedure instead? I keep getting an error "SAP DBTech JBDC: [260] (at 112): invalid column name for Var_8.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue is I want to do a While Do against my last column (i.e. Var_8) in the table but how do I do a While Do such that this value stops when greater than zero,&lt;BR /&gt;.&lt;/P&gt;&lt;P&gt;This is why I am wondering if my procedure should specify an output instead? Or do I declare a variable equal to Var_8&amp;nbsp; I can't seem to get past an invalid column for While Do Var_8 &amp;gt; 0. .&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Dec 2013 04:25:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877091#M3547176</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-12-03T04:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877092#M3547177</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 made some modifications to your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;CREATE COLUMN TABLE "TABLE_2" (&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "ATT_PK1" NVARCHAR(18),&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "ATT_PK2" NVARCHAR(4),&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "ATT_PK3" NVARCHAR(4),&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PRIMARY KEY (ATT_PK1, ATT_PK2, ATT_PK3),&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "MEAS_1" DOUBLE,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "MEAS_2" DECIMAL(5,2),&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "VAR_1" DOUBLE,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "VAR_8" DOUBLE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;CREATE PROCEDURE BUILD_TABLE_2 ( ) LANGUAGE SQLSCRIPT AS&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;VAR_1 DOUBLE;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;VAR_8 DOUBLE; --Change here&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;BEGIN&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;VAR_1 := 2;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;WHILE&amp;nbsp; VAR_8 &amp;gt; 0 DO&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;INSERT INTO TABLE_2&lt;/P&gt;
&lt;P&gt;SELECT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK1",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK2",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK3",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."MEAS_1",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."MEAS_2",&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; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; :VAR_1,&lt;/P&gt;
&lt;P&gt;&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; &lt;/P&gt;
&lt;P&gt;((:VAR_1 + "_SYS_BIC"."sts/TABLE_1"."MEAS_2") - :VAR_1)&amp;nbsp; * ("_SYS_BIC"."sts/TABLE_1"."MEAS_1" )&amp;nbsp; AS "MEAS_3"&amp;nbsp;&amp;nbsp; --Its just an alias(Will display the table with this column name)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;FROM "_SYS_BIC"."sts/TABLE_1"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;GROUP BY&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;ATT_PK1, ATT_PK2, ATT_PK3,&lt;/P&gt;
&lt;P&gt;"_SYS_BIC"."sts/TABLE_1"."MEAS_1",&lt;/P&gt;
&lt;P&gt;"_SYS_BIC"."sts/TABLE_1"."MEAS_2"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;ORDER BY&lt;/P&gt;
&lt;P&gt;ATT_PK1, ATT_PK2, ATT_PK3;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;--Add this query&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;SELECT TOP 1 ((:VAR_1 + "_SYS_BIC"."sts/TABLE_1"."MEAS_2") - :VAR_1)&amp;nbsp; * ("_SYS_BIC"."sts/TABLE_1"."MEAS_1" )&amp;nbsp; INTO VAR_8 FROM "_SYS_BIC"."sts/TABLE_1"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;GROUP BY&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;ATT_PK1, ATT_PK2, ATT_PK3,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;"_SYS_BIC"."sts/TABLE_1"."MEAS_1",&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;"_SYS_BIC"."sts/TABLE_1"."MEAS_2"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;ORDER BY&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;ATT_PK1, ATT_PK2, ATT_PK3 ASC ; --or DESC as per requirement&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;--end of query&lt;/P&gt;
&lt;P&gt;&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; &lt;/P&gt;
&lt;P&gt;VAR_1 := VAR_1 + 1;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;END WHILE;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;END;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;CALL BUILD_TABLE_2 ( )&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Very Important:&lt;/STRONG&gt; You will have to use the ASC or DESC very carefully.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you get what I am trying to do and build your code accordingly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Shreepad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Dec 2013 07:23:51 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877092#M3547177</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2013-12-03T07:23:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877093#M3547178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shree&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you, your suggestion makes sense and have been trying many ways. I can build the procedure but I still struggle with zero rows when I call the procedure. I am now getting the following error when I call the procedure&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"Could not execute 'CALL BUILD_TABLE_2 ()' in 233 ms 812 us, SAP DBTech JDBC: [340]: not all variable bound: [340] SYSTEM.BUILD_TABLE_2: line 13 col 3 (at pos 161): not all variables bound exception:&amp;nbsp; not all variables bound:&amp;nbsp; [340] not all variables bound: unbound parameter : 0 of 1 Please check lines"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am attaching my code as txt files - it was also suggested to utilize a Loop Over Curser and I have attached a text version of this as well. At the end of the code I have added the error I get this method as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully you can help point me in the right direction&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;&lt;/P&gt;&lt;P&gt;John &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jan 2014 01:44:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877093#M3547178</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-01-06T01:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877094#M3547179</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the code without cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;I can build the procedure but I still struggle with zero rows when I call the procedure.&lt;/P&gt;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Sometimes the SQL Console will not show the results properly while running a procedure, can you check the table directly instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;SELECT * FROM TABLE_2;&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. If the earlier step also shows 0 records in the table then can you try running the SQL Statement separately in the console&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&lt;P&gt;SELECT&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK1", &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK2", &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK3",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."MEAS_1", &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."MEAS_1" - 2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FROM "_SYS_BIC"."sts/TABLE_1"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GROUP BY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK1", &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK2", &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK3",&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."MEAS_1"&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; &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ORDER BY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK1", &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK2", &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "_SYS_BIC"."sts/TABLE_1"."ATT_PK3";&lt;/P&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Notice that I have removed the :VAR_1 and replaced it with 2, That is the value of the variable in first iteration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As far as the code with Cursor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1. Declare statements should be the 1st statementa after BEGIN, Can you remove the VAR_1 assignment from that position and make it go after the declare.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2. When you loop over the cursor, use parenthesis after the cursor name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FOR cur_row as CURSOR1() DO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Though as you mention, using a Cursor is a bad idea(Its a real performance killer). If this is a critical code then I would advise against the use of cursors.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us know if it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Shreepad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jan 2014 05:59:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877094#M3547179</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-01-06T05:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877095#M3547180</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shree&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think we are getting closer - thank you. I ran step 1 as you suggested and the result was 0 rows. I then ran step 2 and I did get all my rows.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does this mean it is not being inserted into the table or something is wrong with the while do? I added the Insert Into statement for Step 2 and then Selected Table_2 - this did bring up the rows of data, so it seems to be the while do. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again - you have been very helpful&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Jan 2014 19:26:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877095#M3547180</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-01-11T19:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877096#M3547181</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The tests show results which are quite surprising. Although the debugging you did show that the problem might be with the WHILE..DO loop, but it is looking very fine to me..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Before we conclude that the problem is with the loop, one more thing you can try is put this statement inside the loop as the first line after DO&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT :VAR_2 FROM DUMMY;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and then call the procedure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the loop is getting executed then it should open up result tabs with the value of VAR_2 for each iteration. This would confirm whether the loop is getting executed or not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Shreepad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jan 2014 15:16:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877096#M3547181</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-01-13T15:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877097#M3547182</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shree&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp; I tried as you suggested and still got zero rows when I called the procedure. I also tried Select * From Table_2 and only showed the Header Row.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the procedure two ways (see attached text files), one where I do not set VAR_2 equal to anything and another where I set it equal to 1. The first way (Method 1), I get zero rows. The second way (Method 2), I get the following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could not execute 'CALL BUILD_TABLE_2 ( )' in 161 ms 191 us, SAP DBTech JBDC: [340]: not all variable bound: [340] SYSTEM.BUILD_TABLE_2: line 16 col 3 (at pos 194): not all variables bound exception: not all variables bound: [340] not all variables bound: unbound parameter : 0 of 1Please check lines:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jan 2014 23:28:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877097#M3547182</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-01-13T23:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877098#M3547183</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Method 2 would give an error for sure as loop's WHILE condition would check whether VAR_2 &amp;gt; 0 and whereas the VAR_2 variable does not hold any value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, you should get a similar result(as given below) when trying to execute via the method 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried to build a similar procedure(just the loop part of it)&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/363236" /&gt;&lt;/P&gt;&lt;P&gt;Output:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/363238" /&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/jiveimages/363239" /&gt;&lt;/P&gt;&lt;P&gt;If the code goes through loop one should get similar kind of display. If you're getting these kind of screens in method 1 then the select statement could be faulty otherwise if you are not getting these screens then the loop itself has an issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not able to see why it is not working. The code seems to be correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you try the same code I have written in your system. Let's see if this piece of code works.&lt;/P&gt;&lt;P&gt;Which version of HANA DB are you using? There might be a slight possibility of bugs with the version you're using. I am on HANA Rev 70.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Shreepad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jan 2014 14:26:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877098#M3547183</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-01-14T14:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877099#M3547184</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Shree&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks. I ran the same code and got the same results as you. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using Rev 68 and will update to 70 tonight. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I noticed you had "WHILE :VAR_1 &amp;gt; 0 DO" instead "WHILE VAR_1 &amp;gt; 0 DO". I made this change in my original code and this did not make a difference - still no rows of data. I was hoping it would be as simple as this ; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could it be that in your code we only use VAR_1. First in the While Do and then second we iterate on it by subtracting one.?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is in comparison having VAR_2 in the While Do and iterate using VAR_1. Plus I am using data from the table to calculate VAR_2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do I need to be doing more with VAR_2?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jan 2014 01:49:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877099#M3547184</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-01-15T01:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877100#M3547185</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, I agree that you are doing much more with the looping variable VAR_2, but it should have gone inside the loop for the first time at least.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it went inside the loop then it should have been able to print the VAR_2 at least once. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let us know if the upgrade made this piece of code work. Until the upgrade can you try declaring the variable as INTEGER and running the loop..not sure whether it would work or not.&lt;SPAN __jive_emoticon_name="confused" __jive_macro_name="emoticon" class="jive_macro_emoticon jive_macro jive_emote" src="https://community.sap.com/408/images/emoticons/confused.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again can you try writing a similar display statement such as &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT 5 FROM DUMMY; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;put this statement outside the loop and check whether it gives an output while running the procedure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Shreepad&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jan 2014 04:41:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877100#M3547185</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-01-17T04:41:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to do a WHILE DO loop on data from a SQL Calculation View</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877101#M3547186</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Shree - I want to thank you for all your help -&amp;nbsp; I finally got my While Loop working correctly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Feb 2014 21:46:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-do-a-while-do-loop-on-data-from-a-sql-calculation-view/qaa-p/9877101#M3547186</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-02-09T21:46:09Z</dc:date>
    </item>
  </channel>
</rss>

