DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Use FOR rec IN <variable>

  1. #1
    Join Date
    Jun 2007
    Posts
    60

    Use FOR rec IN <variable>

    Hi

    I have got a sql statement in var say v_s_sql_stmt = 'select * from mytable'
    now I want use the v_s_sql_stmt in implisit cursor like this

    FOR rec in (v_s_sql_stmt)
    LOOP
    ..
    END LOOP;

    How can I do it. I don't have access to select stmt itself just to the variable

    Ta

  2. #2
    Join Date
    Jul 2002
    Location
    Lake Worth, FL
    Posts
    1,492

    Talking Ref Cursor

    Try something like this:
    Code:
    ...
       TYPE CurTyp IS REF CURSOR;
       rec  CurTyp;
    ...
    BEGIN
      OPEN rec FOR v_s_sql_stmt;
      LOOP
          FETCH rec INTO {some variable(s)};
          EXIT WHEN rec%NOTFOUND;
    ...
    "The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb

  3. #3
    Join Date
    Jun 2007
    Posts
    60
    Thank you LKBrwn. Appreciate it.

Posting Permissions

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


Click Here to Expand Forum to Full Width