11/14/1995 { PURPOSE: The purpose of this code fragment is to demonstrate the use of a call to the BDE function DbiQExecDirect to avoid having the SQL statement parsed for parameters (i.e. anything preceded by a colon) In this case, it is being used to create an Oracle trigger, where :new refers to the new version of the updated record. Conversely, :old refers to the record before the update. Oracle also happens to use := as an assignment operator in triggers. } uses ..., DbiProcs, DbiTypes; procedure TForm1.Button1Click(Sender: TObject); var { We need a pchar, but the following declaration amounts to the same thing and saves us from having to explicitly allocate/deallocate the memory for it. } SQLString : array[0..255] of char; begin { Get database handle required by DbiQExecDirect. } Database1.open; { Convert SQL statement from Pascal string to null-terminated string. } StrPCopy(SQLString, 'CREATE OR REPLACE TRIGGER ab_update BEFORE UPDATE OF B ON swu.ab FOR EACH ROW BEGIN :new.B := :new.A; END;'); { Parameters: First parameter is the database handle, Second is the query type (qryLangSQL or qryLangQBE), Third is the null-terminated query string, Fourth is the handle to the result set (in this case there is none so we can pass nil) } DbiQExecDirect(Database1.Handle, qryLangSQL, SQLString, nil); end; end. SWU ID:CSxxxx