Home » RDBMS Server » Server Administration » query question
query question [message #371491] Sun, 29 October 2000 14:19 Go to next message
christopher
Messages: 25
Registered: September 2000
Junior Member
Can anyone give me an example to work on this problem? I need to write a block that will give an existing employee a raise and print the old salary and the new salary as outputs. I wanted to prompt the name of the employee and then enter the amount of the raise. here is what I have thus far.Thanks

/*begin by prompting which employee is going to get a raise*/

SET SERVEROUTPUT OFF
SET VERIFY OFF

ACCEPT p_ename PROMPT 'Please enter the new employee name: ';
ACCEPT p_annual_sal PROMPT 'Please enter the amount of raise: ';

DECLARE

V_ename emp.ename%TYPE := '&p_ename';
v_sal NUMBER(9,2):=&p_annual_sal;

BEGIN

SELECT EMP.ENAME, EMP.SAL
FROM EMP
WHERE EMP.ENAME
Re: query question [message #371503 is a reply to message #371491] Mon, 30 October 2000 14:28 Go to previous message
Shanthi Ramayanapu
Messages: 22
Registered: October 2000
Junior Member
Try the following

DECLARE
p_name varchar2(10);
p_id number;
n_id number;
BEGIN
SELECT a.name, a.id into p_name, p_id
FROM btemp a
WHERE a.NAME= &&v_name;

update btemp
set id = &p_id
where name = &&v_name;

SELECT a.name, a.id into p_name, n_id
FROM btemp a
WHERE a.NAME= &&v_name;

dbms_output.put_line('Name is'||p_name||' and old salary is '||to_char(p_id)||'
new salary is '||to_char(n_id));

END;
/

Shanthi
Previous Topic: how to call host commands from Oracle 7.3.4 and above
Next Topic: Databases of many languages
Goto Forum:
  


Current Time: Sat Apr 27 03:50:59 CDT 2024