Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Small Programmers SP Trick

Status
Not open for further replies.

Krshin

Programmer
Feb 2, 2003
3
0
0
YU
Hello,

I would like to create stored procedure witch is do next job:

1. I have some table ( field1, field2, field3 - all smallint )
2. My procedure will update this table with SQL statment UPDATE table SET field3 = field3 + 1 WHERE field1 = :f1 AND field2 = :f2
3. If field1 or field2 does not exist procedure dont use SELECT statment form, but automaticly insert fields somethin like INSERT INTO table :f1, :f2, :f3
4. Thanks for all answeres

Krshin
 
if (EXISTS (SELECT * FROM mytable WHERE field1 = :f1 AND field2 = :f2) )
THEN UPDATE...
ELSE INSERT...

Martijn Tonies
Database Workbench - the developer tool for InterBase, Firebird, MySQL & MS SQL Server
 
Thanks Martinjn, your the 1st !!!

Krshin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top