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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change Stored procedure from SQL server to Oracle

Status
Not open for further replies.

trungx

Programmer
Sep 20, 2001
28
VN
I want to change Stored procedure from SQL server to Oracle, but Oracle not accept.
Exam: change If exists (select ...) in SQL server to Oracle
Help me!
 

Can you post the entire SQL procedure? Robbie

"The rule is, not to besiege walled cities if it can possibly be avoided" -- Art of War
 
CREATE PROCEDURE quest2001.proc_setstatus
@id varchar(30),
@param varchar(4),
@taction varchar(10) = ''
AS
DECLARE @status varchar(30)
SET @status='Nused'

IF @param= 'BNOT' -- Set status Bloc-notes
BEGIN
IF EXISTS (SELECT q.IDTBNOT FROM quest2001.QUEST_TBNOTE q WHERE q.IDTBNOT=@id ) SET @status='Used'
UPDATE t SET t.STATUTTBNOT =@status FROM quest2001.TYPE_BLOC_NOTE t WHERE t.IDTBNOT=@id
END
 

You can change this part of your procedure:

IF EXISTS (SELECT q.IDTBNOT FROM quest2001.QUEST_TBNOTE q WHERE q.IDTBNOT=@id )
SET @status='Used'
UPDATE t SET t.STATUTTBNOT =@status
FROM quest2001.TYPE_BLOC_NOTE t
WHERE t.IDTBNOT=@id
END


To an Oracle equivalent:

BEGIN
SELECT q.IDTBNOT
FROM quest2001.QUEST_TBNOTE q
WHERE q.IDTBNOT=v_id;

v_status='Used';

UPDATE t SET t.STATUTTBNOT = v_status
FROM quest2001.TYPE_BLOC_NOTE t
WHERE t.IDTBNOT= v_id
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;


I don't know if my theory is right, table quest2001.TYPE_BLOC_NOTE will be updated to 'Used' when data is found on quest2001.QUEST_TBNOTE.



Robbie

"The rule is, not to besiege walled cities if it can possibly be avoided" -- Art of War
 
thanks you,help me, It run ok. but I met problem when I create Trigger and this trigger call that procedure.

Ex:
CREATE TRIGGER quest2001.STATUTEVAFONCTi ON quest2001.EVALUATIONDECLARE
FOR INSERT,UPDATE
AS
DECLARE @id varchar(30)
(SELECT id=old.IDFONCT FROM deleted old)
EXECUTE quest2001.PROC_SETSTATUS id,'EIDX;'


this trigger created in SQL SERVER I can not change ORAC. Can you help me
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top