sql task doesn't execute script

2001-11-01 Thread Gauti Reynisson

Hi!

I have a problem with executing a sql script through the sql task.

When I come to this decleration in the script:


create or replace trigger addresses_trg
before insert on addresses
for each row
begin
   if :new.address_id is null then  
 select addresses_seq.nextval
 into :new.address_id
 from dual;
   end if;
end;
/

... it fails and says

  [sql] SQL: create or replace trigger cls_addresses_bir_trg before
insert on cls_addresses_tb for each row begin if :new.address_id is null
then  
 select addresses_seq.nextval
 into :new.address_id
 from dual;
  [sql] -1 rows affected
  [sql] SQL: end if;
  [sql] Failed to execute: end if

BUILD FAILED

All tables and sequences have been created when this part is executed.

Am I doing something wrong?

cheers,

Gauti

PS. my ant task looks like:

sql driver=oracle.jdbc.OracleDriver
url=jdbc:oracle:thin:@host:1521:orcl userid=user password=pass
transaction src=${database}/scriptName.sql/
classpath
pathelement
location=${lib}/oracle/jdbc/classes12.jar/
/classpath
/sql


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: sql task doesn't execute script

2001-11-01 Thread Johan Adelöw

You can not use the sql task to perform operations like this cinsce the task
is only designed for single sqlstatements and launches the code ar the first
;. 

In your case 

create or replace trigger addresses_trg
before insert on addresses
for each row
begin
   if :new.address_id is null then  
 select addresses_seq.nextval
 into :new.address_id
 from dual;
   end if;

which makes no sence to oracle. By using the delimiter option you can change
the behaviour to launch at / on a single row. Thus it is possible to launch
block statements.

I have made a modified sqltask though, that is made especially to handle all
kinds of Oracle statements that I can send you if you like. 

/Johan

-Original Message-
From: Gauti Reynisson [mailto:[EMAIL PROTECTED]]
Sent: den 1 november 2001 14:21
To: [EMAIL PROTECTED]
Subject: sql task doesn't execute script


Hi!

I have a problem with executing a sql script through the sql task.

When I come to this decleration in the script:


create or replace trigger addresses_trg
before insert on addresses
for each row
begin
   if :new.address_id is null then  
 select addresses_seq.nextval
 into :new.address_id
 from dual;
   end if;
end;
/

... it fails and says

  [sql] SQL: create or replace trigger cls_addresses_bir_trg before
insert on cls_addresses_tb for each row begin if :new.address_id is null
then  
 select addresses_seq.nextval
 into :new.address_id
 from dual;
  [sql] -1 rows affected
  [sql] SQL: end if;
  [sql] Failed to execute: end if

BUILD FAILED

All tables and sequences have been created when this part is executed.

Am I doing something wrong?

cheers,

Gauti

PS. my ant task looks like:

sql driver=oracle.jdbc.OracleDriver
url=jdbc:oracle:thin:@host:1521:orcl userid=user password=pass
transaction src=${database}/scriptName.sql/
classpath
pathelement
location=${lib}/oracle/jdbc/classes12.jar/
/classpath
/sql


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]