Re: DATABASE EXCLUSIVE Error
Posted in 1993
In <1v3432INNsfb@emory.mathcs.emory.edu> inf_bb@hermes1.sps.mot.com (informix users bb) writes:
>robert,
>the 'bug' is not necessarily with the 'DATABASE EXCLUSIVE' statement.
>im not sure why the following works, but i have tried it. changes
>to the original code are blocked with #####. i have also removed the
>sleep statements.
Well, if that works, you should be able to workaround the problem AND
make the program more efficient with:
>================================================================================
>{ error.4gl }
>DATABASE db_name
>MAIN
> WHENEVER ERROR STOP
> CALL do_first_cursor()
> CALL do_next_step()
> CALL do_first_cursor()
>END MAIN
>FUNCTION do_first_cursor()
>DEFINE tr_first_fld CHAR(12),
> tr_second_fld CHAR(35),
> tr_cnt INTEGER,
> wbuf CHAR(500)
>######
>DECLARE ins_cursor CURSOR FOR INSERT INTO new_table VALUES ( ?,? )
>######
> OPEN WINDOW w1 AT 5,5 WITH FORM "error" ATTRIBUTE(BORDER)
> CONSTRUCT wbuf ON
> table_name.acct_no,
> table_name.acctname,
> table_name.source,
> table_name.usr
> FROM
> sc_table_name.acct_no,
> sc_table_name.acctname,
> sc_table_name.source,
> sc_table_name.usr
> DELETE FROM new_table
> LET wbuf = "SELECT acct_no,acctname FROM db_name:table_name WHERE ",wbuf clipped
> PREPARE first_prep FROM wbuf
> DECLARE first_curs CURSOR FOR first_prep
> LET tr_cnt = 0
>######
>OPEN ins_cursor
>######
> FOREACH first_curs INTO tr_first_fld,tr_second_fld
>
>######
>PUT ins_cursor FROM tr_first_fld,tr_second_fld
>######
>
> LET tr_cnt = tr_cnt + 1
>
> END FOREACH
>######
>CLOSE ins_cursor
>######
> FREE first_prep
> ERROR "Inserted ",tr_cnt," record(s)"
> CLEAR SCREEN
> CLOSE WINDOW w1
>END FUNCTION
>FUNCTION do_next_step()
> ERROR "Setting Database to exclusive mode"
> DATABASE db_name EXCLUSIVE
> ERROR "Closing Database"
> CLOSE DATABASE
> ERROR "Setting Database to normal mode"
> DATABASE db_name
> DISPLAY sqlca.sqlawarn
>END FUNCTION
>================================================================================
It also strikes me as strange that Robert is freeing the prepared
statement, without closing or freeing the cursor. I doubt that this has
any effect on the EXCLUSIVE problem, but it might be worth experimenting
(I don't have a system to experiment with right now).
graeme
--
Disclaimer: The author's opinions are his own, and not necessarily
those of Pyramid Technology Ltd. or Pyramid Technology Inc.
---------------------------------------------------------------------------
-m------- Graeme Sargent Voice: +44 (0)252 373035
---mmm----- Senior Database Consultant Fax : +44 (0)252 373135
-----mmmmm--- Pyramid Technology Ltd. Telex: Tell who???
-------mmmmmmm- Farnborough, Hants GU14 7PL Email: graeme@pyra.co.uk
---------------------------------------------------------------------------
We have the technology. The tricky bit is learning how to use it.