It is possible to make inserts and updates with records. This records can be rowtype of a table or a user defined data type. Let's show with an example:
Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
Connected as SYS
SQL>
SQL> drop table t;
Table dropped
SQL> create table t(i number, v varchar2(16));
Table created
SQL> DECLARE
2 r_t t%ROWTYPE;
3 TYPE t_t IS RECORD(
4 i PLS_INTEGER
5 ,v VARCHAR2(32));
6 v_t t_t;
7 BEGIN
8 r_t.i := 1;
9 r_t.v := 'First';
10
11 v_t.i := 2;
12 v_t.v := 'Second';
13
14 INSERT INTO t VALUES r_t;
15 INSERT INTO t VALUES v_t;
16
17 r_t.v := 'Not First';
18 UPDATE t SET ROW = r_t WHERE i = r_t.i;
19 COMMIT;
20
21 END;
22 /
PL/SQL procedure successfully completed
SQL> SELECT * FROM t;
I V
---------- ----------------
1 Not First
2 Second
SQL>
No comments:
Post a Comment