|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Stored Procedure
I have the following Stored Procedure:
CREATE PROCEDURE SPR_USER ( CODEUSER VARCHAR(30), NAME VARCHAR(100), PASS VARCHAR(20) AS BEGIN INSERT INTO USER (CODEUSER,NAME,PASS) VALUES (:CODEUSER,:NAME,PASS); SUSPEND; END I want to change this Stored Procedure to check if allready exists a user with the CODEUSERT that itīs trying to insert before doing the insert or else itīs going to give me an error because the column CODEUSER is a primary key. How can I solve this problem ?? |
|
#2
|
|||
|
|||
|
Quote:
... IF (NOT EXISTS(SELECT CODEUSER FROM USER WHERE CODEUSER = :CODEUSER)) THEN INSERT INTO USER (CODEUSER,NAME,PASS) VALUES (:CODEUSER,:NAME,PASS); |
|
#3
|
|||
|
|||
|
btw, do not use SUSPEND in executable procedures, there's no need.
With regards, Martijn Tonies Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL Server Upscene Productions http://www.upscene.com Database development questions? Check the forum! http://www.databasedevelopmentforum.com |
|
#4
|
|||
|
|||
|
But how would the procedure return saying that a user allready exists ?
|
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Stored Procedure |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|