--
Paul Horan[TeamSybase]
Get the new PB9 books!
http://www.pb9books.com?source=newsgroups
Code samples on Sybase CodeXchange:
http://codexchange.sybase.com
ISUG Enhancement Requests:
http://www.isug.com/cgi-bin/ISUG2/submit_enhancement
<Ed Ardzinski> wrote in message news:3f4e60c6.61...@sybase.com...
This is what I'm trying...although I get a syntax error mear
where I try to use the where clause. I started yesterday
trying to use an If/Then structure:
insert into
other_referral (other_referral_id, name, status, last_name,
source_or_recipient, specialty)
values ((select max(other_referral_id)+1 from
other_referral), '1-800-DENTIST', 'A', '1-800-DENTIST', 'S',
-1)
where not exists (select * from other_referral where name =
'1-800-DENTIST')
INSERT INTO t1
ON EXISTING SKIP
VALUES (1,'new_value');
From the docs :
If you specify the ON EXISTING clause, the server does a primary key lookup
for each input row. If the corresponding row does not already exist in the
table, it inserts the new row as usual. For rows that already exist in the
table, you can choose to silently ignore the input row (SKIP), update the
values in the input row (UPDATE), or generate an error message for duplicate
key values (ERROR).
--
Reg Domaratzki, Sybase iAnywhere Solutions
Sybase Certified Professional - Sybase ASA Developer Version 8
Please reply only to the newsgroup
iAnywhere Developer Community : http://www.ianywhere.com/developer
ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm
-> Choose SQL Anywhere Studio
-> Set "Platform Preview" and "Time Frame" to ALL
<Ed Ardzinski> wrote in message news:3f4e60c6.61...@sybase.com...
If not exists (
select 1 from other_referral
where name = '1-800-DENTIST' ) then
insert into other_referral (
other_referral_id,
name,
status,
last_name,
source_or_recipient,
specialty)
(select
max(other_referral_id)+1,
'1-800-DENTIST',
'A',
'1-800-DENTIST',
'S',
-1
from other_referral )
End if;
--
Paul Horan[TeamSybase]
Get the new PB9 books!
http://www.pb9books.com?source=newsgroups
Code samples on Sybase CodeXchange:
http://codexchange.sybase.com
ISUG Enhancement Requests:
http://www.isug.com/cgi-bin/ISUG2/submit_enhancement
<Ed Ardzinski> wrote in message news:3f4f4609.f4...@sybase.com...
BTW, Reg...using ASA 7. Sorry forgot to mention that.