sql error
Posted in 1996
I have compiled the following 4gl program successfully, but get a syntax
error on line 37 (Error -201). I have tried everything to find out where
the error is coming from, even commenting-out line 74, but without
success.
part.4gl:
main
define v_osadbname char(512),
v_err_code integer
let v_osadbname = fgl_getenv("OSADBNAME") clipped
database v_osadbname
call Partition_Data() returning v_err_code
exit program v_err_code
end main
function Partition_Data()
define v_dcs_date,
v_dcs_status,
v_content_id,
v_confirmed,
v_meta_status,
v_metaed integer,
v_status smallint,
v_maturity,
v_ics_status char(8),
v_brn char(19)
declare ics_cur cursor for
select brn, bgc_content_id, confirmed, status, maturity
into v_brn, v_content_id, v_confirmed, v_ics_status, v_maturity
from ics
if status != 0 then
call Db_Error(status)
return -1
end if
foreach ics_cur
let v_metaed = 0
if v_content_id > 0 then
select status
into v_meta_status
from bgc_content
where content_id = v_content_id
if status != 0 then
call Db_Error(status)
return -1
end if
let v_meta_status = v_meta_status MOD 65535
if v_meta_status = 1073 or v_meta_status = 1059 then
let v_metaed = 1
end if
end if
if v_metaed = 1 and (v_confirmed = 0 or v_confirmed = 2 or
v_confirmed = 8 or v_confirmed = 10) then
let v_confirmed = v_confirmed + 1
end if
if v_ics_status = 'GEAGEND' and v_confirmed < 8 then
let v_confirmed = v_confirmed + 8
end if
select proc_date, status
into v_dcs_date, v_dcs_status
from dcs
where brn = v_brn
let v_status = status
if v_status = 0 then
# There is a match between ics and dcs
if v_confirmed = 0 or v_confirmed = 1 or v_confirmed = 8 or
v_confirmed = 9 then
let v_confirmed = v_confirmed + 2
end if
if v_confirmed = 11 then
let v_dcs_status = 2
let v_dcs_date = v_maturity
else
if v_confirmed = 3 then
let v_dcs_status = 1
end if
end if
update dcs
set status = v_dcs_status, proc_date = v_dcs_date, reserve = 0
where brn = v_brn
if status != 0 then
call Db_Error(status)
return -1
end if
else
if v_status != notfound then
call Db_Error(v_status)
return -1
end if
end if
update ics
set confimed = v_confirmed, reserved = 0
where current of ics_cur
if status != 0 then
call Db_Error(status)
return -1
end if
end foreach
update dcs
set reserved = 0
where reservec != 0 or reserved is null
if status != 0 then
call Db_Error(status)
return -1
end if
return 0
end function
function Db_Error(v_err_code)
define v_err_code integer,
v_err_message char(512)
let v_err_message = err_get(v_err_code) clipped
call Db_Error_Log(v_err_message)
end function
function Db_Error_Log(v_err_message)
define v_err_message,
v_log_file char(512)
let v_log_file = fgl_getenv("OSADIR") clipped, "/Tmp/daily",
today using "yymmdd", ".log"
call startlog(v_log_file)
call errorlog(v_err_message)
end function