Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Trouble with a simple stored procedure..
Hello, I'm a seasoned SQL Server developer and new to Oracle. I am
trying to write a simple SP that detects if a record exists for a
particular GUID.
If not, it creates the record with a new id, the GUID and an e-mail address. If it does already exist, it updates the e-mail address. Either way, it returns the id back to the caller.
The table looks like this..
CREATE TABLE SCANA.SCOOPCREATORS
(
SCOOPID NUMBER(1) NOT NULL, GUID VARCHAR2(36) NOT NULL, EMAIL VARCHAR2(500) NOT NULL,
I'm trying to create the following SP but it fails. Can anyone help?
Thanks,
Gary
CREATE OR REPLACE PROCEDURE SCANA.GET_SCOOP_CREATOR_ID (
creatorId OUT INTEGER,
guid IN VARCHAR2,
email IN VARCHAR2 ) IS
BEGIN
IF NOT EXISTS (SELECT CREATORID FROM ScoopCreators WHERE GUID =
guid) BEGIN
INSERT INTO SCOOPCREATORS (CREATORID, GUID, EMAIL) VALUES(SCANA.SEQ_SCOOPCREATORS.NEXTVAL, guid, email); ELSE UPDATE SCOOPCREATORS SET EMAIL=email WHERE GUID=guidEND SELECT CREATORID INTO creatorId FROM ScoopCreators WHERE GUID = guid
![]() |
![]() |