Subject | Re: decode or case features |
---|---|
Author | skotaylor <scott@dctchambers.com> |
Post date | 2003-01-03T20:31:25Z |
--- In ib-support@yahoogroups.com, "mikeevteev <mikeevteev@y...>"
<mikeevteev@y...> wrote:
features?
Something like:
Create Procedure My_Proc(MyParameter Integer)
Returns ( Store_Number Integer )
As
Declare Variable MyType Integer;
begin
for Select Doc_Type from document
where MyField = :MyParameter
Into :MyType do
begin
If (MyType = 1) then
Store_Number = From_Store;
Else
If (MyType = 2) then
Store_Number = To_Store;
end
Suspend;
end
Then just call it with:
Select * from My_Proc('SomeParameter')
Nice thing about using a SP, if you ever add another type in this
situaltion, you only have to change one thing, not a bunch of queries.
HTH
Scott.
<mikeevteev@y...> wrote:
> Hi all!features?
>
> Is there any way to emulate oracle decode or sql server case
>Any reason you couldn't use a Stored Procedure's If Then Else
> I need output different values based on other field. Someting like
> that
>
> select
> decode(doc_type, 1, from_store, 2, to_store) store_number
> from document
features?
Something like:
Create Procedure My_Proc(MyParameter Integer)
Returns ( Store_Number Integer )
As
Declare Variable MyType Integer;
begin
for Select Doc_Type from document
where MyField = :MyParameter
Into :MyType do
begin
If (MyType = 1) then
Store_Number = From_Store;
Else
If (MyType = 2) then
Store_Number = To_Store;
end
Suspend;
end
Then just call it with:
Select * from My_Proc('SomeParameter')
Nice thing about using a SP, if you ever add another type in this
situaltion, you only have to change one thing, not a bunch of queries.
HTH
Scott.