Results 1 to 7 of 7

Thread: procedure

  1. #1
    Join Date
    Nov 2003
    Posts
    33

    Unanswered: procedure

    hi all trying to get the max salary using procedre but getting errors followicreate or replace procedure emp_dept_pro(dept_no in emp.deptno%type)
    is
    type sal_tabtype is table of emp.sal%type
    index by binary_integer;
    cursor emp_dept_cur is select deptno,sal from emp where deptno = dept_no;
    p_emp_dept sal_tabtype;
    c_emp_dept emp_dept_cur%rowtype;
    c binary_integer := 0;
    v_total number(2);
    max emp.sal%type;
    begin
    select count(*) into v_total from emp where deptno = dept_no ;
    for counter in emp_dept_cur loop
    c:= c+1;
    p_emp_dept(c) := counter.sal;
    end loop;
    for c in 1..v_total loop
    if (max < p_emp_dept(c)) then
    max := p_emp_dept(C);
    else
    end if;
    end loop;
    dbms_output.put_line(max);
    end emp_dept_pro;ng is my code
    18/20 PLS-00103: Encountered the symbol "<" when expecting one of the
    following:
    (


    your help would be appriciated

    thanx in advance

  2. #2
    Join Date
    Apr 2003
    Location
    NY
    Posts
    208

    Re: procedure

    You are missing a statement after your ELSE

    Code:
       for c in 1..v_total loop
          if (max < p_emp_dept(c)) then
             max := p_emp_dept(C);
          else
    
        end if;
        end loop;
    either enter a statement after the else, or remove the else.

  3. #3
    Join Date
    Nov 2003
    Posts
    33

    Re: procedure

    Originally posted by carloa
    You are missing a statement after your ELSE

    Code:
       for c in 1..v_total loop
          if (max < p_emp_dept(c)) then
             max := p_emp_dept(C);
          else
    
        end if;
        end loop;
    either enter a statement after the else, or remove the else.

    i did but giving me same error
    is there any problem with data type of max and pl/sal type ?

  4. #4
    Join Date
    Apr 2003
    Location
    NY
    Posts
    208

    Re: procedure

    MAX is a sql keyword. Change your variable name to something else and you should be good to go.

  5. #5
    Join Date
    Jan 2004
    Location
    North Haven, CT
    Posts
    110

    Re: procedure

    Originally posted by vchokshi
    i did but giving me same error
    is there any problem with data type of max and pl/sal type ?
    Avoid using max as variable. It's a reserved word.

  6. #6
    Join Date
    Nov 2003
    Posts
    33

    Re: procedure

    tnanyou very much
    you have saved lot of my times and really appriciate your help

    take care

  7. #7
    Join Date
    Mar 2004
    Posts
    23

    Re: procedure

    for counter in emp_dept_cur loop
    c:= c+1;
    p_emp_dept(c) := counter.sal;
    end loop;
    for c in 1..v_total loop
    if (max < p_emp_dept(c)) then
    max := p_emp_dept(C);
    else
    end if;
    end loop;

    1) max (bad name) doesn't have an initial value.

    2) The 2nd loop 'seems' unnecessary as it appears you can
    track max (the if statement) in first loop

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •