dbTalk Databases Forums  

OpenQM trigger question

comp.databases.pick comp.databases.pick


Discuss OpenQM trigger question in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
pi3k
 
Posts: n/a

Default OpenQM trigger question - 08-12-2005 , 05:42 PM






Hey,
I'm trying to write a general trigger, to attach to multiple
dictionaries, that will keep track of any changes made. The only
problem that I'm having is that I can't figure out a way to get the
filename of the dictionary. Does anyone know how to do this? If this
isn't possible, does anyone know why QM doesn't send the filename to
the trigger? Here is the code I have so far:

SUBROUTINE WRITE.TRIGGER( MODE, ID, ITEM, ON.ERROR )

**VARS FOR TESTING
FILENAME = "CODES" ;*HOW DO YOU GET THIS?
**

OPEN "AUDITTRAIL" TO AUDIT.F ELSE ABORT "CANNOT OPEN AUDITFILE"
OPEN FILENAME TO FILE.F ELSE ABORT "CANNOT OPEN " : FILENAME

READ ENTRY FROM FILE.F, ID THEN
NAME = FILENAME : "*" : ID : "*" : DATE() : "*" : TIME()

WRITEV "MODE: " : MODE TO AUDIT.F, NAME, 1
WRITEV "OLD ITEM: " : ENTRY<1> TO AUDIT.F, NAME, 2
WRITEV "NEW ITEM: " : ITEM TO AUDIT.F, NAME, 3
WRITEV @LOGNAME TO AUDIT.F, NAME, 4
END
END


Thanks for your help


Reply With Quote
  #2  
Old   
Tom deL
 
Posts: n/a

Default Re: OpenQM trigger question - 08-13-2005 , 09:17 AM






Hello again pi3k,

Try the code below. Disclaimer: *NOT* thoroughly tested.

To answer your question, two things:

1. You forgot to pass the file handle.
2. From the file handle, much info is available through FILEINFO()

Some changes in the below code not relating to your question:

1. If creating a new item, no logging would occur. You may have planned
this.
2. I added LOWER() assuming that you wanted a record of changes, the
way it was, a dictionary item for instance would overwrite the
audit item's attributes.
3. I didn't address adding text for Delete, just the mode.

*** Begin test code:

SUBROUTINE WRITE.TRIGGER( MODE, ID, ITEM, ON.ERROR, FH)

$INCLUDE KEYS.H

**VARS FOR TESTING
* FILENAME = "CODES" ;*HOW DO YOU GET THIS?
* Try this:
FILENAME = FILEINFO(FH, FL$VOCNAME)
PATH = FILEINFO(FH, FL$PATH) ;* Make sure you pick up the DICT
**

OPEN "AUDITTRAIL" TO AUDIT.F ELSE ABORT "CANNOT OPEN AUDITFILE"
OPENPATH PATH TO FILE.F ELSE ABORT "CANNOT OPEN " : FILENAME

READ ENTRY FROM FILE.F, ID THEN ;* Modifying or Deleting existing
OLD.ITEM = LOWER(ENTRY) ;* Make it fit in one attribute
ELSE ;* Must be a new item
OLD.ITEM = "New Item Added"
END
NAME = FILENAME : "*" : ID : "*" : DATE() : "*" : TIME()

WRITEV "MODE: " : MODE TO AUDIT.F, NAME, 1
WRITEV "OLD ITEM: " : OLD.ITEM TO AUDIT.F, NAME, 2
WRITEV "NEW ITEM: " : LOWER(ITEM) TO AUDIT.F, NAME, 3
WRITEV @LOGNAME TO AUDIT.F, NAME, 4

END


Reply With Quote
  #3  
Old   
pi3k
 
Posts: n/a

Default Re: OpenQM trigger question - 08-13-2005 , 05:43 PM



Wow, thank you for your help yet again Tom. That code worked great (
there needs to be and END ELSE on line 17 ) and does exactly what I
needed it for. I was wondering if you know of a place that has some
better documentation on openqm because the pdf's from openqm.com don't
always contain enough detail on functions. Triggers are a good example
because the docs ( REF.PDF ) don't even tell you that the subroutine
takes in 4 or 5 parameters. Or I could just keep posting to the forums
because the level of help I've recieved is better than some of the
better forums, gentoo linux for example.
Thanks again.


Reply With Quote
  #4  
Old   
Tom deL
 
Posts: n/a

Default Re: OpenQM trigger question - 08-13-2005 , 07:27 PM



Hi pi3k,

Quote:
Wow, thank you for your help yet again Tom. That code worked great (
Happy to be able to help.

Quote:
there needs to be and END ELSE on line 17 ) and does exactly what I
Oops! Too much in php these days :-\

Quote:
needed it for. I was wondering if you know of a place that has some
better documentation on openqm because the pdf's from openqm.com don't
always contain enough detail on functions. Triggers are a good example
because the docs ( REF.PDF ) don't even tell you that the subroutine
Download all of the PDF's - the ref.pdf I think is called 'quick
reference'. There is an excellent description of triggers in the intro
pdf (intro.pdf maybe?)

Quote:
takes in 4 or 5 parameters. Or I could just keep posting to the forums
because the level of help I've recieved is better than some of the
better forums, gentoo linux for example.
Thanks again.


Reply With Quote
  #5  
Old   
pi3k
 
Posts: n/a

Default Re: OpenQM trigger question - 08-13-2005 , 10:54 PM



Ah, ya if I'd read all the way to the bottom of the intro I would have
seen that one . pg 38 of INTRO.PDF for anyone else who wants to
know.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.