Subject | Re: [firebird-support] SP problem |
---|---|
Author | Martijn Tonies |
Post date | 2007-10-10T11:39:22Z |
Hello Werner,
stored procedure, you're not getting NULL, but rather not
getting any resultset (<- note "resultset", not "null value for
the trans_value column").
To transform a stored procedure into a select-able one, you
need to put a SUSPEND somewhere. SUSPEND means
the server will send the output variables to the client and
stall the execution of the procedure until the client asks for a
new row of data.
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
> When I do this:I don't know what tool you're using, but from reading your
>
> execute procedure t('some text dd', 'wbruhin');
>
> I get the expected result pack, but if I do this:
>
> select trans_value from T('some text dd', 'wbruhin');
>
> I get Null back for trans_value.
stored procedure, you're not getting NULL, but rather not
getting any resultset (<- note "resultset", not "null value for
the trans_value column").
To transform a stored procedure into a select-able one, you
need to put a SUSPEND somewhere. SUSPEND means
the server will send the output variables to the client and
stall the execution of the procedure until the client asks for a
new row of data.
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
>
> I must be doing something wrong, but it does not jump at me.
>
> Any hints would be very much appreciated.
> Werner
>
> The SP is:
> CREATE PROCEDURE T (
> orig_value varchar(256),
> user_name varchar(20))
> returns (
> trans_value varchar(256))
> as
> declare variable user_lang varchar(5) character set utf8;
> begin
> /* Procedure Text */
> user_lang = null;
> trans_value = null;
> select lang from i18n_currlang where i18n_currlang.user_name =
> :user_name into :user_lang;
> if (user_lang is not null) then
> begin
> select trans from i18n_trans where i18n_trans.lang = :user_lang
> and i18n_trans.orig = :orig_value into :trans_value;
> if (:trans_value is null) then
> trans_value = :orig_value;
> end
> else
> begin
> trans_value = :orig_value;
> end
> end