Zprocessor doesnt exec CREATE TRIGGER AND ZQUERY TO

Forum related to Firebird

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
sfxcc
Senior Boarder
Senior Boarder
Posts: 95
Joined: 13.05.2010, 18:48

Zprocessor doesnt exec CREATE TRIGGER AND ZQUERY TO

Post by sfxcc »

Why cant i exec this on zsqlprocessor or zquery

But i dont want to add sql.clear ; sql.sql := text;

parcial want to exec all on same string ???


any goodc :idea: :thx:

Better yet how can i exec create table create procedure and every thing on same tstring ?????

It it possible.

Execdirect solve the problem ???????

Damn this is a Terror movie .. .. . :twisted: :arrow: :shock:


/* Begin : Triggers Definition */
SET TERM ^ ;
CREATE TRIGGER TRI_GRUPOS FOR GRUPOS ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.GR_ID IS NULL) OR (NEW.GR_ID = 0)) THEN BEGIN NEW.GR_ID =GEN_ID(GEN_GRUPOSID ,1);END END ^
CREATE TRIGGER TRI_GRUPOSCOLABORDORES FOR GRUPOSCOLABORDORES ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.GC_ID IS NULL) OR (NEW.GC_ID = 0)) THEN BEGIN NEW.GC_ID =GEN_ID(GEN_GRUPOSCOLABORDORESID ,1);END END ^
CREATE TRIGGER TRI_FORMAPAGAMENTO FOR FORMAPAGAMENTO ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.FP_ID IS NULL) OR (NEW.FP_ID = 0)) THEN BEGIN NEW.FP_ID =GEN_ID(GEN_FORMAPAGAMENTOID ,1);END END ^
CREATE TRIGGER TRI_SERVICOSCLIENTES FOR SERVICOSCLIENTES ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.SC_ID IS NULL) OR (NEW.SC_ID = 0)) THEN BEGIN NEW.SC_ID =GEN_ID(GEN_SERVICOSCLIENTESID ,1);END END ^
CREATE TRIGGER TRI_SOLICITACOESCLICOL FOR SOLICITACOESCLICOL ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.SCC_ID IS NULL) OR (NEW.SCC_ID = 0)) THEN BEGIN NEW.SCC_ID =GEN_ID(GEN_SOLICITACOESCLICOLID ,1);END END ^
CREATE TRIGGER TRI_ATTACHFILES FOR ATTACHFILES ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.AF_ID IS NULL) OR (NEW.AF_ID = 0)) THEN BEGIN NEW.AF_ID =GEN_ID(GEN_ATTACHFILESID ,1);END END ^
CREATE TRIGGER TRI_SERVICOSCONTRATADOS FOR SERVICOSCONTRATADOS ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.SC_ID IS NULL) OR (NEW.SC_ID = 0)) THEN BEGIN NEW.SC_ID =GEN_ID(GEN_SERVICOSCONTRATADOSID ,1);END END ^
CREATE TRIGGER TRI_PERIODICIDADESERVICOS FOR PERIODICIDADESERVICOS ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.PS_ID IS NULL) OR (NEW.PS_ID = 0)) THEN BEGIN NEW.PS_ID =GEN_ID(GEN_PERIODICIDADESERVICOSID,1);END END ^
CREATE TRIGGER TRI_TIPOSERVICO FOR TIPOSERVICO ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.TS_ID IS NULL) OR (NEW.TS_ID = 0)) THEN BEGIN NEW.TS_ID =GEN_ID(GEN_TIPOSERVICOID ,1);END END ^
CREATE TRIGGER TRI_GENEROSERVICO FOR GENEROSERVICO ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.GS_ID IS NULL) OR (NEW.GS_ID = 0)) THEN BEGIN NEW.GS_ID =GEN_ID(GEN_GENEROSERVICOID ,1);END END ^
CREATE TRIGGER TRI_RESULTADO FOR RESULTADO ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.R_ID IS NULL) OR (NEW.R_ID = 0)) THEN BEGIN NEW.R_ID =GEN_ID(GEN_RESULTADOID ,1);END END ^
CREATE TRIGGER TRI_RESULTADO FOR ACCOESEXECUTADAS ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.AE_ID IS NULL) OR (NEW.AE_ID = 0)) THEN BEGIN NEW.AE_ID =GEN_ID(GEN_ACCOESEXECUTADASID ,1);END END ^
CREATE TRIGGER TRI_TIPOSOLICITACOESINFO FOR TIPOSOLICITACOESINFO ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.TSI_ID IS NULL) OR (NEW.TSI_ID = 0)) THEN BEGIN NEW.TSI_ID =GEN_ID(GEN_TIPOSOLICITACOESINFOID ,1);END END ^
COMMIT WORK ^
SET TERM ;^
/* End : Triggers Definition */
where's the code ..
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

But which error this procedure gives you?
Have you tried exexcuting this procedure with FlameRobin?
Moreover remember you can't partially execute this procedure because is one macro procedure, so before excute it check none of that triggers were already created.
sfxcc
Senior Boarder
Senior Boarder
Posts: 95
Joined: 13.05.2010, 18:48

