Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2008
    Posts
    8

    Unanswered: Need help to print cursor

    Hi,


    My code for cursor is


    DECLARE
    CURSOR all_emps is
    select to_char(b.end_date,'Mon DD YYYY') ,
    queue_status_code , count(distinct a.fund_group_id)
    from tmp.tmp_scheduled_funds a, tmp.tmp_sched_queue b
    where rtrim(b.fund_group_id) = rtrim(a.fund_group_id)
    and b.requestor_name = :v_req_name
    and b.upd_time between to_date(:v_start_time,:v_date_format) and to_date(:v_end_time,:v_date_format)
    and b.task_type_code = 'PA'
    group by b.end_date, queue_status_code
    order by b.end_date, queue_status_code ;

    emp all_emps%ROWTYPE;
    BEGIN
    OPEN all_emps;

    LOOP
    EXIT WHEN all_emps%NOTFOUND;
    FETCH all_emps INTO emp;
    DBMS_OUTPUT.PUT_LINE(emp.queue_status_code);
    END LOOP;

    CLOSE all_emps;
    END;
    /


    I am able to print just "queue_status_code".


    How should I print end_date "to_char(b.end_date,'Mon DD YYYY')" and count "count(distinct a.fund_group_id) " in

    DBMS_OUTPUT.PUT_LINE("****",emp.queue_status_code, "***");?


    Thanks in advance.........

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Concatenate all values you need, such as
    Code:
    DBMS_OUTPUT.PUT_LINE(emp.first_value ||' - '|| emp.second_value ||' - '|| emp.third_value);

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Cool Or maybe this

    Maybe you could try something like this:
    Code:
    VAR all_emps REFCURSOR;
    
    DECLARE
    BEGIN
       OPEN :all_emps FOR
          SELECT   TO_CHAR (b.end_date, 'Mon DD YYYY'), queue_status_code,
                   COUNT (DISTINCT a.fund_group_id)
              FROM tmp.tmp_scheduled_funds a, tmp.tmp_sched_queue b
             WHERE RTRIM (b.fund_group_id) = RTRIM (a.fund_group_id)
               AND b.requestor_name = :v_req_name
               AND b.upd_time BETWEEN TO_DATE (:v_start_time, :v_date_format)
                                  AND TO_DATE (:v_end_time, :v_date_format)
               AND b.task_type_code = 'PA'
          GROUP BY b.end_date, queue_status_code
          ORDER BY b.end_date, queue_status_code;
    END;
    /
    
    PRINT all_emps

    How should I print end_date "to_char(b.end_date,'Mon DD YYYY')" and count "count(distinct a.fund_group_id) "
    You need to define an alias for those columns like:
    Code:
    Select ..etc.., to_char(b.end_date,'Mon DD YYYY') End_Date, ...etc...
    Last edited by LKBrwn_DBA; 03-13-09 at 12:38.
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  4. #4
    Join Date
    Dec 2008
    Posts
    8

    Wink

    hey thanks friend for quick reply...will try this one.......

Posting Permissions

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