4gl return value problem
Posted in 2004
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
Hi there , I had a question occurred when my 4gl main program calling a function. There seems to be something wrong with the return value Statements in my main program : ud_fun() ........... let p=1 while p if del_fun() then exit while end if let p=0 end while if p then rollback work prompt "error... " for char answer end if ............ end function del_fun() ........ if m_ac31('2',n.acm02,n.acm00,n.acm01, o[i].acn02 thru o[i].acn15) then display "m_ac31 error ",o[i].acn02 at 21,1 sleep 5 return 1 end if .................. end function statements in my function m_ac31() ............... if status or sqlca.sqlerrd[3]<1 then display "Upd ac31 err-",status sleep 5 return 1 end if ...... My problem is that I 'sometimes ' found that the m_ac31 function was performed successfully (because there is no error message displayed ) but the results comed out wrong ; which means there were error during the function was called but my main program did not catch the return value .Could any one tell me where the problem is ? My Informix was old SE. I do not know what is the problem in my program. Any message from you will be appreciated. Thanks in advnce
daisy wrote: > I had a question occurred when my 4gl main program calling a > function. There seems to be something wrong with the return value > > Statements in my main program : > > ud_fun() > ........... > let p=1 > while p > if del_fun() then exit while end if > let p=0 > end while > if p then > rollback work > prompt "error... " for char answer > end if > ............ > end function > > > del_fun() > ........ > if m_ac31('2',n.acm02,n.acm00,n.acm01, > o[i].acn02 thru o[i].acn15) then > display "m_ac31 error ",o[i].acn02 at 21,1 > sleep 5 > return 1 > end if > .................. > end function > > statements in my function > > m_ac31() > ............... > if status or sqlca.sqlerrd[3]<1 then > display "Upd ac31 err-",status > sleep 5 > return 1 > end if > ...... > > > My problem is that I 'sometimes ' found that the m_ac31 > function was performed successfully (because there is no error message > displayed ) > but the results comed out wrong ; which means there were error > during the function was called but my main program did not catch the > return value .Could any one tell me where the problem is ? > > My Informix was old SE. I do not know what is the problem in my > program. Since you don't specify what you mean when you say the results are wrong, I'm just guessing at where to start. Was data changed that shouldn't have been? Was data skipped? Were one or more unexpected records changed? Were one or more expected records missed while others were selected? Simply saying the results are "wrong" leaves a whole lot of possibilities. Without knowing exactly what "wrong" means, my first suggestion would be to change the error checking in m_ac31. I would check SQLCA.SQLCODE rather than STATUS - or check both. The STATUS variable will indicate errors from both the form and from SQL statements whereas SQLCA.SQLCODE indicates errors (or success) of just the SQL statements. Since you only show the error checking, we can't be sure what comes before it in your code; I'd be more comfortable checking the SQLCA record. I would also be inclined to evaluate SQLCA.SQLERRD[3] against a known value. For example, I would find out how many records I expect to process, and would compare SQLCA.SQLERRD[3] against that value rather than zero. Is it possible that the problem isn't that no records were processed but rather more records than you were expecting were processed? With these changes, at least you'd be sure you were checking the results of the last SQL statement and that you were processing as many records as you were expecting. Note that this doesn't necessarily mean the correct records were processed, but at least the actual number of records can be determined. -- June Hunt