Re: Return values ???
Posted in 1999
--------------0ABFB90FCA1CB3D8D60F7EDD
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Below is the listing of my procedure and my 4gl module ... Hope u can find out
what's wrong with it ??? thanx ...
My Procedure
create procedure abc (p_scn char(4))
returning int ;
define p_rows integer ;
select count(*) into p_rows from man_hdr
where scn matches p_scn ;
return p_rows ;
end procedure ;
My 4gl module
database mandev
main
define l_dummy char(4), l_row integer
declare csr_sql cursor for "execute procedure abc (?)"
|________________________________________________________^
|
| A grammatical error has been found on line 6, character 58.
| The construct is not understandable in its context.
| See error number -4373.
open csr_sql using l_dummy
fetch csr_sql into l_row
close csr_sql
display l_row
end main
Octav Chiriac wrote:
> Could you post the 4gl .err file fragment with the
> indication of what is wrong.
>
> On Mon, Aug 09, 1999 at 04:56:58PM +0800, Wu wrote:
> > With this way, I have compilation error -4373 ...
> >
> > Octav Chiriac wrote:
> >
> > > DECLARE qCursorName CURSOR FOR "EXECUTE PROCEDURE theprocedure(?,?)"
> > >
> > > OPEN qCursorName USING var1, var2
> > >
> > > WHILE TRUE
> > > FETCH qCursorName INTO result1, result2
> > > IF sqlca.sqlcode == NOTFOUND THEN
> > > EXIT WHILE
> > > END IF
> > >
> > > -- DO SOMETHING WITH YOUR results
> > >
> > > END WHILE
> > >
> > > CLOSE qCursorName
> > >
> > > FREE ... stuff
> > >
> > > Of course if you know the procedure will return only one result set
> > > you can exclude the while loop and use just one FETCH.
> > >
> > > And to return more than one result set your procedure should
> > > return values WITH RESUME.
> > >
> > > Hope this helps,
> > > Octav
> > >
> > > On Mon, Aug 09, 1999 at 04:07:53PM +0800, Wu wrote:
> > > > How to accept the return values from a stored procedure in i4gl module ?
> > > > Appreciate if example is given. thanx.
> > > >
> > > >
> > >
> > > --
> > > Octav Chiriac Phone: (373) 2 22 99 67
> > > NetInfo S.R.L. Fax: (373) 2 21 36 59
> > > Chisinau (373) 2 22 84 88
> > > Moldova, Republic of mailto:com@netinfo-moldova.com
> >
>
> --
> Octav Chiriac Phone: (373) 2 22 99 67
> NetInfo S.R.L. Fax: (373) 2 21 36 59
> Chisinau (373) 2 22 84 88
> Moldova, Republic of mailto:com@netinfo-moldova.com
--------------0ABFB90FCA1CB3D8D60F7EDD
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<tt>Below is the listing of my procedure and my 4gl module ... Hope u can
find out what's wrong with it ??? thanx ...</tt><tt></tt>
<p><b><tt><u>My Procedure</u></tt></b>
<br><tt>create procedure abc (p_scn char(4))</tt>
<br><tt> returning int ;</tt>
<p><tt> define p_rows integer ;</tt>
<p><tt> select count(*) into p_rows from man_hdr</tt>
<br><tt> where scn matches p_scn ;</tt>
<p><tt> return p_rows ;</tt>
<br><tt>end procedure ;</tt>
<p><b><tt><u>My 4gl module</u></tt></b>
<br><tt>database mandev</tt>
<p><tt>main</tt>
<br><tt> define l_dummy char(4), l_row integer</tt>
<p><tt> declare csr_sql cursor for "execute procedure abc (?)"</tt>
<br><tt>|________________________________________________________^</tt>
<br><tt>|</tt>
<br><tt>| A grammatical error has been found
on line 6, character 58.</tt>
<br><tt>| The construct is not understandable in its context.</tt>
<br><tt>| See error number -4373.</tt>
<br><tt> open csr_sql using l_dummy</tt>
<br><tt> fetch csr_sql into l_row</tt>
<br><tt> close csr_sql</tt>
<p><tt> display l_row</tt>
<br><tt>end main</tt>
<br>
<p>Octav Chiriac wrote:
<blockquote TYPE=CITE>Could you post the 4gl .err file fragment with the
<br>indication of what is wrong.
<p>On Mon, Aug 09, 1999 at 04:56:58PM +0800, Wu wrote:
<br>> With this way, I have compilation error -4373 ...
<br>>
<br>> Octav Chiriac wrote:
<br>>
<br>> > DECLARE qCursorName CURSOR FOR "EXECUTE PROCEDURE theprocedure(?,?)"
<br>> >
<br>> > OPEN qCursorName USING var1, var2
<br>> >
<br>> > WHILE TRUE
<br>> > FETCH qCursorName INTO result1, result2
<br>> > IF sqlca.sqlcode == NOTFOUND THEN
<br>> > EXIT WHILE
<br>> > END IF
<br>> >
<br>> > -- DO SOMETHING WITH YOUR results
<br>> >
<br>> > END WHILE
<br>> >
<br>> > CLOSE qCursorName
<br>> >
<br>> > FREE ... stuff
<br>> >
<br>> > Of course if you know the procedure will return only one
result set
<br>> > you can exclude the while loop and use just one FETCH.
<br>> >
<br>> > And to return more than one result set your procedure should
<br>> > return values WITH RESUME.
<br>> >
<br>> > Hope this helps,
<br>> > Octav
<br>> >
<br>> > On Mon, Aug 09, 1999 at 04:07:53PM +0800, Wu wrote:
<br>> > > How to accept the return values from a stored procedure in i4gl
module ?
<br>> > > Appreciate if example is given. thanx.
<br>> > >
<br>> > >
<br>> >
<br>> > --
<br>> > Octav Chiriac
Phone: (373) 2 22 99 67
<br>> > NetInfo S.R.L.
Fax: (373) 2 21 36 59
<br>> > Chisinau
(373) 2 22 84 88
<br>> > Moldova, Republic of
<a href="mailto:com@netinfo-moldova.com">mailto:com@netinfo-moldova.com</a>
<br>>
<p>--
<br>Octav Chiriac
Phone: (373) 2 22 99 67
<br>NetInfo S.R.L.
Fax: (373) 2 21 36 59
<br>Chisinau
(373) 2 22 84 88@@NL