Subject | Re: Can I use a Stored Procedure like a UDF in a Select? |
---|---|
Author | volklp30_nz |
Post date | 2004-02-24T20:16:58Z |
Thanks for that Thomas.
I agree with your comments about the relevance of this example, I
just wanted to 'keep it simple' to focus on my issue which was the
call semantics in a select, which you answered most kindly :)
Regards,
Jono.
--- In firebird-support@yahoogroups.com, "Thomas Steinmaurer"
<ts@i...> wrote:
I agree with your comments about the relevance of this example, I
just wanted to 'keep it simple' to focus on my issue which was the
call semantics in a select, which you answered most kindly :)
Regards,
Jono.
--- In firebird-support@yahoogroups.com, "Thomas Steinmaurer"
<ts@i...> wrote:
> > Does anyone know if it is possible to use in Firebird a storedfrom
> > procedure like a UDF?
> >
> > For example, suppose I have defined a stored procedure like :
> >
> > create procedure concat (param1 varchar(50), param2 varchar(50))
> > returns (output_string varchar(100))
> > as
> > begin
> > for select (:param1 || :param2) from rdb$database
> > into :output_string do suspend;
> > end ^
>
> Try:
>
> create procedure concat (param1 varchar(50), param2 varchar(50))
> returns (output_string varchar(100))
> as
> begin
> output_string = param1 || param2;
> suspend;
> end
>
>
> > I would like to be able to call it in a way similar to :
> >
> > select concat(contact.firstname, contact.surname) contact_name
> > contact;Select".
> >
> > Any ideas? Thanks for your time in advance.
>
> The call of the stored procedure has to be within an "Inline-
>contact_name
> For example:
>
> select
> (select output_string from concat (c.firstname, a.surname)) as
> fromsimple
> contact c
>
>
> Btw, in your case, you don't need a stored procedure for that. A
>if e.g.
> select
> (c.firstname || c.surname) as contact_name
> from
> contact c
>
>
> will do the job as well. A stored procedure might make more sense,
> one of the parameters can be null, because you can put the logicinto the
> stored procedure to check, whether a parameter is null or not. Ifit is
> null, then you should assign an empty string, otherwise theconcatenation
> will result in null as well.neither,
>
> If you are using Firebird 1.5, then you don't need that check
> because you can use COALESCE(...).
>
>
> HTH,
> Thomas Steinmaurer
> LogManager Serie - Logging/Auditing Suites supporting
> InterBase, Firebird, Advantage Database and MS SQL Server
> Upscene Productions
> http://www.upscene.com