Subject Re: [firebird-support] Convert varchar argument to an integer array
Author Gustavo Tonini
Helen Borrie <helebor@...> escreveu: At 03:02 AM 31/08/2007, you wrote:
>Hello,
>I have a function which have a varchar argument. Inside this functions
>I need to convert this argument (formatted by "(1,2,3)") to an integer
>array for use the IN operator.
>How can I make this on firebird?

You had best explain how you want to use it. Firebird does not
support writing "functions" in SQL. You *can* write external
functions (also known as user-defined functions, or UDFs) in C, C++,
Pascal or some other C-compatible language. However, a Firebird
ARRAY type is not compatible either with a C vector nor the list that
forms the argument for the IN() operator.
I'm using a SP. I used wrong "name" function. I'm accustomed with PostgreSQL vocabulary...


The usual way to achieve what you want is by writing a selectable
stored procedure that takes a varchar input and returns the desired
set. The output set is defined by the RETURNS() clause of the
procedure's declaration.

Your SSP could simply accept your input string and concatenate it
into the desired sentence, before running a FOR EXECUTE STATEMENT
('your sentence'...INTO..<declared output variables> DO SUSPEND
construct. Consult the v.1.5 release notes for detailed syntax of
EXECUTE STATEMENT.

Ok. FOR EXECUTE STATEMENT solved my problem.



Thanks,
Gustavo.






Flickr agora em português. Você clica, todo mundo vê. Saiba mais.

[Non-text portions of this message have been removed]