pl/sql %type和%rowtype區別
一:%Type功能
SQL> set serveroutput on
SQL> select * from temp_table;
SQL> select * from temp_table;
NUM_COL CHAR_COL
---------- --------------------------------------------------
1 insert one
2 insert two
3 insert three
---------- --------------------------------------------------
1 insert one
2 insert two
3 insert three
SQL> declare
2 v_numcol temp_table.num_col%type;
3 v_charcol temp_table.char_col%type;
4 cursor c_alltable is
5 select * from temp_table;
6
7 begin
8 open c_alltable;
9 loop
10 fetch c_alltable into v_numcol,v_charcol;
11 exit when c_alltable%notfound;
12 dbms_output.put_line(v_numcol);
13 dbms_output.put_line(v_charcol);
14 end loop;
15 end;
16 /
1
insert one
2
insert two
3
insert three
2 v_numcol temp_table.num_col%type;
3 v_charcol temp_table.char_col%type;
4 cursor c_alltable is
5 select * from temp_table;
6
7 begin
8 open c_alltable;
9 loop
10 fetch c_alltable into v_numcol,v_charcol;
11 exit when c_alltable%notfound;
12 dbms_output.put_line(v_numcol);
13 dbms_output.put_line(v_charcol);
14 end loop;
15 end;
16 /
1
insert one
2
insert two
3
insert three
PL/SQL 過程已成功完成。
SQL>
二:%RowType功能
SQL> declare
2
3 cursor c_alltable is
4 select * from temp_table;
5
6 v_tablerecord c_alltable%rowtype;
7
8 begin
9 open c_alltable;
10 loop
11 fetch c_alltable into v_tablerecord;
12 exit when c_alltable%notfound;
13 dbms_output.put_line(v_tablerecord.num_col);
14 dbms_output.put_line(v_tablerecord.char_col);
15 end loop;
16 end;
17 /
1
insert one
2
insert two
3
insert three
2
3 cursor c_alltable is
4 select * from temp_table;
5
6 v_tablerecord c_alltable%rowtype;
7
8 begin
9 open c_alltable;
10 loop
11 fetch c_alltable into v_tablerecord;
12 exit when c_alltable%notfound;
13 dbms_output.put_line(v_tablerecord.num_col);
14 dbms_output.put_line(v_tablerecord.char_col);
15 end loop;
16 end;
17 /
1
insert one
2
insert two
3
insert three
PL/SQL 過程已成功完成。
SQL>
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/16400082/viewspace-754287/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ORACLE中%TYPE和%ROWTYPE的使用Oracle
- PL/SQL中command window與SQL window的區別SQL
- TypeScript 裡 interface 和 type 的區別TypeScript
- <button>和<input type=“button“> 的區別
- <input type="button">和<button>的區別
- PL/SQL DEVELOPER工具與toad工具的區別SQLDeveloper
- Go 中 type var string 和 type var = string 的區別Go
- python的type和isinstance的區別Python
- Pl/SQL 自定義型別SQL型別
- pl/sql記錄型別SQL型別
- pl/sql集合型別(一)SQL型別
- oracle taf type型別為session和select的區別Oracle型別Session
- MYSQL和SQL的區別MySql
- pl/sql集合型別_varray(二)SQL型別
- %rowtype
- Oracle 和 SQL Server 個別小區別OracleSQLServer
- PL/SQL Profiler 和SQL Developer 報表SQLDeveloper
- TypeScript中,interface和type使用上有什麼區別?TypeScript
- SQL中where和on的區別SQL
- sql語句中#{}和${}的區別SQL
- V$SQL 和V$SQLAREA區別SQL
- MS SQL Server和MySQL區別ServerMySql
- PLSQL Language Reference-PL/SQL資料型別-SQL資料型別-使用者定義的PL/SQL子型別SQL資料型別
- PLSQL Language Referenc-PL/SQL集合和記錄-集合型別SQL型別
- 在PL/SQL中使用日期型別SQL型別
- PL/SQL Developer 6.0.4.906特別版SQLDeveloper
- PL/SQL複合資料型別SQL資料型別
- Typescript 中的 interface 和 type 到底有什麼區別TypeScript
- nth-of-type()和nth-child()選擇器的區別
- SQL語句中exists和in的區別SQL
- SQL語句中not in 和not exist的區別SQL
- v$sql和v$sqlarea的區別SQL
- SQL中IN和EXISTS用法的區別SQL
- 【SQL】Oracle SQL join on語句and和where使用區別SQLOracle
- PLSQL Language Reference-PL/SQL資料型別-SQL資料型別-LONG和LONG RAW變數SQL資料型別變數
- PL/SQL中char型別的暗門SQL型別
- PL/SQLSQL
- python中isinstance()和type()有什麼區別?如何使用?Python