Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Used by dbms_sql to create a generic dynamic sql

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

/ * calling dbms_sql requires five steps:   1. Open a cursor   2. Analyze the statement to be executed   3. Bind any input variables that may be needed   4. Execute statement   5. Close cursors * / DECLARE CUR PLS_INTEGER: = DBMS_SQL.OPEN_CURSOR;-- open cursors for processing, cur returns system cursors id COLS DBMS_SQL.DESC_TAB -- DBMS_SQL.DESC_TAB: collection type NCOLS PLS_INTEGER;BEGIN DBMS_SQL.PARSE (CUR, 'select * from ma_ctl', DBMS_SQL.NATIVE) used to receive data parsed by dbms_sql;-- parsing statement .DBMS _ SQL.NATIVE: get oracle SQL version-- DBMS_OUTPUT.PUT_LINE (DBMS_SQL.NATIVE) / * the SQL version of the database to be used to parse the sql statement, with V6 and native, and use the native option when the connected ORACLE database version is uncertain. DBMS_SQL.NATIVE: the relationship between constant name and value. Name Data Type Value V6 INTEGER 0 native INTEGER 1 v7 INTEGER 2 * /-- retrieves the column information, assigns the number of fields to the second parameter variable NCOLS, and puts the data into the third parameter COLS collection variable DBMS_SQL.DESCRIBE_COLUMNS (CUR, NCOLS, COLS); FOR I IN 1.. NCOLS LOOP DBMS_OUTPUT.PUT_LINE (COLS (I). COL_NAME);-- COL_NAME is an attribute of COLS and holds the field name END LOOP; DBMS_SQL.CLOSE_CURSOR (CUR); END

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report