Home » SQL & PL/SQL » SQL & PL/SQL » Procedure Calling Methods (PL/SQL Toad Oracle 10g)
Procedure Calling Methods [message #598379] Mon, 14 October 2013 08:26 Go to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

I have created this procedure for printing ename,sal,job as ouput
using empno as input:-

CREATE OR REPLACE PROCEDURE p_get (
   p_empno         NUMBER,
   p_name    OUT   VARCHAR2,
   p_sal     OUT   NUMBER,
   p_job     OUT   VARCHAR2
)
IS
BEGIN
   SELECT ename, sal, job
     INTO p_name, p_sal, p_job
     FROM emp
    WHERE empno = p_empno;
END;


Now My Requirement I want to call this procedure using Positional,
Named and Mix Methods :-

I am calling this procedure using Positional Method:-
declare
p_name varchar2(20);
p_sal number;
p_job varchar2(20);
begin
p_get(7369,p_name,p_sal,p_job);
dbms_output.put_line('Name='||p_name||' Salary='||p_sal||' Job='||p_job);
end;


Note:- But i don't know how to call the same procedure using NAMED and MIX methods.
Kindly please tell how to call same procedure using NAMED and MIX methods.
Thanks
Re: Procedure Calling Methods [message #598381 is a reply to message #598379] Mon, 14 October 2013 08:36 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
jgjeetu wrote on Mon, 14 October 2013 18:56
But i don't know how to call the same procedure using NAMED and MIX methods.
Kindly please tell how to call same procedure using NAMED and MIX methods.


-- Positional Notation.
p_get(7369,p_name,p_sal,p_job);

-- Mixed Notation.
p_get(p_empno => 7369,p_name,p_sal,p_job);

-- Named Notation.
p_get(p_empno => 7369,p_name => p_name,p_sal => p_sal,p_job => p_job);


Positional, Named, and Mixed Notation

Regards,
Lalit

[update : Provided link to docs]

[Updated on: Mon, 14 October 2013 08:39]

Report message to a moderator

Re: Procedure Calling Methods [message #598382 is a reply to message #598379] Mon, 14 October 2013 08:37 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Positional: p_get(7369,p_name,p_sal,p_job);
Named: p_get(p_sal=>p_sal,p_name=>p_name,p_empno=>7369,p_job=>p_job);
Mix: p_get(7369,p_name,p_job=>p_job,p_sal=>p_sal);

Re: Procedure Calling Methods [message #598383 is a reply to message #598382] Mon, 14 October 2013 08:47 Go to previous messageGo to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

Thanks michel and lalit Smile
I tried this one also:-
p_get(7369,p_sal=>p_sal,p_name=>p_name,p_job);

and got this error:-

PLS-00312: a positional parameter association may not follow a named association

Why and what is the reason ?
Re: Procedure Calling Methods [message #598385 is a reply to message #598383] Mon, 14 October 2013 08:55 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Read the error, what do you think that the error means?
Re: Procedure Calling Methods [message #598388 is a reply to message #598385] Mon, 14 October 2013 09:05 Go to previous messageGo to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

the error says you can't use the positional parameter after using named paramter , but i want to know the reason what's the reason why cant we use ?
Re: Procedure Calling Methods [message #598390 is a reply to message #598388] Mon, 14 October 2013 09:07 Go to previous message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

As you can put the named parameter in any order which one would be the next positional parameter you'll give?

Previous Topic: calling a function in another function to insert a dml record is failing
Next Topic: Error ORA-04091
Goto Forum:
  


Current Time: Wed Apr 24 20:36:39 CDT 2024