Subject | Re: [firebird-support] change field depending variables |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2006-12-20T11:03:37Z |
Martijn Tonies wrote:
SELECT CASE
WHEN :QUESTION = 'Y' THEN Field1
WHEN :QUESTION = 'N' THEN Field2
ELSE NULL
END as MyField
from Table_a where Field2 = '1' into :answer
I just thought EXECUTE STATEMENT ought to be avoided when possible.
HTH,
Set
> Hi,why not something like
>
>> Pseudo code:
>>
>> declare field varchar( 20 );
>>
>> if ( :question = 'y' ) then field='Field1';
>> if ( :question = 'n' ) then field='Field2';
>>
>> select :field from Table_a where Field2 = '1' into :answer.
>>
>> Please can anyone tell me how to do this???
>
> Take a look at EXECUTE STATEMENT in the Firebird
> 1.5 release notes.
SELECT CASE
WHEN :QUESTION = 'Y' THEN Field1
WHEN :QUESTION = 'N' THEN Field2
ELSE NULL
END as MyField
from Table_a where Field2 = '1' into :answer
I just thought EXECUTE STATEMENT ought to be avoided when possible.
HTH,
Set