ibm midrange - RPG exec sql works only once -


i wrote program in rpg iv free-form , met problem. im trying execute sql statment with:

dcl-proc getrecord; dcl-pi *n int(5) end-pi; dcl-s rec int(5) inz(0);  exec sql select max(score) :rec snk_hisc;  return rec; end-proc;    

it works once after compilation. maybe should reset indicators or sql flags? @ end of program use:

*inlr = *on; return;     

where procedure called:

   exfmt back;    exfmt info;     inital();      dow run , alive;      write mainboard;      read(e) ake_dsp;      run = fkeylistener();      alive = goforward();    enddo;    lscore = points;    if points > getrecord();      lrecord = 'new record!';       exec sql        insert ake_hisc( usid , score) values( :userid , :points);     endif;    exfmt ending;      *inlr = *on;    return;  

and in procedure:

dcl-proc inital;      snake(1).x = 5;      snake(2).x = 5;      snake(3).x = 5;      snake(1).y = 5;      snake(2).y = 6;      snake(3).y = 7;      direction.x = 1;      direction.y = 0;      score = points;      record = getrecord();      gensnack();      refresh();    end-proc; 

i run program cl program:

         pgm           monmsg     msgid(cpf0000 mch0000) exec(goto cmdlbl(end))           ovrdspf    file(ake_dsp) dev(*requester) waitrcd(1)           call       pgm(ake_s)   end:              dltovr     file(*all)          monmsg     msgid(cpf0000)           endpgm 

problem not sql query is. removed procedure getrecord() , make rec global variable , sql query placed inside main cycle thats all.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -