Re: Locked record
Posted in 1998
Topics: Stored Procedures & SPL, Error Codes & Troubleshooting, Connectivity: ESQL/C, 4GL & Embedded SQL, Transactions, Locking & Isolation
One other idea that's verbose, but might help:
Rather than handling the lock through a SET LOCK MODE statement, you can do
something like the following:
WHILE TRUE
WHENEVER ERROR CONTINUE
FETCH curs INTO curs_rec.*
WHENEVER ERROR STOP
IF ( SQLCA.SQLCODE = 0 ) THEN
# Fetch successful.
EXIT WHILE
ELSE
IF ( SQLCA.SQLCODE = 100 ) THEN
# Out of rows to fetch.
EXIT WHILE
ELSE
IF ( SQLCA.SQLCODE = -244 ) THEN
# Locked. Perform lock logging into other table,
# display message on screen, or whatever, then retry.
SLEEP 2
CONTINUE WHILE
ELSE
# Non-244 SQL Error. Exit program.
CALL graceful_exit (SQLCA.SQLCODE)
EXIT PROGRAM (SQLCA.SQLCODE)
END IF
END IF
END IF
END WHILE
This lets you put in custom code to handle the error at the point it's
affecting you. You can also put in a counter for limiting retries, check
for any SQL or ISAM error through IF or CASE statements, and display
"waiting..." messages to the user.
Note that the WHILE loop here is solely for FETCHing, not for processing the
data that's fetched.
This also works great for INSERT/UPDATE/DELETE statements that may have
concurrency problems.
Matt Pletcher
Whole Foods Market
Richard Thomas wrote:
> Marek,
>
> Try putting a SET LOCK MODE TO WAIT n ; statement in the 4GL. The
> problem is that the index-row (and the row itself) is locked for the
> term of the transaction that your second user is performing. If the 4GL
> doesn't do any updating, (ie if it's just a report), try adding a SET
> ISOLATION TO DIRTY READ to it (if that isolation level is appropriate to
> your application).
>
> You could also try changing the LOCK MODE of the offending table to ROW,
> but I don't think that is your problem here. It looks to me like the
> index is being read by the 4GL, and crashing when it encounters a lock
> held by another user.
>
> cheers
> RET
>
> > ----------
> > From: Marek Miloszewski
> > Sent: Thursday, 27 August 1998 6:39 PM
> > To: informix-list@iiug.org
> > Subject: Locked record
> >
> > Hi all,
> >
> > we have a problem with one of our application. Sometimes when somebody
> > is
> > inserting new record into one of the tables, other person has a
> > problem with
> > entering the application. Here is a message displayed:
> >
> > Program stopped at "function.4gl", line number 166.
> > SQL statement error number -244.
> > Could not do a physical-order read to fetch next row.
> > SYSTEM error number -107.
> > ISAM error: record is locked.> >
> > The problem is that it does not happened continuously. One day yes,
> > another
> > not. Our application producer said this is problem with our Informix
> > configuration. But other programs work properly! I don't know were to
> > look
> > for error...
> >
> > Any suggestions?
> >
> > Marek
> >
> > -------------------------------------------------------------
> > Zaklad Energetyczny Szczecin SA
> > ul. Malczewskiego 5/7, 70-952 Szczecin, Poland
> > tel: (48 91) 424.00.71 w.5216, fax: (48 91) 22.56.28
> > marek.miloszewski@zes.szczecin.pl
> > -------------------------------------------------------------
> > memorek@polbox.com
> > http://www.polbox.com/m/memorek
> > -------------------------------------------------------------
> >