Error is just this

Post by sfxcc »

Error in Sql Statment ... I do this on a empty database after create tables and generators;

"
CREATE TRIGGER TRI_GRUPOS FOR GRUPOS ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF ((NEW.GR_ID IS NULL) OR (NEW.GR_ID = 0)) THEN BEGIN NEW.GR_ID =GEN_ID(GEN_GRUPOSID ,1);
"

On the 1st post is exacly what im using. Before this i have some code Create table but is ok.(I removed the CREATE TRIGGER SECTION and sql is executed.)

It just blocks on the 1st TRIGGER , on zsqlprocessor i added the "set term ^ ;"but didnt solve started and new error on "set term ^ ;" ...
So with "Set term ^" no error on "set term" but error continues on create trigger.

But i read a post i cant use trigger on zsqlprocessor and u gave a answer on in so i uses a zquery to the triggers

zsqlprcessor.execute;
zquery1.sql.text := is all trigger posted on 1st post ;
zquery1.execsql;

But doesnt work anyway,


do i have to do

zquery1.sql.text := 1st trigger;
zquery1.execsql;

zquery1.sql.text := 2st trigger;
zquery1.execsql;

zquery1.sql.text := 3st trigger;
zquery1.execsql;
.
.
.
zquery1.sql.text := N.... trigger;
zquery1.execsql;


What can i do to solve this.



What i want is to have a file.sql and do
component.sql.loadfromfile("file.sql");
component.Execsql;


and it does every thing on the file.

Any :idea: for this works fine :?:

:thanks:
where's the code ..
sfxcc
Senior Boarder
Senior Boarder
Posts: 95
Joined: 13.05.2010, 18:48

Post by sfxcc »

grupostable exists , GR_ID is integer no null, of grupos table exits,
GEN_GRUPOSID is agenerator and exists to....

I did this on flamerobbin o run query :

create trigger TRI_GRUPOS FOR grupos active before insert
as
begin
if ((new.gr_id is null) or (new.gr_id = 0)) then
begin
new.gr_id = gen_id( GEN_GRUPOSID, 1);
end
end




The Result is this error :

Preparing query: create trigger TRI_GRUPOS FOR grupos active before insert
as
begin
if ((new.gr_id is null) or (new.gr_id = 0)) then
begin
new.GR_ID = gen_id( GEN_GRUPOSID, 1)
Error: *** IBPP::SQLException ***
Context: Statement::Prepare( create trigger TRI_GRUPOS FOR grupos active before insert
as
begin
if ((new.gr_id is null) or (new.gr_id = 0)) then
begin
new.GR_ID = gen_id( GEN_GRUPOSID, 1) )
Message: isc_dsql_prepare failed

SQL Message : -104
Invalid token

Engine Code : 335544569
Engine Message :
Dynamic SQL Error
SQL error code = -104
Unexpected end of command - line 6, column 38




Whats the problem ???

End of commabnd there a ";" is correct ??? not seeing the problem

Cant i execute this as a query ????



:?: :?: :?: :?: :shock:
where's the code ..
sfxcc
Senior Boarder
Senior Boarder
Posts: 95
Joined: 13.05.2010, 18:48

FlameRobin Ok

Post by sfxcc »

This worlked on flame robin fine .....

But not on zsqlprocessor.

set term ^ ;
create trigger TRI_GRUPOS_ID1 for grupos
active before insert
as
begin
if ((new.gr_id is null) or (new.gr_id=0)) then
begin
new.gr_id = gen_id(GEN_GRUPOSID,1 );
end
end
^
set term ;^
where's the code ..
sfxcc
Senior Boarder
Senior Boarder
Posts: 95
Joined: 13.05.2010, 18:48

Post by sfxcc »

Finally i think i solved the problem with zsqlprocessor


Set zSqlProcessorDelimiterType := dtGo.

and In all statment did go:

ex :
go
Create soemething

go
create other thing


Dont use set term (big problems ).... but with go solves this issue ..

:thanks: seawolf for ya support in all issues.
where's the code ..
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

sfxcc,

I suppose there's a problem with splitting the ZSQLProcessor into separate statements.

If somebody wishes to debug the proces I wish him all luck he needs.

Mark
Image
sfxcc
Senior Boarder
Senior Boarder
Posts: 95
Joined: 13.05.2010, 18:48

exec

Post by sfxcc »

Indeed my last post of this issue is working perfectly till now.


I hope this help somebody .. it helped me a lot. of :wallb:
where's the code ..
joseme
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 29.03.2009, 03:13
Location: Costa Rica
Contact:

Re: exec

Post by joseme »

sfxcc wrote:Indeed my last post of this issue is working perfectly till now.


I hope this help somebody .. it helped me a lot. of :wallb:
Yes you did it!!! It help me to create two tables with generators and triggers, thank you!
Post Reply