Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Basic Trigger Handling? Some condition are fail to use!
Message
From
09/03/1998 05:09:30
 
 
To
09/03/1998 01:30:36
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00083299
Message ID:
00083314
Views:
21
>I would like to make a set of "k" + OldTableName to
>carry all deleted data information.
>My trigger will call an extenal kMover.prg and the coding will be:
>
* kMover.prg Make a copy to 'kTable' before delete record!
* As the original Table can pack at anytime if necessary!
LPARAMETERS oTable, oKey, oKey2
LOCAL kTable, kKey

IF TYPE("gcUser") = "U"
	PUBLIC gcUser && define public Variable to know who Does it!
	gcUser = ""
	DO WHILE EMPTY(gcUser)
           do form requestUser to gcUser
	ENDDO
ENDIF

USE &oTable AGAIN IN 0 SHARED
SELECT &oTable
kKey = ALLTRIM(&oKey)
kTable = "k" + Alltrim(oTable)

IF USED([&kTable])
	USE IN &kTable
ENDIF

IF !FILE([&kTable]+".dbf")	&& either lost file or new create
	SELECT &oTable
	COPY STRUCTURE TO &kTable

	OPEN DATABASE LOVELYHM SHARED
	ADD TABLE &kTable
*
*       Problem at this point as Cyclic in using table!!
*       but no problem when developing!! +_+"
*       Either I comment the above two coding or not still fail!
*

	ALTER TABLE &kTable;
		ADD COLUMN UsedTime T NOT NULL;
			DEFAULT DATETIME() ;
		ADD COLUMN UsedBy C(40) NULL;
			DEFAULT gcUser ;
		ADD COLUMN isDelete L NULL;
		ADD PRIMARY KEY UsedTime TAG UsedTime

*       Additional Fields for recording the User accesstime, who and action!

	USE IN &kTable
ENDIF

use &kTable AGAIN in 0 shared  
*
*       Another Error Above here when run it in execute file or
*       in other .prg
*       But sure work when in development Browse!! +_+"

SELECT &kTable
Append from &oTable for &oKey = "&kKey"
IF !DELETED()
	SELECT &kTable
	REPLACE isDelete WITH .T. 
ENDIF
use in &kTable
if !used([&oTable])
	USE &oTable again in 0 shared
ENDIF
Previously, I have make a version on Recno() but still error on
trigger because the pointer try to move around!!
* Previously passing oTable, oRecno
...
Append from oTable for Recno() = oRecno

Of cos, if possible, add datetime() field to mark when delete and
also if possible, take out the Novell system "USER" Variable
to know who did it it better. GETENV("USER")

But firstly I fail to Move it to another table when triggering!

So, any suggestions to do so instead of above .prg?

Now, I will take a look on avoiding if kTable not exist.
I think this part I can do it but still sth wrong! ~_~"
but really I have no idea to copy current record to another table.

Sorry for repost but I give more detail on it!
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Reply
Map
View

Click here to load this message in the networking platform