pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedUsing Control Flow Functions in a SELECT Statement
6+ messages / 4 participants
[nested] [flat]
* Using Control Flow Functions in a SELECT Statement
@ 2006-12-04 16:21 Ashish Ahlawat <ahlawat.ashish@gmail.com>
0 siblings, 2 replies; 6+ messages in thread
From: Ashish Ahlawat @ 2006-12-04 16:21 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Ken Johanson <pg-user@kensystem.com>; Martijn van Oosterhout <kleptog@svana.org>; pgsql-sql
Hi Team
I am unable to fetch data using following simple query it prompts following
error
*ORA: 00907: Missing right parenthesis*
Query :-
SELECT Name AS Title, StatID AS Status, RatingID AS Rating,
IF(NumDisks>1, 'Check for extra disks!', 'Only 1 disk.') AS Verify
FROM DVDs
*Table Structure :-*
CREATE TABLE DVDs (
Name VARCHAR(60) NOT NULL,
NumDisks INT NOT NULL ,
RatingID VARCHAR(4) NOT NULL,
StatID CHAR(3) NOT NULL
)
rows has been inserted with different numdisks numbers. pls help
warm R's
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Using Control Flow Functions in a SELECT Statement
@ 2006-12-04 16:30 Richard Broersma Jr <rabroersma@yahoo.com>
parent: Ashish Ahlawat <ahlawat.ashish@gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Richard Broersma Jr @ 2006-12-04 16:30 UTC (permalink / raw)
To: Ashish Ahlawat <ahlawat.ashish@gmail.com>; +Cc: pgsql-sql
> *ORA: 00907: Missing right parenthesis*
> Query :-
> SELECT Name AS Title, StatID AS Status, RatingID AS Rating,
> IF(NumDisks>1, 'Check for extra disks!', 'Only 1 disk.') AS Verify
What kind of error is ORA? Is this an oracle error?
In postgresql I do not believe that the "IF" predicate exists. However the "CASE" predicate does
and will do what you want.
http://www.postgresql.org/files/documentation/books/aw_pgsql/node44.html
Regards,
Richard Broersma Jr.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Using Control Flow Functions in a SELECT Statement
@ 2006-12-04 16:32 Bricklen Anderson <banderson@presinet.com>
parent: Ashish Ahlawat <ahlawat.ashish@gmail.com>
1 sibling, 1 reply; 6+ messages in thread
From: Bricklen Anderson @ 2006-12-04 16:32 UTC (permalink / raw)
To: Ashish Ahlawat <ahlawat.ashish@gmail.com>; +Cc: pgsql-sql
Ashish Ahlawat wrote:
>
> Hi Team
>
> I am unable to fetch data using following simple query it prompts
> following error
>
> *ORA: 00907: Missing right parenthesis*
>
> Query :-
>
> SELECT
>
> Name AS Title, StatID AS Status, RatingID AS Rating,
>
> IF(NumDisks>1, 'Check for extra disks!', 'Only 1 disk.') AS Verify
>
i. That's an Oracle error message.
ii. IF does not belong in an SQL query. Use CASE.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Using Control Flow Functions in a SELECT Statement
@ 2006-12-04 16:42 Ashish Ahlawat <ahlawat.ashish@gmail.com>
parent: Bricklen Anderson <banderson@presinet.com>
0 siblings, 2 replies; 6+ messages in thread
From: Ashish Ahlawat @ 2006-12-04 16:42 UTC (permalink / raw)
To: Bricklen Anderson <banderson@presinet.com>; +Cc: Bruce Momjian <bruce@momjian.us>; Ken Johanson <pg-user@kensystem.com>; Martijn van Oosterhout <kleptog@svana.org>; pgsql-sql; pgsql-sql-owner@postgresql.org; tgl@sss.pgh.pa.us
Hi Team
Thanks FOR your prompt response....But USING CASE issue still NOT resolved
....Oracle prompts same error.
Team its a simple query but really instresting one...
Following data has been updated IN TABLE DVDs
INSERT INTO DVDs (Name, NumDisks, RatingID, StatID)
VALUES('Mash', 2, 'R', 's2'), ('View', 1, 'NR', 's1'), ('Show', 2, 'NR',
's2'), ('Amadeus', 1, 'PG', 's2') , ('Falcon', 1, 'NR', 's2'),
('Africa', 1, 'PG', 's1'), ('Doc', 1, 'G', 's2') , ('Christmas', 1, 'NR',
's1');
On 12/4/06, Bricklen Anderson <banderson@presinet.com> wrote:
>
> Ashish Ahlawat wrote:
> >
> > Hi Team
> >
> > I am unable to fetch data using following simple query it prompts
> > following error
> >
> > *ORA: 00907: Missing right parenthesis*
> >
> > Query :-
> >
> > SELECT
> >
> > Name AS Title, StatID AS Status, RatingID AS Rating,
> >
> > IF(NumDisks>1, 'Check for extra disks!', 'Only 1 disk.') AS Verify
> >
>
> i. That's an Oracle error message.
> ii. IF does not belong in an SQL query. Use CASE.
>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Using Control Flow Functions in a SELECT Statement
@ 2006-12-04 16:48 Richard Broersma Jr <rabroersma@yahoo.com>
parent: Ashish Ahlawat <ahlawat.ashish@gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Richard Broersma Jr @ 2006-12-04 16:48 UTC (permalink / raw)
To: Ashish Ahlawat <ahlawat.ashish@gmail.com>; +Cc: pgsql-sql
> Thanks FOR your prompt response....But USING CASE issue still NOT resolved
> ....Oracle prompts same error.
I see, was answers to you get from the oracle mailing lists regarding this problem? ;o)
Regards,
Richard Broersma Jr.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Using Control Flow Functions in a SELECT Statement
@ 2006-12-05 23:07 Ragnar <gnari@hive.is>
parent: Ashish Ahlawat <ahlawat.ashish@gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Ragnar @ 2006-12-05 23:07 UTC (permalink / raw)
To: Ashish Ahlawat <ahlawat.ashish@gmail.com>; +Cc: pgsql-sql
[
removing a bunch of probably uninterested people from CC
]
On mán, 2006-12-04 at 22:12 +0530, Ashish Ahlawat wrote:
> Hi Team
>
> Thanks
>
> FOR your prompt response....But USING CASE issue still NOT
> resolved....Oracle prompts same error.
this is a postgresql mailing list, but
I believe that even with oracle, the case statement
should work. a quick google found
http://www.oracle-base.com/articles/9i/Case9i.php
gnari
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2006-12-05 23:07 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-12-04 16:21 Using Control Flow Functions in a SELECT Statement Ashish Ahlawat <ahlawat.ashish@gmail.com>
2006-12-04 16:30 ` Richard Broersma Jr <rabroersma@yahoo.com>
2006-12-04 16:32 ` Bricklen Anderson <banderson@presinet.com>
2006-12-04 16:42 ` Ashish Ahlawat <ahlawat.ashish@gmail.com>
2006-12-04 16:48 ` Richard Broersma Jr <rabroersma@yahoo.com>
2006-12-05 23:07 ` Ragnar <gnari@hive.is>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox