Home » SQL & PL/SQL » SQL & PL/SQL » please, i need a help in procedure
please, i need a help in procedure [message #312740] Wed, 09 April 2008 12:42 Go to next message
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 Smile

[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 #312753 is a reply to message #312740] Wed, 09 April 2008 13:05 Go to previous messageGo to next message
RRRR
Messages: 6
Registered: April 2008
Junior Member
please, i need to understand the question...
Re: please, i need a help in procedure [message #312768 is a reply to message #312753] Wed, 09 April 2008 13:34 Go to previous messageGo to next message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
What don't you understand in the question?
We give you an employee id and you have to return the name and salary in output variables.

Regards
Michel
Re: please, i need a help in procedure [message #312773 is a reply to message #312740] Wed, 09 April 2008 13:39 Go to previous messageGo to next message
RRRR
Messages: 6
Registered: April 2008
Junior Member

ok..

i am using a cursor , and iam using select statement to query the table , but there is error in the code, is this false?

thanks

Re: please, i need a help in procedure [message #312780 is a reply to message #312773] Wed, 09 April 2008 14:01 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
What exactly do you think a cursor is?
Where does it differ from a select?

So, should there both be a cursor AND a select in your code?
Re: please, i need a help in procedure [message #312785 is a reply to message #312740] Wed, 09 April 2008 14:12 Go to previous messageGo to next message
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 #312820 is a reply to message #312785] Wed, 09 April 2008 19:29 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Show us the final result, it might have some things we can comment on to help you improve.
Re: please, i need a help in procedure [message #312832 is a reply to message #312740] Wed, 09 April 2008 20:31 Go to previous messageGo to next message
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 Go to previous messageGo to next message
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
Re: please, i need a help in procedure [message #312903 is a reply to message #312883] Thu, 10 April 2008 01:32 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
*cough*pot and kettle*cough*
i need help in item conversions [message #313046 is a reply to message #312768] Thu, 10 April 2008 08:53 Go to previous messageGo to next message
tsonali_apps
Messages: 2
Registered: April 2008
Junior Member
Hi,

i am new to the conversions.i dont understand how the validation and loading is done in the conversion.
please explain it with some simple example.

Sonali(thanks)
Re: please, i need a help in procedure [message #313049 is a reply to message #312903] Thu, 10 April 2008 08:57 Go to previous message
MarcS
Messages: 312
Registered: March 2007
Location: Antwerp
Senior Member
Frank wrote on Thu, 10 April 2008 08:32
*cough*pot and kettle*cough*


Laughing
Previous Topic: Exception within the loop
Next Topic: Find the Less Serial Numbers in a table
Goto Forum:
  


Current Time: Mon Feb 17 22:19:21 CST 2025