Subject | Re: [firebird-support] Re: Need help with running for select... do loop through isql |
---|---|
Author | Helen Borrie |
Post date | 2005-10-01T01:02:31Z |
At 05:13 PM 30/09/2005 +0000, you wrote:
are on the wrong track thinking that a script can achieve it. A script is
merely a list of DSQL statements that are executed one after the other as a
batch, from a client, like a robot sitting at the keyboard.
Then, as part of your corrective surgery, you need to add an After Insert
trigger to docpage, so that, in future, every insert to docpage will
automatically create these dependent records in endorsement:
If you are doing this from isql (or from a script), you'll need to set an
external terminator:
set term ^;
create trigger ai_docpage for docpage
active after insert
as
begin
insert into endorsement (id, document_id)
values (new.id, new.document_id);
end ^
This will reset the terminator:
set term ;^
./heLen
>Basically i need to loop through a set of document_page records usingYou are on the right track regarding the logic of what you have to do. You
>the id and document_id of each record to insert a corresponding record
>into endorsement using the document_page's id and document_id (id and
>document_id are the concatinated key).
are on the wrong track thinking that a script can achieve it. A script is
merely a list of DSQL statements that are executed one after the other as a
batch, from a client, like a robot sitting at the keyboard.
>I would like to have seen constraints manage this, but we didn't and IConstraints don't add data. What you want is triggers.
>need a clean up script.
>Basically i need :You need to write a one-off stored procedure to do this.
>
>for select id, document_id from docpage
>where (...)
>into :id, :document_id
>do begin
>insert into endorsement (id, document_id,...)
>values (:id,:document_id,...)
>end
Then, as part of your corrective surgery, you need to add an After Insert
trigger to docpage, so that, in future, every insert to docpage will
automatically create these dependent records in endorsement:
If you are doing this from isql (or from a script), you'll need to set an
external terminator:
set term ^;
create trigger ai_docpage for docpage
active after insert
as
begin
insert into endorsement (id, document_id)
values (new.id, new.document_id);
end ^
This will reset the terminator:
set term ;^
./heLen