Subject | Re: Optional parameter in a select statement |
---|---|
Author | Adam |
Post date | 2005-08-25T23:57:57Z |
> >Um, that is a very round about way of achieving
> > Does anybody knows if the FB has anything like:
> >
> > declare variable command varchar(1000);
> > select 'select * from TABLE' from RDB$DATABASE into :command;
> > execute(command);
>
command = 'select * from table';
but anyway, once you have set the value into command, you can use it
inside a for select do construct. Check the FB 1.5(.0) release notes.
It has an example of how to achieve this.
If you are using a stored procedure, and you want to do it this way,
you could simply do a test
if (:User = -1) then
begin
command = :command || ' where User = ' || :User;
end
etc
But I don't think the plan can be stored for dynamicly created queries
like this, which may or may not be an issue.
Adam