|Subject||Re: Optional parameter in a select statement|
> >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
command = :command || ' where User = ' || :User;
But I don't think the plan can be stored for dynamicly created queries
like this, which may or may not be an issue.