Glowworm27
Programmer
Hello gurus,
I am a Microsoft SQL guy, and need to write an App using an Oracle DB, for the most part all has been going well.
my problem:
I need to write a stored proc to either insert a record into the employee_master table if one DOES NOT exist, or update an Existing Record.
I could write this in SQL no problem, so I figured it would be close, but I am having some syntactical errors, that I am not familiar with when it comes to Oracle.
Could someone check this proc and tell me what I am missing or explain it to me? thanks
Thanks again in advance!!!!
George Oakes
Check out this awsome .Net Resource!
I am a Microsoft SQL guy, and need to write an App using an Oracle DB, for the most part all has been going well.
my problem:
I need to write a stored proc to either insert a record into the employee_master table if one DOES NOT exist, or update an Existing Record.
I could write this in SQL no problem, so I figured it would be close, but I am having some syntactical errors, that I am not familiar with when it comes to Oracle.
Could someone check this proc and tell me what I am missing or explain it to me? thanks
Code:
CREATE OR REPLACE PROCEDURE "SYSTEM"."SPINSUPEMPMASTREC" (
oUniversalID IN Number
, oCompanyCode IN Number
, oLastName In Varchar2
, oFirstName In Varchar2
, oMiddleInit In Varchar2
, oSSN In Varchar2
, oHireDate In Date
)
as
begin
declare UnivID Number
Set UnivID = (Select Count(*) from Employee_Master Where Universal_ID = oUniversalID);
if UnivID > 0
Begin
Update Employee_Master
Set Company_Code = oCompanyCode
, Last_Name = oLastName
, First_Name = oFirstName
, Middle_Init = oMiddleInit
, SSN = oSSN
, Hire_Date = oHireDate
where Universal_ID = oUniversalID
End
Else
Begin
Insert Into Employee_Master Values(oUniversalID, OCompanyCode, oLastName, oFirstName
, oMiddleInit, oSSN, oHireDate)
End
end;
Thanks again in advance!!!!
George Oakes
Check out this awsome .Net Resource!