torturedmind
Programmer
Good morning to all.
I have this "regular" method of updating an Oracle table. Let's just call it Method 1:
1. SET MULTI LOCKS ON
2. Connect to DB using SQLCONNECT()
3. Open the table using SQLEXEC()
4. Set buffering to table buffering optimistic using CURSORSETPROP()
5. Update several thousand records.
6. Commit changes using TABLEUPDATE()
Method 2, on the other hand, uses a different way of updating.
1. Connect to DB using SQLCONNECT()
2. Open and Oracle table (let's call it TBL1) using SQLEXEC() into a resulting READ-WRITE cursor (let's call the cursor CUR1)
3. Edit values of several thousand records in CUR1
4. Update the back-end table TBL1 using SCAN...ENDSCAN like so:
I use Method 1. I know someone who uses Method 2. Why is Method 1 way slower than Method 2? I'm almost tempted to use Method 2 but I know it just causes inefficiency and high "hard-parses" on the DB side.
TIA
kilroy
philippines
"Once a king, always a king. But being a knight is more than enough."
I have this "regular" method of updating an Oracle table. Let's just call it Method 1:
1. SET MULTI LOCKS ON
2. Connect to DB using SQLCONNECT()
3. Open the table using SQLEXEC()
4. Set buffering to table buffering optimistic using CURSORSETPROP()
5. Update several thousand records.
6. Commit changes using TABLEUPDATE()
Method 2, on the other hand, uses a different way of updating.
1. Connect to DB using SQLCONNECT()
2. Open and Oracle table (let's call it TBL1) using SQLEXEC() into a resulting READ-WRITE cursor (let's call the cursor CUR1)
3. Edit values of several thousand records in CUR1
4. Update the back-end table TBL1 using SCAN...ENDSCAN like so:
Code:
SCAN && the cursor
SQLEXEC(db_conn, "UPDATE tbl1 SET f1 = " + ;
fld1 + ;
", f2 = " + ;
<blah><blah> + ;
" FOR tbl1.ndx_fld = " + )
SQLCOMMIT(db_conn)
ENDSCAN
I use Method 1. I know someone who uses Method 2. Why is Method 1 way slower than Method 2? I'm almost tempted to use Method 2 but I know it just causes inefficiency and high "hard-parses" on the DB side.
TIA
kilroy
philippines
"Once a king, always a king. But being a knight is more than enough."