please, i need a help in procedure [message #312740] |
Wed, 09 April 2008 12:42  |
RRRR
Messages: 6 Registered: April 2008
|
Junior Member |
|
|
hello
i have a question, i answered it but i don't know what exactly the question need
the question is:
create a procedure called query_emp to query the employees table, retrieving the salary and name columns for an employee when provided the specified employee id
i wrote this code
create or replace procedure query_emp(
em_id in employees.id%type,
em_name out employees.nama%type,
em_salary out employees.salary%type) is
cursor q_curr is
select * from employees for update;
cur_row q_curr%rowtype;
begin
open q_curr;
loop
fetch q_crr into cur_row;
exit when(q_curr%notfound);
select name, salary into em_name, em_salary from employees
end loop;
close q_curr;
end query_emp;
/
then i will make execution as this
variable p_name varchar2(20)
variable p_salary number
execute query_emp(32, :p_name, :p_salary)
i am a new student in data base
i hope you help me , please
thank you
[Edit MC: replace quote tags to code one]
[Updated on: Wed, 09 April 2008 12:57] by Moderator Report message to a moderator
|
|
|
|
|
|
|
Re: please, i need a help in procedure [message #312785 is a reply to message #312740] |
Wed, 09 April 2008 14:12   |
RRRR
Messages: 6 Registered: April 2008
|
Junior Member |
|
|
i know that we use a cursor as pointer and i know that there is types of cursors..i know this
and i know that we use a cursor when we need it..
So, should there both be a cursor AND a select in your code?
no..
thank you ... i solve the question without using cursor..and there is no problem
thanks
|
|
|
|
Re: please, i need a help in procedure [message #312832 is a reply to message #312740] |
Wed, 09 April 2008 20:31   |
ravi214u
Messages: 153 Registered: February 2008 Location: CANADA
|
Senior Member |
|
|
Simple example without using cursors.
create or replace procedure query_emp(empid emp.empno%type) as
name emp.ename%type;
sala emp.sal%type;
begin
select ename,sal into name,sala from emp where empno=empid;
dbms_output.put_line(name||sala);
end;
/
Procedure created
SQL> set serveroutput on
SQL> exec query_emp(7369);
SMITH 800
PL/SQL procedure successfully completed
|
|
|
Re: please, i need a help in procedure [message #312883 is a reply to message #312832] |
Thu, 10 April 2008 00:56   |
 |
Michel Cadot
Messages: 68737 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Don't put solution only hint or clue as requested in OraFAQ Forum Guide, "Responding to Posts" section:
Quote: | When responding to questions, if it is obviously a student with a homework assignment or someone else just learning, especially in the homework and newbies forums, it is usual to provide hints or clues, perhaps links to relevant portions of the documentation, or a similar example, to point them in the right direction so that they will research and experiment on their own and learn, and not provide complete solutions to problems. In cases where someone has a real-life complex work problem, or at least it may seem complex to them, it may be best to provide a complete demo and explanation.
|
Regards
Michel
|
|
|
|
|
|