Re: setjmp()/longjmp() and RDS
Posted in 1995
} Subject: setjmp()/longjmp() and RDS } Date: 3 Jan 1995 17:41:50 GMT } Reply-To: rb@argon.in-ulm.de (Richard Bahcic) } Organization: Private Site } } To all IPC and Trigger-Fans! } } Our Configuration and installation-order: } SCO 3.2.4 } Informix SQL 4.11.UC1 } Informix RDS 4.11.UC1 } Informix ID 4.11.UC1 } Informix Online 5.01.UD2 } } Please have a look at the following scenario: } } 1. There is a table called `lager' representing the real-world stockroom } (german Lager). } In this stockroom is beside others the article `screw' and the actual amount. } 2. There is a module which allows a user to create a delivery note (german } Lieferschein). } 3. The user X now wants to sell and deliver some amount of screws. ... omitted ... } 4. While the user X has the information on the screen and the purchaser at the } telefon, he decides that the amount of this article the purchaser wants to buy } is enough. } 5. While speaking with the purchaser, user Y unfortunately sold the whole } amount of the screws. } 6. At the moment user Y's process updates the table `lager', we want user X } to inform about the change. We want to tell him immediately, that the } information on the screen is no longer valid. } } And now the big question is: } WHAT IS THE MOST-EFFECTIVE AND EASIEST-TO-IMPLEMENT STRATEGY TO IMPLEMENT } THIS `Real-Time'-Database-Applikation with RDS? } } There are several starting points, we think: } } 1. We heard and read something about `triggers', which are said to be related } to tables. ... omitted ... } } 2. We have some experience with the C-function-pair setjmp()/longjmp() and } so we think it should be possible to implement a complex mechanism like the } following: ... omitted ... } } The questions here are: } 1. Could the implementation be done without setjmp()/longjmp()??? } 2. DO THESE C-routines AND THE RDS-Interpreter work together in the outlined } way???? or is it completely impossible for both to comunicate in this } asynchronous manner???? } } So long, } Richard } -- } Richard Bahcic Email: rb@argon.in-ulm.de 1. Triggers will NOT do what you want. They work within the database engine and are not intended to communicate with user processes. 2. The setjmp()/longjmp() technique you describe looks like it would work, but it is *very* complicated and error prone. 3. I think your best approach is to use the record locking mechanisms in the database: a. When your application accesses the number of screws, use a cursor with the SELECT ... FOR UPDATE clause. Syntax is defined under DECLARE (not SELECT) in my reference manual. This puts an exclusive lock on the row, which prevents user Y from fetching it while user X is looking at it. b. This has concurrency implications for your application, of course, which are more severe if your database uses transactions. The reference manual discusses this rather well. Regards, Alan ___________________________ ______________________| R. Alan Popiel |__________________________ \\ Internet: | Martin Marietta, SLS | / \\ alan@den.mmc.com | P.O. Box 179, M/S 3810 | Std disclaimers apply. / )Voice: | Denver, CO 80201-0179 USA | ( / 303-977-9998 |___________________________| (But you knew that!) \\ /________________________) (____________________________\\