Re: SQL Exists query in SPL If
Posted in 1996
Dave Harding wrote:
> All Gurus,
> In SPL, if I want to test the existance of a particular record, I either
> select count(*) into x_count ... or> select rowid into x_exists ..... and then test the value of either x_count
> or x_exists. It seems to me that you should be able to say something like
> "if [not] exists select ...then ...etc etc. I have had a bit of a fiddle
> but nothing is ever easy is it?
> Has anyone nutted this one out already or discovered that it can't be
> done, I'd appreciate some feedback.
Yes, you can use the following in SPL:
IF EXISTS (
SELECT *
FROM table
WHERE.....
)
THEN
:
ELSE
:
END IF;
Notice the placement of semi-colons (;).
Hope that helps,
--
Mark.
+-------------------------------------------------------------------------+
|Mark D. Stock - The West Solutions Group http://www.west.co.za |
| |
|mailto:marks@west.co.za +------------------------------------------------+
|Tel: +27 11 803 2151 |If it doesn't work... force it! |
|Fax: +27 11 803 2189 |If it breaks... it needed replacing anyway! |
|Cell: +27 83 250 2325 |Well, that's how I code anyway! |
+------------------------+------------------------------------------------+