|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with triggers please
hey there.
here's the situation: i'm updating the PROJECTID field of a row from the WORDPROCESSOR table . I would like all the records in this table , that have the same PARENTDOCUMENTID and PARENTDOCUMENTTYPE as the one of the updated record, to update their PROJECTID field with the value from the updated row. i think the trigger should be put on the AFTER UPDATE event on the WORDPROCESSOR TABLE .. if you think the trigger is a bad choice and i should have a stored procedure, or maybe the trigger should call a stored procedure.. please let me know... here's what i rigged up ...(in Ms SQL Server ) BEGIN DECLARE VARIABLE @DOCUMENTID AS INTEGER; DECLARE VARIABLE RecordRow CURSOR FOR SELECT DOCUMENTID FROM WORDDOCUMENTS WHERE UPDATE.PARENTDOCUMENTID = WORDDOCUMENTS.PARENTDOCUMENTID AND UPDATE.PARENTDOCUMENTTYPE = WORDDOCUMENTS.PARENTDOCUMENTTYPE; OPEN RecordRow FETCH NEXT FROM RecordRow INTO @DOCUMENTID WHILE @@FETCH_STATUS = 0 BEGIN UPDATE WORDDOCUMENTS SET WORDDOCUMENTS.PROJECTID = UPDATE.PROJECTID WHERE WORDDOCUMENTS.DOCUMENTID = @DOCUMENTID FETCH NEXT FROM RecordRow INTO @DOCUMENTID END PS: i'm using firebird 2.0 (i think ... ) Kind thanks |
|
#2
|
||||
|
||||
|
Quote:
__________________
My blog about OpenSource Databases PDF tutorials about OSS databases, DBMonster ... Please contribute to Open Source Development, fill bug reports!!! Developer Shed eSupport Commented my.ini/my.cnf (PLEASE ADD YOUR OWN CONFIG TRICK) Understanding SQL Joins An introduction to database normalization Natural or Surrogate key Custom ordering for your results Correlated and uncorrelated subqueries |
![]() |
| Viewing: Dev Shed Forums > Databases > Firebird SQL Development > Help with triggers please |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|