Subject Re: [firebird-support] Re: Optional parameter in a select statement
Author Mitch@home
m_formigoni wrote:

>;
>
>
>>>select 'select * from TABLE' from RDB$DATABASE into :command;
>>>execute(command);
>>>
>>>
>>Are you going to use it inside stored procedure ?
>>
>>
>
>Yes, inside a SP.. Is there a way?
>
>
yes

create procedure Test
returns ( SomeVal int) as
declare variable command varchr(500);
begin
command='Select AValue from Atable';
for execute statement command
into :SomeVal Do
begin
suspend;
end
end

actually, there is not necessarily a need to store the SQL in the
variable, you could write it/build it directly in the execute statement
like....

create procedure Test2 (FieldName varchar(31))
returns ( SomeVal int) as
begin
for execute statement 'Select ' || :FieldName || ' from Atable'
into :SomeVal Do
begin
suspend;
end
end




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