Subject Re: [ib-support] XCase and Interbase 6
Author Carlo Pettirossi
At 17.42 07/02/01 +0100, you wrote:
Carlo,

It looks suspiciously as if the SET TERM is not being called.

Before each trigger statement there should be something like

  SET TERM ^;

then end the trigger statement with

  END^ (not END;)

and then call

  SET TERM ;^

to reset the terminator.

Without the above ISQL believes you are trying to execute the following series
of statements:

CREATE TRIGGER T_BI_MyTable FOR MyTable BEFORE INSERT AS
DECLARE VARIABLE row_count INTEGER;


BEGIN
IF (new.IDSECONDTABLE is not null) THEN
    BEGIN
       SELECT COUNT(*)
              FROM  SECONDTABLE
              WHERE SECONDTABLE .ID = NEW.IDSECONDTABLE
              INTO :row_count ;


        IF (row_count = 0) THEN
        BEGIN
           EXCEPTION xc_i_res ;


        END
     END
END;

Not surprisingly, an error is thrown.

I'm surprised that XCase doesn't deal with this automatically - it is a pretty
fundamental aspect of Client/Server SQL scripting. Perhaps you have missed a
setting somewhere?

Paul
--

Hi Paul,

Thanks very much for your reply. The whole story is the following:

1) I generate the script with Xcase (at the end part of this message you'll find the script in which I included the SET TERM commands);

2) I test the script with the isql utility in IBConsole 1.0.0.326 connected to a database running on a local Linux server (that's why in my previous message I didn't include the set term command: because I set Options-Terminator=^ in the isql Edit menu);

3) If the script test succeeds, then I run isql directly on a remote Linux server through the following:

         SQL>connect /db/MYDB.gdb;
         SQL>input /db/sqls/myscript.sql

Unfortunately this procedure stops at the second step with the error message I wrote in my previous thread.
I also tried to ignore the IBConsole's error message, and run the script directly on the SQL> prompt, with (obviously) the same result.
Thanks very much in advance for your help

Carlo

------------------------------------------------------

set TERM^;
CREATE TABLE  MyTable
(
     ID INTEGER NOT NULL,
     IDSECONDTABLE INTEGER NOT NULL,
     FIELDNAME VARCHAR(50),
     FIELDVALUE BLOB SUB_TYPE 1 SEGMENT SIZE 80,
     FIELDLINK VARCHAR(100),
        CONSTRAINT RDB$PRIMARY56 PRIMARY KEY (ID)
)
^

CREATE TRIGGER T_BI_MyTable FOR MyTable BEFORE INSERT AS
DECLARE VARIABLE row_count INTEGER;
BEGIN

IF (new.IDSECONDTABLE is not null) THEN
   BEGIN
      SELECT COUNT(*)
             FROM  SECONDTABLE
             WHERE SECONDTABLE.ID = NEW.IDSECONDTABLE
             INTO :row_count ;
       IF (row_count = 0) THEN
       BEGIN
          EXCEPTION xc_i_res ;
       END
    END
END
^
set TERM ;^