Subject | Re: [IBO] IB_Import and Primary Key problem |
---|---|
Author | Helen Borrie |
Post date | 2005-11-11T07:57:05Z |
At 06:20 AM 11/11/2005 +0000, you wrote:
to. Which is fine, let the database do this for you.
create trigger bi_mytable
active before insert
as
begin
if (new.MyPK is null) then
new.MyPK = gen_id(MyGenerator, 1);
end
identifier was exactly the same as the one in your GeneratorLinks, IBO will
included it. But, for this kind of batch importing it's
inefficient. Leave the dest fieldlist as it is and let the trigger do the
work.
method of a statement, that sets up things like fields and parameters. It
should only be called once. It's likely that TIB_Import does it itself if
needed, as part of its Execute sequence.
import consists of file reads (from the source file) and either inserts to
a table (executes a parameterised INSERT statement) or executes a
parameterised stored procedure. So, if you are using a table, you need at
least all of your non-nullable columns "covered" by the structure that
tib_import makes out of your source specifications.
Helen
> > Show us your INSERT statement.Yeah, OK, I see what's going on.
>
>Helen,
>
>Thanks for your reply.
>
>I'm not sure what you mean by 'my' insert statement.
>AIU, IB_Import prepares the insert statementYes, because it's not in the source set, so there is nothing to map it
>based upon the fieldlist I provide it, and as I step
>through IB_Import.MakeInsertStatement I can see it
>being prepared, but it is indeed prepared without the
>needed first field which is the primary key.
to. Which is fine, let the database do this for you.
>So, am I supposed to somehow prepare IB_ImportYou should have a BI trigger on the destination table, as
>to add the primary key as the first field?
create trigger bi_mytable
active before insert
as
begin
if (new.MyPK is null) then
new.MyPK = gen_id(MyGenerator, 1);
end
>It does not seem to work if I add the primaryIt would if it was in the destination fieldlist. Then provided its
>key to the start of the fieldlist.
identifier was exactly the same as the one in your GeneratorLinks, IBO will
included it. But, for this kind of batch importing it's
inefficient. Leave the dest fieldlist as it is and let the trigger do the
work.
>Am supposed to prepare the insert statement directlyDepends whether you and I mean the same thing by "Prepare". Prepare is a
>for IB_Import?
method of a statement, that sets up things like fields and parameters. It
should only be called once. It's likely that TIB_Import does it itself if
needed, as part of its Execute sequence.
>Perhaps through an IB_Table for the table to usedNot clear what this question asks. There is no "IB_Table". Basically, an
>by IB_Import?
import consists of file reads (from the source file) and either inserts to
a table (executes a parameterised INSERT statement) or executes a
parameterised stored procedure. So, if you are using a table, you need at
least all of your non-nullable columns "covered" by the structure that
tib_import makes out of your source specifications.
Helen