Re: Stored Procedures
Posted in 1999
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration, Migration, Import/Export & Data Conversion
I suppose the first question reffers to 4gl too.
You can't unload the results of stored procedures like this.
Although... try storing the execute statement in a string:
LET v_string = "execute procedure my_proc"
unload to 'xx' v_string
I think it works!
To call a sp in a 4gl program you have to prepare the
statement and then execute it. If procedure returns some
values you'll have to declare a cursor over prepared
statement and open - fetch(or foreach) - close it.
Hope this helps,
Octav
On Wed, Aug 25, 1999 at 11:34:44AM +0300, Olcay Sarioglu wrote:
>
> I have two questions:
>
> 1) How can I unload the results of a stored procedure within the
> dbaccess? I tried
> unload to "xx"
> execute procedure my_proc()
> and
> execute procedure my_proc()
> into temp yy
> But it did not worked!>
> 2) How can I call a stored procedure within a 4gl program? I tried t
> call it like functions but it is of no use.
>
> == Olcay Sarioglu
> == olcays@metu.edu.tr http://staff.metu.edu.tr/bidb/olcays/
> == Computer Center, Middle East Tech.Univ. Ankara TURKIYE
> == Voice: +90 312 2103381 Fax: +90 312 2101120
>
--
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 wrote:
>
> I suppose the first question reffers to 4gl too.
>
> You can't unload the results of stored procedures like this.
> Although... try storing the execute statement in a string:
>
> LET v_string = "execute procedure my_proc"
> unload to 'xx' v_string>
> I think it works!
The syntax is valid. The only reason it might fail (I haven't tested)
is because the code in UNLOAD checks that the statement actually is a
SELECT rather than something else (and, in this case, an EXECUTE
PROCEDURE statement).
Interesting thought - it probably works.
With SQLCMD as currently available, you couldn't use the UNLOAD
statement, but you could achieve the same result with:
format unload;
output 'xx';
execute procedure my_proc(); output '/dev/stdout';
You might even be able to push the output file, start the new one,
and pop the old one -- I can't immediately remember. I'll add the
ability to handle EXECUTE PROCEDURE too; it is obviously something
that should be supported, once it has been pointed out...
> To call a sp in a 4gl program you have to prepare the
> statement and then execute it. If procedure returns some
> values you'll have to declare a cursor over prepared
> statement and open - fetch(or foreach) - close it.
Correct. Or, in 7.30, you can use:
SQL
EXECUTE PROCEDURE whatever($val1)
END SQL
Or:
DECLARE c_sp CURSOR FOR
SQL
EXEC PROCEDURE somethingelse($val2)
END SQL
Followed by a FOREACH loop as before.
> Hope this helps,
> Octav
>
> On Wed, Aug 25, 1999 at 11:34:44AM +0300, Olcay Sarioglu wrote:
> >
> > I have two questions:
> >
> > 1) How can I unload the results of a stored procedure within the
> > dbaccess? I tried
> > unload to "xx"
> > execute procedure my_proc()
> > and
> > execute procedure my_proc()
> > into temp yy
> > But it did not worked!> >
> > 2) How can I call a stored procedure within a 4gl program? I tried t
> > call it like functions but it is of no use.
> >
> > == Olcay Sarioglu
> > == olcays@metu.edu.tr http://staff.metu.edu.tr/bidb/olcays/
> > == Computer Center, Middle East Tech.Univ. Ankara TURKIYE
> > == Voice: +90 312 2103381 Fax: +90 312 2101120
> >
>
> --
> 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
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN
#include <disclaimer.h>