BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

sql translation pls.

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
tony
Guest





PostPosted: Sat Aug 14, 2004 1:18 pm    Post subject: sql translation pls. Reply with quote



I have a SQL in MS Access read as :
select fielda, iif(fieldb=0, fieldc,fieldb)
from tableA

How could I do the same in Oracle? I tried NVL but no luck.

Thanks in advance.


Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Sat Aug 14, 2004 1:43 pm    Post subject: Re: sql translation pls. Reply with quote



tony wrote:
Quote:
I have a SQL in MS Access read as :
select fielda, iif(fieldb=0, fieldc,fieldb)
from tableA

A standard SQL alternative is to use Union, which Oracle should handle:

select fielda, fieldc
from tableA
where fieldb=0
union all
select fielda, fieldb
from tableA
where fieldb<>0

--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
SpaceShipOne; GovernmentZero



Back to top
Eric Hill
Guest





PostPosted: Sun Aug 15, 2004 12:18 am    Post subject: Re: sql translation pls. Reply with quote



If you want to use the "Oracle" way, then...

select fielda, decode(fieldb,0,fieldc,fieldb)
from tableA


Back to top
tony
Guest





PostPosted: Sun Aug 15, 2004 3:43 am    Post subject: how about iif(fielda>0, fielda, fieldb)? Reply with quote

Sorry I am asking for more!
how about iif(fielda>0, fielda, fieldb)?
Thanks



Quote:
If you want to use the "Oracle" way, then...

select fielda, decode(fieldb,0,fieldc,fieldb)
from tableA





Back to top
Eric Hill
Guest





PostPosted: Sun Aug 15, 2004 5:47 am    Post subject: Re: how about iif(fielda>0, fielda, fieldb)? Reply with quote

Quote:
Sorry I am asking for more!
how about iif(fielda>0, fielda, fieldb)?
Thanks

decode(sign(fielda),1,fielda,fieldb)

Eric



Back to top
Dmitry Arefiev [gs-soft.r
Guest





PostPosted: Mon Aug 16, 2004 2:23 pm    Post subject: Re: how about iif(fielda>0, fielda, fieldb)? Reply with quote

And so on ? <g>

If Oracle version is >= 9, then you can use CASE statement.

Quote:
select fielda, iif(fieldb=0, fieldc,fieldb)
from tableA

will be

select fielda, case when fieldb = 0 then fieldc else fieldb end
from tableA

Regards,
Dmitry

--
Dmitry L. Arefiev, gs-soft Company, http://www.gs-soft.com
Personal - http://www.da-soft.com

SAPx - Delphi to SAP R/3 direct access
Saphir - SAP R/3 metadata on your fingertips
MetaBase - ERWIN model in Delphi applications
NCOCI8 - Freeware Delphi to ORACLE direct access



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.