$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: false, vro: false, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
-1

hana studio indefinitely executes the below query

Jun 10, 2017 at 02:37 PM

79

avatar image

Hi,

while running the below code hana goes into indefinite run time.

Any help will be appreciated.

CREATE PROCEDURE "FOR_LOOP_EXAMPLE"() LANGUAGE SQLSCRIPT SQL SECURITY INVOKER AS /*********BEGIN PROCEDURE SCRIPT ************/ BEGIN DECLARE v_index INT=1; DECLARE v_index2 INT=1; DECLARE min INT ; DECLARE max INT ; create table t( rownum int, itemcode varchar(50)); Insert into t SELECT Row_Number() OVER (ORDER BY T0."ItemCode" ) as a ,T0."ItemCode" FROM OITM T0 WHERE T0."ItemCode" in('I03515','I04289'); SELECT (SELECT MIN(rownum) FROM t) INTO min FROM DUMMY; SELECT (SELECT MAX(rownum) FROM t) INTO max FROM DUMMY; -- select min as min,max as max FROM DUMMY; FOR v_index IN :min .. :max DO FOR v_index IN 1 .. 1 DO Select v_index from dummy; select * from oitm where "ItemCode" in (Select itemcode from t where rownum=v_index); END FOR; END FOR; -- Select * from t; drop table t; END; CALL "FOR_LOOP_EXAMPLE"();

Regards

Khagesh

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Lars Breddemann
Jun 13, 2017 at 06:21 AM
0

Why wouldn't it?

You explicitly stated that you want a loop over **v_index**

DECLARE v_index INT=1;
DO FOR v_index IN 1 .. 1 DO 
    Select v_index from dummy; 
    select * from oitm where "ItemCode" in (Select itemcode from t where rownum=v_index); 
END FOR; 

As v_index never gets updated, it stays in the range between 1 and 1 - and the loop never terminates.

Share
10 |10000 characters needed characters left characters exceeded