WHENEVER ANY ERROR
Posted in 1997
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL
We are changing some 4GL programs to use WHENEVER ERROR to
WHENEVER ANY ERROR. We have gotten some strange results.
When we do a query if you do a previous or next and there are no more rows
before or after the status should equal not found and a message should be
displayed. This was working fine with WHENEVER ERROR CALL err_trap
(err_trap is a function for capturing the errors), but when we changed the
code to WHENEVER ANY ERROR CALL err_trap the messages "There are no more
rows in this direction" were no longer displayed.
Has any one else had a problem with WHENEVER ANY ERROR?
Also when we compile the program (c4gl -c prog_name.4gl) we are getting
the following warning message:
prog_name.ec, line 524: warning: statement is unreachable
break;}} while(0);
If you have any input just e-mail me at jojean@aol.com.
This is what some of the code looks like.
main
defer interrupt
whenever any error call err_trap
call startlog("prog.log")
menu "CODE"
command "Query"
call query()
next option "Query"
command "Next"
call next_prev(1,0,1)
next option "Next"
command "Previous"
call next_prev(2,0,1)
next option "Previous"
comand "Exit"
exit menu
end menu
end main
function query()
:
:
fetch first ...
call next_prev(3,0,1)
end function
function next_prev(flag,flag2,first_time)
define flag,flag2,first_time smallint
if num < 1 then
message "There are no rows in the current list; use the Query
selection."
return
else
let done = false
while not done
case
when flag = 1
message " "
if first_time then
fetch next cursor_set into ...
else
fetch first cursor_set into ...
end if
exit case
when flag = 2
message " "
if first_time then
fetch prior cursor_set into ...
else
fetch last cursor_set into ...
end if
exit case
when flag = 3
exit case
otherwise
return
exit case
end case
let first_time = 1
if status = 100 then
if flag1 <> 1 then
case
when flag = 1
call next_prev(2,1,0)
exit case
when flag = 2
call next_prev(1,1,0)
exit case
otherwise
return
exit case
end case
message "There are no more rows in this
direction."
let done = true
else
let num = 0
message "There are no rows in the current
list; use the Query
selection."
let done = true
return
end if
else
select ...
if status = 100 then
let done = false
else
display ...
let done = true
end if
end if
let first_time = 1
end while
end if
end function