Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: HELP! Coding problems!

Re: HELP! Coding problems!

From: Robert Chin <robert_chin_2000_at_hotmail.com>
Date: Wed, 05 Dec 2001 16:18:37 GMT
Message-ID: <xNrP7.2034$MX1.441350@news02.optonline.net>


Forgot to do your homework, huh ?
And no sample data ? How'd you expect people to know about your COURSE table etc ?

Save the code below into Notepad
and run in sql*plus. It should take care of Part 1 of your question I'll let you do the 2nd part

Since you gave no sample data
You'll have got some editing to do to suit your need: I used a table of mine MY_EMP

Robert Chin



accept test_entry number prompt 'Enter pay-cut %: '

declare
cursor happy_emp(target varchar2) is

    select * from my_emp where UPPER(job) like target; amount number := &test_entry;
discount_target my_emp.job%TYPE := '%BUSBOY%';

begin
  begin
    if (to_number(amount) > 0) then

       null;
    end if;
  exception
    when value_error then
 dbms_output.put_line('Input error !');
  end;
  dbms_output.put_line('Now giving '||lower(REPLACE(discount_target,'%'))||' a well-deserved pay-cut !'||Chr(10));
  update my_emp set sal = sal * (1 - amount/100)

       where UPPER(job) like discount_target;   commit;
  dbms_output.put_line('Merry Christmas, guys/gals !........'||chr(10));   for rec in happy_emp(discount_target)
  loop
  dbms_output.put_line(rec.empno||' '||rec.ename||' '||rec.job||' '||to_char(rec.sal,'$9,999,999.99'));
  end loop;

end;
/

--
Robert Chin

"Dude"

> I am having a tough time trying to solve these two programming problems:
>
> 1.) I need to write a PL/SQL program that prompts the user for the
percent
> discount that should be applied to the cost of all 'JAVA' courses. Update
> the COURSE table decreasing the course cost for the 'JAVA' courses by the
> percent discount. Us an explicit cursor to retrieve all of the updated
> courses and produce output containing the course id, title, credits, and
> cost. Use a cursor FOR loop to shortcut the process of displaying the
> course information. Display the course cost as currency. Don't hardcode
> literals within the executable section. Create variables and assign
initial
> values in the declarative section.
>
> 2.) Write a PL/SQL program to ....
-- Robert Chin 203-846-4198 "Dude" <liberal.democrat_at_prodigy.net> wrote in message news:vmhP7.4449$hu.980479034_at_newssvr17.news.prodigy.com...
> I am having a tough time trying to solve these two programming problems:
>
> 1.) I need to write a PL/SQL program that prompts the user for the
percent
> discount that should be applied to the cost of all 'JAVA' courses. Update
> the COURSE table decreasing the course cost for the 'JAVA' courses by the
> percent discount. Us an explicit cursor to retrieve all of the updated
> courses and produce output containing the course id, title, credits, and
> cost. Use a cursor FOR loop to shortcut the process of displaying the
> course information. Display the course cost as currency. Don't hardcode
> literals within the executable section. Create variables and assign
initial
> values in the declarative section.
>
> 2.) Write a PL/SQL program to display enrollment for each course section
> that a specified student is in. Accept a student id from the user.
> Retrieve all the course sections that the student is enrolled in from the
> ENROLLMENT table and store them in a PL/SQL table. Using another loop,
> retrieve a count of all students who are enrolled in each of the sections
> that are loaded into the table. Produce output like:
>
> Please enter the student id: 123
>
> Course section 95 has an enrollment of 1.
> Course section 125 has an enrollment of 1.
>
> Explicitly OPEN, FETCH data from, and CLOSE each cursor. Do not use FOR
> loops to shortcut the process.
>
> I really, REALLY, appreciate any suggestions and help that can be offered.
>
>
Received on Wed Dec 05 2001 - 10:18:37 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US