dbTalk Databases Forums  

validate whether a record exist..

sybase.public.sqlanywhere.general sybase.public.sqlanywhere.general


Discuss validate whether a record exist.. in the sybase.public.sqlanywhere.general forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
K2
 
Posts: n/a

Default validate whether a record exist.. - 11-26-2007 , 11:01 PM






Dear all

I want to write a SP to insert some new record and those new reocrd has
input into an temp_table call "new_rec"

So if I want to check whether a record exist in old table before copy record
from "new_rec"
, how I can achieve this ?

Should I use "cursor" and a loop to achieve this ?


Thanks~

Ken



Reply With Quote
  #2  
Old   
Frank Ploessel
 
Posts: n/a

Default Re: validate whether a record exist.. - 11-27-2007 , 03:49 AM






Ken,

Why not use INSERT ON EXISTING SKIP (see the documentation of INSERT for
details)?

Frank

On Tue, 27 Nov 2007 06:01:37 +0100, K2 <hk (AT) hk (DOT) com> wrote:

Quote:
Dear all

I want to write a SP to insert some new record and those new reocrd has
input into an temp_table call "new_rec"

So if I want to check whether a record exist in old table before copy
record
from "new_rec"
, how I can achieve this ?

Should I use "cursor" and a loop to achieve this ?


Thanks~

Ken




Reply With Quote
  #3  
Old   
Dmitri
 
Posts: n/a

Default Re: validate whether a record exist.. - 11-27-2007 , 05:28 AM



"K2" <hk (AT) hk (DOT) com> wrote:

Quote:
I want to write a SP to insert some new record and those new reocrd has
input into an temp_table call "new_rec"

So if I want to check whether a record exist in old table before copy
record from "new_rec"
if not exists (select * from mytable where <some_condition> then
insert into mytable
(
select *
from temp_table
where <...>
)
end if ;

Dmitri.




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.