Subject Re: [IBO] RETURNING clause in Fb 2.1, how should it work?
Author Martijn Tonies
Hi Jason,

> > I'm trying the following:
> > INSERT INTO CUSTOMERS
> > (
> > COMPANY_NAME,
> > CONTACT_FIRSTNAME,
> > CONTACT_LASTNAME,
> > CONTACT_MIDDLENAME
> > )
> > VALUES
> > (
> > '' /*COMPANY_NAME*/,
> > '' /*CONTACT_FIRSTNAME*/,
> > '' /*CONTACT_LASTNAME*/,
> > '' /*CONTACT_MIDDLENAME*/
> > )
> > returning custid
> >
> > where CUSTID is being filled by a BEFORE INSERT trigger. When I run
> > this statement (prepare, then run), IBO returns a "parameter"
> > for "custid".
>
> I'm guessing that you are using a TIBOQuery?
> (Please remember to always specify which component.)

Yes, unless I specify otherwise? :-)

> > Isn't it supposed to return a resultset with a single row?
>
> Only if the statement prepared actually is a SELECT statement.
>
> > For "statement type", IBO returns "ExecProcedure".
>
> This most likely comes from the server as I read the statement type from
> what the API returns.
>
> You should notice that the parameter is of type ptOutput.
>
> In native IBO you would get this in the Fields array instead of the Params
> because I don't have the distinction of parameters for output.

Right, it seems I'm not handling this properly, thanks.

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com