Help! Stored procedures in Informix
Posted in 1995
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration
Hello,
I'm having boatloads of trouble trying to get Informix 5 stored procedures
to work with PowerBuilder 4.
I'm working with a rather large database, and I need to be able to
query the database with a few variables, and get a single-line result. This
seems conceptually straightforward to me, and I can solve the problem in
Informix 4GL with cursors and such.
Instead of using 4GL as a back-end for Powerbuilder, though, I was
hoping that PB could perform the data manipulation by itself. I've
created a stored procedure in SQL (using DBAccess) that performs the
necessary computations, and it works fine (in DBAccess). I then created
a custom user object inherited from the standard class transaction object,
and added an external local function that would call the stored procedure.
This did not work. For some reason, PB would create syntax that called the
procedure as a subroutine, not a function; changing the syntax manually did
not help.
Of note, I've always been able to execute the procedure WITH NO ARGUMENTS;
but, of course, this does not help me as PB merely returns random integers.
In the Building Applications manual, Chap. 9, it states that any DBMS can
be used if you do NOT return a result set. I was not sure if a single line
counted as a result set, but in case it did, I figured I'd try the
alternative method of Declaring a Procedure.
I made a little Command Button to execute my script, and I tried to
Declare Global Variable - Procedure, and I tried the Paste SQL button for
a local procedure; but neither of these work. PB can connect to the
database, and it sees the stored procedure and all, but it generates this
kind of script:
DECLARE please_work PROCEDURE FOR informix.add_num ;
I can't seem to add anything between the "add_num" and the ";" - doing so
gets me SQL Error -201, general syntax error. So, I can't supply the
"@parameter = :value" as needed.
So now, I'm afraid I am stuck. If it helps, my test stored procedure is:
create procedure add_num (uno int, dos int)
returning int; define tres int;
let tres = uno + dos;
return tres;
(This isn't the real SP, of course, but I was hoping that this would
work because of it's simplicity.)
Can anybody see what I am doing wrong? I have a sinking feeling that
maybe Informix does not support result sets, because the PB manual goes
quite in depth with just about every other database (Oracle, Sybase,
etc.) on this subject, talking about IN and OUT and INOUT parameters.
But then, what exactly does the "returning int" part of my SP do, and why
does it work in DBAccess?
I confess that this is my first real venture into stored procedures, so
I'm kinda hoping that it's a newbie thing I'm missing. Please help,
Edwin Park
parke@haven.ios.com