Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UPDATE
- TABLE1 a,
- TABLE2 b
- SET
- a.COL1 = 'VALUE'
- WHERE
- a.FK = b.PK
- AND b.COL2 IN ('SET OF VALUES')
- UPDATE
- (
- SELECT
- a.COL1
- FROM
- TABLE1 a,
- TABLE2 b
- WHERE
- a.FK = b.PK
- AND b.COL2 IN ('SET OF VALUES')
- ) update_tbl
- SET
- update_tbl.COL1 = 'VALUE'
- UPDATE
- TABLE1 update_tbl
- SET
- update_tbl.COL1 = 'VALUE'
- WHERE
- EXISTS (
- SELECT
- 1
- FROM
- TABLE1 a
- TABLE2 b
- WHERE
- a.FK = b.PK
- AND b.COL2 IN ('SET OF VALUES')
- AND update_tbl.PK = a.PK
- )
- UPDATE TABLE1 a
- SET a.COL1 = 'VALUE'
- WHERE a.FK IN
- ( SELECT b.PK FROM TABLE2 b
- WHERE b.COL2 IN ('SET OF VALUES')
- )
- UPDATE
- (
- SELECT
- a.COL1, a.PKCOL
- FROM
- TABLE1 a,
- TABLE2 b
- WHERE
- a.FK = b.PK
- AND b.COL2 IN ('SET OF VALUES')
- ) update_tbl
- SET
- update_tbl.COL1 = 'VALUE'
- UPDATE
- TABLE1
- SET
- COL1 = 'VALUE'
- WHERE
- ROWID in
- (
- SELECT
- a.rowid
- FROM
- TABLE1 a,
- TABLE2 b
- WHERE
- a.FK = b.PK
- AND b.COL2 IN ('SET OF VALUES')
- )
- UPDATE
- TABLE1 update_tbl
- SET
- update_tbl.COL1 = 'VALUE'
- WHERE
- (update_tbl.PK1, update_tbl.pk2) in(
- select some_field1, some_field2
- from some_table st
- where st.some_fields = 'some conditions'
- );
- DECLARE
- /* Output variables to hold the result of the query: */
- a T1.e%TYPE;
- b T2.f%TYPE;
- c T2.g%TYPE;
- /* Cursor declaration: */
- CURSOR T1Cursor IS
- SELECT T1.e, T2.f, T2.g
- FROM T1, T2
- WHERE T1.id = T2.id AND T1.e <> T2.f
- FOR UPDATE;
- BEGIN
- OPEN T1Cursor;
- LOOP
- /* Retrieve each row of the result of the above query
- into PL/SQL variables: */
- FETCH T1Cursor INTO a, b;
- /* If there are no more rows to fetch, exit the loop: */
- EXIT WHEN T1Cursor%NOTFOUND;
- /* Delete the current tuple: */
- DELETE FROM T1 WHERE CURRENT OF T1Cursor;
- /* Insert the reverse tuple: */
- INSERT INTO T1 VALUES(b, a);
- /* Here is my stuff using the variables to update my table */
- UPDATE T2
- SET T2.f = a
- WHERE T2.id = c;
- END LOOP;
- /* Free cursor used by the query. */
- CLOSE T1Cursor;
- END;
- .
- run;
Add Comment
Please, Sign In to add comment