DBAsupport.com Forums - Powered by vBulletin
Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: fucntion query

  1. #11
    Join Date
    Jun 2001
    Location
    NJ
    Posts
    118
    HI,
    This is the procedure I used for populating the static tables.
    Instead of table_name as constant. Use it as parameter.
    procedure rows_selected_cur
    is
    table_name1 VARCHAR2(50) :='Pal_states';
    st_id1 varchar2(2) := 'AK' ;
    sql_stmt varchar2(80) :='';
    where_condition varchar2(80) :='';
    emp_rec pal_states%rowtype;
    TYPE EmpCurTyp IS REF CURSOR; -- define weak REF CURSOR type
    emp_cv EmpCurTyp; -- declare cursor variable

    BEGIN
    --test_id :='NJ';
    -- open cursor variable

    where_condition := ' WHERE ST_ID = ''' || st_id1 || '''' ;
    where_condition := '';
    sql_stmt := 'SELECT * FROM ' || table_name1 || where_condition;
    dbms_output.put_line(sql_stmt );
    OPEN emp_cv FOR sql_stmt; -- INTO emp_rec; --USING st_id1;
    loop
    fetch emp_cv into emp_rec;
    --dbms_output.put_line ('Sql_row_count ' || emp_cv%ROWCOUNT);
    exit when emp_cv%notfound;
    end loop;

    dbms_output.put_line ('Sql_row_count ' || emp_cv%ROWCOUNT);
    close emp_cv;
    --dbms_output.put_line (emp_rec.st_desc);
    end;

    Hope this helps.

    Thanks.
    GD_1976.

  2. #12
    Join Date
    Jun 2001
    Posts
    316
    gee thanx a lot GD..it worked....lol atlast!!!

  3. #13
    Join Date
    Jun 2001
    Location
    NJ
    Posts
    118
    Welcome

    GD_1976.

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