please find out mistake.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Deven Oza
    New Member
    • Oct 2006
    • 53

    please find out mistake.

    Hello everybody,

    I need your help to write the following procedure. I did it but dont get the out put so please help me that where I made mistake. I written the procedure just after the specification.


    Write a program that computes a salesperson’s commission according to the specifications outlined below.

    A particular company computes a salesperson’s weekly commission as follows:

    If the salesperson sold less than or exactly equal to $ 500 in
    products / services, then the salesperson’s commission rate
    is 3.00

    If the salesperson sold more than $ 500 but not more than $ 1,000 in products / services, then the salesperson’s commission rate
    is 5.00

    If the salesperson sold more than $ 1,000 in products / services,
    then the salesperson’s commission rate is 10.00

    To compute a salesperson’s commission, multiply the commission rate by his / her total sales.
    *************** *************** *************** ***
    I WRITE DOWN AS UNDER.
    set serveroutput on;
    set verify off;
    declare
    sales number := &sales;
    comm_rate number(5,2);
    commission number(6,2);

    begin
    if sales <= 500
    then comm_rate := 0.03;
    else if sales <= 1000
    then comm_rate := 0.05;
    else
    comm_rate := 0.10;
    end if;

    commission := comm_rate * sales;
    dbms_output.put _line('Employee s commission is' || commission);

    End;

    BUT ITS NOT WORKING . PLEASE LET ME KNOW WHERE I MADE MISTAKE.

    Thank you.
    Deven Oza
  • Mondo Tofu
    New Member
    • Dec 2006
    • 12

    #2
    What you typed in should work.

    One thing to watch for in SQL*Plus is avoid putting blank lines in your anonymous PL/SQL block.

    It could fool the interpreter and think that the code did not belong together.

    As with all PL/SQL code, issue a slash ( / ) all by itself in the first column to execute the code.

    Good luck!

    Mondo Tofu

    Comment

    • suvam
      New Member
      • Nov 2006
      • 31

      #3
      Can u mention what is the actual error coming during compilation ?

      Comment

      • nunnasujatha
        New Member
        • Nov 2006
        • 24

        #4
        Hi u missed one more end if;
        that is the problem.

        the following code works.check it.

        SQL> declare
        2 sales number := &sales;
        3 comm_rate number(5,2);
        4 commission number(6,2);
        5 begin
        6 if sales <= 500
        7 then comm_rate := 0.03;
        8 else if sales <= 1000
        9 then comm_rate := 0.05;
        10 else
        11 comm_rate := 0.10;
        12 end if;
        13 end if;
        14 commission := comm_rate * sales;
        15 dbms_output.put _line('Employee s commission is' || commission);
        16 end;
        17 /
        Enter value for sales: 300
        old 2: sales number := &sales;
        new 2: sales number := 300;

        PL/SQL procedure successfully completed.

        SQL> set serveroutput on;
        SQL> /
        Enter value for sales: 300
        old 2: sales number := &sales;
        new 2: sales number := 300;
        Employees commission is9

        PL/SQL procedure successfully completed.

        Comment

        Working...