Thread: Conversion from Sybase ASA

Conversion from Sybase ASA

From
"Richard Sydney-Smith"
Date:
In sybase I can use the following syntax:
 

select 'T' as src,(if tbon is null or tbon < '1900/12/12' or tbon > '1900/9/30' then 'U' else 'P' endif) as pres from ftrans

this returns two columns: src = 'T' and pres which has either the value 'U' or 'P'

how would I express this in postgresql?

thanks

Richard

Re: Conversion from Sybase ASA

From
"Viorel Dragomir"
Date:
select 'T' as src,(if tbon is null or tbon < '1900/12/12' or tbon > '1900/9/30' then 'U' else 'P' endif) as pres from ftrans
 
select 'T' as src,(CASE WHEN tbon is null or tbon < '1900/12/12' or tbon > '1900/9/30' THEN  'U' ELSE  'P' END) as pres from ftrans
 
I think it works in Oracle too :)
Pay attention at tbon < '1900/12/12'. Try to use conversion on date formats like to_date() or to_timestamp().
 
Good luck
----- Original Message -----
Sent: Tuesday, September 09, 2003 10:06 AM
Subject: [SQL] Conversion from Sybase ASA

In sybase I can use the following syntax:
 

select 'T' as src,(if tbon is null or tbon < '1900/12/12' or tbon > '1900/9/30' then 'U' else 'P' endif) as pres from ftrans

this returns two columns: src = 'T' and pres which has either the value 'U' or 'P'

how would I express this in postgresql?

thanks

Richard

Re: Conversion from Sybase ASA

From
Ian Barwick
Date:
On Tuesday 09 September 2003 09:06, Richard Sydney-Smith wrote:
> In sybase I can use the following syntax:
>
> select 'T' as src,(if tbon is null or tbon < '1900/12/12' or tbon >
> '1900/9/30' then 'U' else 'P' endif) as pres from ftrans
>
> this returns two columns: src = 'T' and pres which has either the value 'U'
> or 'P'
>
> how would I express this in postgresql?

"CASE":

http://www.postgresql.org/docs/7.3/static/functions-conditional.html

Ian Barwick
barwick@gmx.net