Board index » delphi » BDE doesn't let me create a trigger in database syntax

BDE doesn't let me create a trigger in database syntax

The following statement will not run because BDE thinks ':' is preceding a
parameter specifier:

CREATE OR REPLACE TRIGGER replica1.TRGR002FEC
  AFTER DELETE OR INSERT OR UPDATE OF
  CodFer, DatFer, DesFer ON replica1.R002FEC
REFERENCING
  OLD AS OLD
  NEW AS NEW
  FOR EACH ROW
DECLARE
  CHAVE_ID VARCHAR2(100);
  OPR VARCHAR2(4);
  TR VARCHAR2(100);
  WTRANS VARCHAR2(100);
  WSERV VARCHAR2(10);
BEGIN
  IF UPDATING THEN
    OPR:='UPDA';
  END IF;
  IF DELETING THEN
    OPR:='DELE';
  END IF;
  IF INSERTING THEN
    OPR:='INSE';
  END IF;
  TR:=DBMS_TRANSACTION.LOCAL_TRANSACTION_ID(FALSE);
  CHAVE_ID:=
    NVL(:OLD.CodFer, :NEW.CodFer)||';'||
    NVL(To_Char(:OLD.DatFer,'DD/MM/YYYY'),
To_Char(:NEW.DatFer,'DD/MM/YYYY'));
  SELECT CODTRA,IDESVR INTO WTRANS,WSERV FROM R400LCK WHERE TIPREG = 1;
  IF (WSERV IS NULL) THEN
    WSERV:='SUP';
  END IF;
  INSERT INTO R400TRS VALUES (TR,'R002FEC',CHAVE_ID,'replica1',WSERV,OPR);
END;

I've tried with double ':'. After executing with double ':', I tested the
trigger execution. Oracle bombed me with a syntax error. Then I entered
Oracle's Schema Manager, and took a look at the trigger code. The trigger,
in the Oracle Server, was with double ':'.
--> BDE seems to not convert the double ':' to a single ':'.

Delphi ignores the property 'ParamCheck' in this situation, because setting
the SQL property with ParamCheck "true" or "false" caused exactly the same
effect.

More information:
BDE Version: 5.00.
BDE Native Oracle Driver Version: 4.0.
Delphi Version: 3.0, Build 5.83.
Database Explorer Version: 4.00.

 

Re:BDE doesn't let me create a trigger in database syntax


This is only an idea:
Put a variable STring to get the query

var
   StrSql : string;
begin

StrSql := StrSql + ' ';
StrSql := StrSql + 'CREATE OR REPLACE TRIGGER replica1.TRGR002FEC';
StrSql := StrSql + '  AFTER DELETE OR INSERT OR UPDATE OF ';
...
...
...
StrSql := StrSql + 'NVL(' +#58 +'OLD.CodFer,' + #58+'NEW.CodFer)||';'||
...

QrX.Close;
QrX.Sql.Clear;
QrX.Sql.Add(StrSql);
QrX.Open;

the #58  is tha ASCII for ":"
Maybe this can help you
Because this help me for the " ' " i'm put #39
and is goog

Quote
Fernando Colombo wrote:
> The following statement will not run because BDE thinks ':' is preceding a
> parameter specifier:

> CREATE OR REPLACE TRIGGER replica1.TRGR002FEC
>   AFTER DELETE OR INSERT OR UPDATE OF
>   CodFer, DatFer, DesFer ON replica1.R002FEC
> REFERENCING
>   OLD AS OLD
>   NEW AS NEW
>   FOR EACH ROW
> DECLARE
>   CHAVE_ID VARCHAR2(100);
>   OPR VARCHAR2(4);
>   TR VARCHAR2(100);
>   WTRANS VARCHAR2(100);
>   WSERV VARCHAR2(10);
> BEGIN
>   IF UPDATING THEN
>     OPR:='UPDA';
>   END IF;
>   IF DELETING THEN
>     OPR:='DELE';
>   END IF;
>   IF INSERTING THEN
>     OPR:='INSE';
>   END IF;
>   TR:=DBMS_TRANSACTION.LOCAL_TRANSACTION_ID(FALSE);
>   CHAVE_ID:=
>     NVL(:OLD.CodFer, :NEW.CodFer)||';'||
>     NVL(To_Char(:OLD.DatFer,'DD/MM/YYYY'),
> To_Char(:NEW.DatFer,'DD/MM/YYYY'));
>   SELECT CODTRA,IDESVR INTO WTRANS,WSERV FROM R400LCK WHERE TIPREG = 1;
>   IF (WSERV IS NULL) THEN
>     WSERV:='SUP';
>   END IF;
>   INSERT INTO R400TRS VALUES (TR,'R002FEC',CHAVE_ID,'replica1',WSERV,OPR);
> END;

> I've tried with double ':'. After executing with double ':', I tested the
> trigger execution. Oracle bombed me with a syntax error. Then I entered
> Oracle's Schema Manager, and took a look at the trigger code. The trigger,
> in the Oracle Server, was with double ':'.
> --> BDE seems to not convert the double ':' to a single ':'.

> Delphi ignores the property 'ParamCheck' in this situation, because setting
> the SQL property with ParamCheck "true" or "false" caused exactly the same
> effect.

> More information:
> BDE Version: 5.00.
> BDE Native Oracle Driver Version: 4.0.
> Delphi Version: 3.0, Build 5.83.
> Database Explorer Version: 4.00.

Re:BDE doesn't let me create a trigger in database syntax


Hi

There is a Boolean property of TQuery called ParameterCheck. If you set this
to False the BDE will not scan your SQL and thus the colons will not be a
problem.

Regards, Frederick C. Wilt

Re:BDE doesn't let me create a trigger in database syntax


We always use double colons.  Although I didn't actually try to create a
trigger, doing an ExecSQL on the following PL/SQL code demonstrates that
either Delphi or the BDE removes one of the colons:

  declare
    v_dummy varchar2(20);
  begin
    v_dummy ::= 'Fred';
  end;

Does this work for you?  BTW, if I use a single colon I get the error "Field
'=' is of an unknown type."

V/R
Russell L. Smith
Russell_L._Sm...@mail.amsinc.com
American Management Systems (www.amsinc.com)

Quote
Fernando Colombo wrote in message <6r9bmc$kg...@forums.borland.com>...
>I've tried with double ':'. After executing with double ':', I tested the
>trigger execution. Oracle bombed me with a syntax error. Then I entered
>Oracle's Schema Manager, and took a look at the trigger code. The trigger,
>in the Oracle Server, was with double ':'.
>--> BDE seems to not convert the double ':' to a single ':'.

Other Threads