Cursor using dynamic SQL


declare
i integer;
v_number integer;
table_name varchar(20);
sno_ varchar(20);
sname_ varchar(50);
begin
table_name :='student';
i:=DBMS_SQL.open_cursor;
DBMS_SQL.parse(i,'select sno,sname from '||table_name,DBMS_SQL.v7);
DBMS_SQL.define_column(i,1,sno_,20);
DBMS_SQL.define_column(i,2,sname_,20);-- Note If you set up the table specifies the precision of the time The last length must be specified

v_number:=DBMS_SQL.execute(i);-- Note You must You want to v_number:= Or report errors

loop
if(DBMS_SQL.fetch_rows(i)=0) then
exit;
else
DBMS_SQL.column_value(i,1,sno_);
DBMS_SQL.column_value(i,2,sname_);
DBMS_OUTPUT.put_line(sno_||' '||sname_);
end if;
end loop;

end;


  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb
Tags: parse, sname, sno

Related Posts of Cursor using dynamic SQL

  • Log oracle10g training ☆ 5

    ------------ plsql oracle to sql is plsql language extension is based on language in the sql joined the circle and determine the logic. rn ----------- plsql block structure part of the statement declare ---- operative begin ------ rn exeption - Excep ...

  • Oracle District (2)

    In front of us a brief introduction about the scope of the district: We continue on the following HASH partition, LIST Zoning HASH Zoning: Create: Insert the five data; we query: Next on: LIST Zoning Insert the write data: And then proceed to query: ...

  • Oracle District (1)

    ORACLE District (a) Oracle would like to know the district has long been finally determined to get a get As the name suggests is to partition the data into a range of one to keep, the attention of the district and databases where the logic that the & ...

  • Packages and dynamic SQL cursor variables to use the joint

    The following three documents: Paper: package statement Paper II: the definition of package Three documents: Test document Results:

  • Detailed analysis of Statspack report

    2. Snapshot Snapshot threshold threshold should only be used for table stats $ sql_summary access to the SQL statement. Because each snapshot will collect a lot of data, each line represents a snapshot at the database access to a SQL statement, so st ...

  • Oracle to create data table space, the user, authorization, table, index, cluster

    / / Create a temporary table space (log files) create temporary tablespace test_temp tempfile 'E: \ oracle \ test_temp01.dbf' size 32m autoextend on next 32m maxsize 2048m extent management local; / / Create a data table space create tablespa ...

  • Oracle to create data table space, the user, authorization, tables, indexes, clusters

    / / Create a temporary table space (log files) create temporary tablespace test_temp tempfile 'E: \ oracle \ test_temp01.dbf' size 32m autoextend on next 32m maxsize 2048m extent management local; / / Create a data table space create tablespa ...

  • Introduction and analysis instrument Tkprof

    Tkprof is an Oracle trace file for analysis and have a more clear and reasonable instrument output executable. If a system is relatively low efficiency, a better method is by tracking the user's session and use tools to sort Tkprof formatted outp ...

  • Description and analysis tools Tkprof

    Tkprof is an Oracle trace file for analysis and have a more clear and reasonable tool for the output of the executable. If a system is relatively low efficiency, a better way is by tracking the user's session and use tools to sort Tkprof formatte ...

Leave a Reply

Recent
Recent Entries
Tag Cloud
Random Entries
Latest Comments