calling stored procedures from 4GL
Posted in 1997
Greetings:
Given:
Unix: SCO
Engine: 7.23 Online
4GL: 6.04
I'm new to stored procedures and I'm trying to call a Stored Procedure
from
a 4GL program. I'm trying to call a stored procedure, sp_in_string,
which
checks if a substring is a string. Here's the 4GL stub:
database "testdb"
main
define x integer,
pattern char(20),
src char(80),
s1 char(80)
let s1 = "execute procedure sp_in_string (?, ?)"
prepare stmt_s3 FROM s1
declare proc_ptr cursor for stmt_s3
let pattern = "MM"
let src = "Its inMM here"
open proc_ptr using pattern, src
while true
fetch proc_ptr into x
if sqlca.sqlcode != 0
then
exit while
end if
end while
end main # End program
The problem is I'm getting a runtime syntax error: 661
The number of variables on the left side of a LET statement does not
match the number of values on the right side.
CAN ANYONE POINT OUT MY ERROR? Thanks!
Here's the Stored Procedure. syntax appears correct:
create procedure sp_in_string(pattern char(50), source_string
char(512))
returning int;define pat_len, source_len, i smallint;
define buf_pattern char(50);
let pat_len = length(pattern);
if pat_len = 0
then
return 1;
end if
let buf_pattern = '*', pattern, '*';
if buf_pattern matches source_string
then
return 1;
end if
return 0;
end procedure -- sp_inst
document
'return true if pattern within source_string';