Subject | Re: [IBO] Questions about transactions and generators |
---|---|
Author | Rafael Colucci |
Post date | 2004-05-24T12:36:09Z |
Hi Helen
My problem is to get a id inserted before (or after) execute a insert sql
... I still did not understand how to obtain it when I use threads ...
About the method ExecuteDML ... it is only to ilustrate .. but how you do to
execute a insert query? Can you show me an example to get a id inserted and
how to use ib_query to execute a insert query? I have to use GeneratorLinks
property for this?
I donĀ“t use double quotes ... it is because delphi requires this ... one o
close string and other to close the query ...
Rafael
My problem is to get a id inserted before (or after) execute a insert sql
... I still did not understand how to obtain it when I use threads ...
About the method ExecuteDML ... it is only to ilustrate .. but how you do to
execute a insert query? Can you show me an example to get a id inserted and
how to use ib_query to execute a insert query? I have to use GeneratorLinks
property for this?
I donĀ“t use double quotes ... it is because delphi requires this ... one o
close string and other to close the query ...
Rafael
> At 05:04 PM 22/05/2004 -0300, you wrote:values(''rafael'')');
> >Ok.. but I have some threads that will insert at the same time. This code
> >will work?
> >
> >procedure TForm1.Button1Click(Sender: TObject);
> >var
> > vId : Integer;
> >begin
> > IB_Query1.GeneratorLinks.Add('MyTablePK=genMyTable');
> > vId := IB_Query1.Gen_ID('genMyTable', 1);
> > IB_Query1.ExecuteDML('insert into MyTable(''Name'')
> >end;that
> >
> >vId is the id that will be inserted in MyTablePK?
>
> You are a bit mixed up here. If you use GeneratorLinks, you simply forget
> about the PK value when doing a normal Insert from the dataset.
>
> But you are not doing a normal insert from the dataset, you are doing an
> ExecuteImmediate, which doesn't prepare anything. The GeneratorLinks are
> not available. If you use this method, you will have to pass the PK value
> to the statement yourself, i.e. your variable vid, because this method
> requires a literal SQL statement.
>
> For ExecuteDML, you also have to pass a pointer to an XSQLDA structure
> you have previously constructed. ExecuteDML isn't "beginner stuff" and
> it's quite abnormal to call it from the context of a query object.
>
> Another problem I notice is your use of double quotes on the string
> value. This isn't valid for Firebird or IB 6 (but you don't say what you
> are using).
>
> Do you want to start again, using a more conventional method?
>
> Helen