niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle » Tools
SQLPLUS Oracle 8i query
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
Author Message
Jerome Vitalis
*nix forums addict


Joined: 03 Jun 2005
Posts: 58

PostPosted: Fri Jul 21, 2006 12:12 pm    Post subject: Re: SQLPLUS Oracle 8i query Reply with quote

Cris Carampa wrote:

Quote:
select * from tablename
where
country = 'abc' and
(
(region='pqr' and city='xyz')
or
(region!='pqr')
)

That query can be simplified as follows:

select * from tablename where country='abc' and (city='xyz' or
region<>'pqr');
Back to top
Cris Carampa
*nix forums Guru Wannabe


Joined: 06 May 2005
Posts: 122

PostPosted: Thu Jul 20, 2006 8:35 am    Post subject: Re: SQLPLUS Oracle 8i query Reply with quote

vernalGreens@gmail.com wrote:

Quote:
If a user selected pqr from a dropdown on the webpage, only then I want
the city statement to run.

How can I achieve this in SQLPLUS (I think the syntax in the above
query is incorrect). I'm using oracle 8i. Can I use conditional if in
SQLPLUS?

There's still no need for procedural statements here:

select * from tablename
where country='abc'
and
(
('&&1'='pqr' and city='xyz')
or
('&&1'!='pqr')
) ;


--
Cris Carampa (spamto:cris119@operamail.com)
when they kick at your front door | how you gonna come ?
with your hands on your head | or on the trigger of your gun ?
Back to top
vernalGreens@gmail.com
*nix forums beginner


Joined: 20 Jul 2006
Posts: 2

PostPosted: Thu Jul 20, 2006 7:22 am    Post subject: Re: SQLPLUS Oracle 8i query Reply with quote

select * from tablename
where
country = 'abc'
if @userEnteredParameter = 'pqr' then
and city = 'xyz'
end if

If a user selected pqr from a dropdown on the webpage, only then I want
the city statement to run.

How can I achieve this in SQLPLUS (I think the syntax in the above
query is incorrect). I'm using oracle 8i. Can I use conditional if in
SQLPLUS?


Cris Carampa wrote:
Quote:
vernalGreens@gmail.com wrote:

I want to modify the query so that "and city = 'xyz'" run only when
region = pqr.

You can do that with plain SQL, there's no need for procedural
constructs here.

It's not clear what you want to do with rows with region!='pqr'. I
assumed you wish to select all of them. Then:

select * from tablename
where
country = 'abc' and
(
(region='pqr' and city='xyz')
or
(region!='pqr')
)

Kind regards,

--
Cris Carampa (spamto:cris119@operamail.com)
when they kick at your front door | how you gonna come ?
with your hands on your head | or on the trigger of your gun ?
Back to top
Cris Carampa
*nix forums Guru Wannabe


Joined: 06 May 2005
Posts: 122

PostPosted: Thu Jul 20, 2006 7:15 am    Post subject: Re: SQLPLUS Oracle 8i query Reply with quote

vernalGreens@gmail.com wrote:

Quote:
I want to modify the query so that "and city = 'xyz'" run only when
region = pqr.

You can do that with plain SQL, there's no need for procedural
constructs here.

It's not clear what you want to do with rows with region!='pqr'. I
assumed you wish to select all of them. Then:

select * from tablename
where
country = 'abc' and
(
(region='pqr' and city='xyz')
or
(region!='pqr')
)

Kind regards,

--
Cris Carampa (spamto:cris119@operamail.com)
when they kick at your front door | how you gonna come ?
with your hands on your head | or on the trigger of your gun ?
Back to top
vernalGreens@gmail.com
*nix forums beginner


Joined: 20 Jul 2006
Posts: 2

PostPosted: Thu Jul 20, 2006 7:00 am    Post subject: SQLPLUS Oracle 8i query Reply with quote

select * from tablename
where
country = 'abc'
and city = 'xyz'


I want to modify the query so that "and city = 'xyz'" run only when
region = pqr.

select * from tablename
where
country = 'abc'
if region = 'pqr' then
and city = 'xyz'
end if

What's the exact syntax for doing this in SQLPLUS. I'm using oracle 8i.
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
The time now is Fri Nov 21, 2008 8:33 pm | All times are GMT
navigation Forum index » Databases » Oracle » Tools
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Move Oracle 10g database to another location Selt Server 0 Fri Jul 21, 2006 2:14 pm
No new posts Oracle runtime Spitfire Server 0 Fri Jul 21, 2006 1:18 pm
No new posts Very slow query Michael Sutter MySQL 0 Fri Jul 21, 2006 1:10 pm
No new posts Oracle Text Score Computation jatinder.1975@gmail.com Server 0 Fri Jul 21, 2006 1:00 pm
No new posts Can a trigger insert records into another oracle server Tauqir Server 2 Fri Jul 21, 2006 12:27 am

Fast Loans | Credit Counseling | Loans | Bad Credit Mortgages | Homes for Sale
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1833s ][ Queries: 20 (0.1002s) ][ GZIP on - Debug on ]