Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Merge in stored procedure


Merge in stored procedure

Author
Message
masoudk1990
masoudk1990
Valued Member
Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)

Group: General Forum Members
Points: 66 Visits: 299
Hello guys, may you help me why my merge in stored procedure have exception?


CREATE OR REPLACE PROCEDURE mySP
(
pID IN NUMBER
, pCurrent_Level_ID IN NUMBER
, pParent_Level_ID IN NUMBER
, pTitle IN VARCHAR2
, pOrganization_Unit IN NUMBER
, outmessage OUT VARCHAR2
, outresult OUT NUMBER
) AS

BEGIN

----------------validation

outresult := -1;

IF pTitle IS NULL THEN
outmessage := 'Please insert title';
RETURN;
END IF;

IF pOrganization_Unit IS NULL THEN
outmessage := 'Please determine your organization unit';
RETURN;
END IF;


-----------end validation
-----------if exists update else insert

MERGE INTO myTable USING dual ON --I have Error here sql statement ignored
(Id = pid)
when matched then
UPDATE myTable SET Title = pTitle,Organization_Unit = pOrganization_Unit
WHERE ID = pID;
WHEN not matched then
INSERT INTO myTable(ID,Current_Level_ID,Parent_Level_ID,Title,Organization_Unit)
VALUES (Commision_Commodity_Group_Id.nextval,pCurrent_Level_ID,pParent_Level_ID,pTitle,pOrganization_Unit)

outMessage := 'Success';
outNumber := 0;

return;
EXCEPTION
WHEN OTHERS THEN
outMessage := 'Error : ' || SQLERRM;
outNumber := -1;
return;

END mySP;



___________________________________
Computer Enterprise Masoud Keshavarz
I don't care about hell.
If I go there I've played enough Diablo to know how to fight my way out.
twin.devil
twin.devil
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1376 Visits: 2596
what error are you getting
Luis Cazares
Luis Cazares
SSCrazy Eights
SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)

Group: General Forum Members
Points: 8506 Visits: 18115
Are you working in Oracle or SQL Server?


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
masoudk1990
masoudk1990
Valued Member
Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)Valued Member (66 reputation)

Group: General Forum Members
Points: 66 Visits: 299
Sorry I think I asked my question in wrong section. I just searched for 'oracle' with ctrl + F through my web browser and I'm in here.

I working with oracle through sqlDeveloper software. The error I get is "sql statement ignored".
I searched for this and I found that "Merge" statement should be in beginning of procedure or you have to put it in a string and execute it with equivalent of sp_execute in oracle.

I tried all this methods and I still get "sql statement ignored" error.

By the way is it okay to ask oracle questions in this forum or I must register in another forums for my oracle questions?

___________________________________
Computer Enterprise Masoud Keshavarz
I don't care about hell.
If I go there I've played enough Diablo to know how to fight my way out.
Luis Cazares
Luis Cazares
SSCrazy Eights
SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)SSCrazy Eights (8.5K reputation)

Group: General Forum Members
Points: 8506 Visits: 18115
There's no problem for us if you post it here. However, this site is focused on SQL Server and you might not get the best answers. You should try an Oracle forum.
I'm not great at Oracle, but aren't you missing a table on MERGE statement?


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search