Board index » delphi » Strange error !!!!!!!!!

Strange error !!!!!!!!!

Hello,

can anybody write me what in my SQL string is wrong :

   DMod.Empty_Query.SQL.Text := '';
   DMod.Empty_Query.SQL.Add('CREATE TRIGGER '+Trim(DB_Pav)+'_UPDATE_REPL FOR
'+Trim(DB_Pav)+' AFTER UPDATE AS');
   DMod.Empty_Query.SQL.Add('DECLARE VARIABLE AAA INTEGER;');
   DMod.Empty_Query.SQL.Add('BEGIN');
   DMod.Empty_Query.SQL.Add('IRSK = 0;');
   DMod.Empty_Query.SQL.Add('IF( USER <> "REPL" ) THEN');
   DMod.Empty_Query.SQL.Add('BEGIN');
   DMod.Empty_Query.SQL.Add('SELECT COUNT(*) FROM REPL_LOG');
   DMod.Empty_Query.SQL.Add('WHERE (REPL_LOG.DB_ANR =
OLD.'+Trim(Lauko_Pav)+') AND (REPL_LOG.TIPAS="U")');
   DMod.Empty_Query.SQL.Add('INTO :AAA;');
   DMod.Empty_Query.SQL.Add('IF (:AAA = 0) THEN');
   DMod.Empty_Query.SQL.Add('BEGIN');
   DMod.Empty_Query.SQL.Add('INSERT INTO REPL_LOG(DB_Pav, DB_ANr, Tipas,
Padaliniai, ANR_Pav)');
   DMod.Empty_Query.SQL.Add('VALUES("'+Trim(DB_Pav)+'",
NEW.'+Trim(Lauko_Pav)+', "U","", "'+Trim(ANr_Pav)+'");');
   DMod.Empty_Query.SQL.Add('END');
   DMod.Empty_Query.SQL.Add('END');
   DMod.Empty_Query.SQL.Add('END');
   DMod.Empty_Query.SQL.ExecSQL;

When I execute SQL I receive message :
    General SQL error.
    Token unknown - line 9 char 4
    .?

If I write this via SQL explorer Enter SQL everything is OK.

Thanks.

Jarka

 

Re:Strange error !!!!!!!!!


FIRST :
Change
DMod.Empty_Query.SQL.Text := '';
 to
DMod.Empty_Query.SQL.Clear; !!
Maybe that already helps...

Does your TQuery.SQL property already contain an SQL- statement?

it seems you're writing some Replication- program. How Far did you get? I
could need sth. like that !! Please Mail me!
mostrow...@bedruck.de

Greetings, M. Ostrowski

Jaroslavas Akmanovas <jaroslavas_akmano...@intelsoftas.lt> schrieb in im
Newsbeitrag: 8616j4$e0...@bornews.borland.com...

Quote
> Hello,

> can anybody write me what in my SQL string is wrong :

>    DMod.Empty_Query.SQL.Text := '';
>    DMod.Empty_Query.SQL.Add('CREATE TRIGGER '+Trim(DB_Pav)+'_UPDATE_REPL

FOR '+Trim(DB_Pav)+' AFTER UPDATE AS');
Quote
>    DMod.Empty_Query.SQL.Add('DECLARE VARIABLE AAA INTEGER;');
>    DMod.Empty_Query.SQL.Add('BEGIN');
>    DMod.Empty_Query.SQL.Add('IRSK = 0;');
>    DMod.Empty_Query.SQL.Add('IF( USER <> "REPL" ) THEN');
>    DMod.Empty_Query.SQL.Add('BEGIN');
>    DMod.Empty_Query.SQL.Add('SELECT COUNT(*) FROM REPL_LOG');
>    DMod.Empty_Query.SQL.Add('WHERE (REPL_LOG.DB_ANR =

OLD.'+Trim(Lauko_Pav)+') AND (REPL_LOG.TIPAS="U")');
Quote
>    DMod.Empty_Query.SQL.Add('INTO :AAA;');
>    DMod.Empty_Query.SQL.Add('IF (:AAA = 0) THEN');
>    DMod.Empty_Query.SQL.Add('BEGIN');
>    DMod.Empty_Query.SQL.Add('INSERT INTO REPL_LOG(DB_Pav, DB_ANr, Tipas,

Padaliniai, ANR_Pav)');
Quote
>    DMod.Empty_Query.SQL.Add('VALUES("'+Trim(DB_Pav)+'",

NEW.'+Trim(Lauko_Pav)+', "U","", "'+Trim(ANr_Pav)+'");');
Quote
>    DMod.Empty_Query.SQL.Add('END');
>    DMod.Empty_Query.SQL.Add('END');
>    DMod.Empty_Query.SQL.Add('END');
>    DMod.Empty_Query.SQL.ExecSQL;

> When I execute SQL I receive message :
>     General SQL error.
>     Token unknown - line 9 char 4
>     .?

> If I write this via SQL explorer Enter SQL everything is OK.

> Thanks.

> Jarka

Re:Strange error !!!!!!!!!


Sorry, That wasn't the solution, exchange line 9 and 8 and everything will
be alright ...

M.Ostrowski

Matthias Ostrowski <MOstrow...@bedruck.de> schrieb in im Newsbeitrag: ...

Quote
> FIRST :
> Change
> DMod.Empty_Query.SQL.Text := '';
>  to
> DMod.Empty_Query.SQL.Clear; !!
> Maybe that already helps...

> Does your TQuery.SQL property already contain an SQL- statement?

> it seems you're writing some Replication- program. How Far did you get? I
> could need sth. like that !! Please Mail me!
> mostrow...@bedruck.de

> Greetings, M. Ostrowski

That' what SQL looks like

CREATE TRIGGER '+Trim(DB_Pav)+'_UPDATE_REPL FOR '+Trim(DB_Pav)+' AFTER
UPDATE AS
DECLARE VARIABLE AAA INTEGER;
BEGIN
  IRSK = 0
  IF( USER <> "REPL" ) THEN
  BEGIN
    SELECT COUNT(*) FROM REPL_LOG
    WHERE (REPL_LOG.DB_ANR =  OLD.'+Trim(Lauko_Pav)+') AND
(REPL_LOG.TIPAS="U")   <--
    INTO :AAA;
<--
    IF (:AAA = 0) THEN
      BEGIN
      INSERT INTO REPL_LOG(DB_Pav, DB_ANr, Tipas, Padaliniai, ANR_Pav)
      VALUES("'+Trim(DB_Pav)+'", NEW.'+Trim(Lauko_Pav)+', "U","",
"'+Trim(ANr_Pav)+'")
    END
  END
END

Re:Strange error !!!!!!!!!


If this is Oracle, remove the ':' from AAA.  Anything else, probably the
same.

John

Other Threads