Re: calling stored procedures from 4GL
Posted in 1997
Ed Schaefer wrote:
>
> 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, '*';
--------------------------------------
Ed,
This is your error line above.
The concatenation operator in SPL is not the same as 4GL.
Use let buf_pattern = '*' || pattern || '*';
In SPL (unlike 4GL) you can do things like let a, b = 1, 2;
Peter
--------------------------------------
> 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';
--
Peter Lancashire
Information Systems Specialist, Bayer plc
Eastern Way, Bury St Edmunds, Suffolk, IP32 7AH, UK
Tel: +44-1635-562258, Fax: +44-1635-562281
Mail: Peter.Lancashire.PL1@bayer.co.uk
My Internet plumbing does not allow me to mail and post news together.
Sorry.
All opinions are my own and not those of Bayer plc.