DBMS.OUTPUT Group Functions from a Cursor?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • geebanga88
    New Member
    • Aug 2007
    • 62

    DBMS.OUTPUT Group Functions from a Cursor?

    Hi was wondering if you are allowed to output a group function such as SUM
    from a cursor. For example:

    [CODE=oracle]
    DECLARE
    cursor customer_total_ owing IS
    SELECT c_first, c_last, SUM(inventory.i nv_price * order_line.ol_q uantity)
    FROM customer, orders, order_line, inventory
    WHERE customer.c_id = orders.c_id
    AND orders.o_id = order_line.o_id
    AND order_line.inv_ id = inventory.inv_i d
    GROUP BY c_first, c_last;

    customer_owing_ row customer_total_ owing%rowtype;


    BEGIN

    FOR customer_owing_ row IN customer_total_ owing
    LOOP
    DBMS_OUTPUT.PUT _LINE(customer_ owing_row.c_fir st || customer_owing_ row.c_last || ' $' || customer_owing_ row.SUM(invento ry.inv_price * order_line.ol_q uantity));
    END LOOP;

    END;
    [/CODE]
    Im having trouble outputing the group function customer_owing_ row.SUM(invento ry.inv_price * order_line.ol_q uantity));.
    *customer_owing _row is a %rowtype of the cursor which has the group function.

    The error i get:
    ORA-06550: line 17, column 110:
    PLS-00302: component 'SUM' must be declared.
    So can i output this function or is there some other way to do it?
    Last edited by debasisdas; Mar 8 '08, 04:18 PM. Reason: added code =oracle tag
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    You need to use a column alias for the sum(field_name) .

    Comment

    • geebanga88
      New Member
      • Aug 2007
      • 62

      #3
      Originally posted by debasisdas
      You need to use a column alias for the sum(field_name) .
      Ah yes so simple, thank you:D

      Comment

      Working...