Subject Re: [IBO] Syntax for passing variable to insert query
Author mitch_landor
--- In IBObjects@yahoogroups.com, Helen Borrie <helebor@...> wrote:
>
> At 03:30 PM 11/09/2006, you wrote:
> >I have an integer variable "VAR_PVERSION_ID" that I want to pass to an
> >insert query so that the column "PVERSION_ID" can receive it at the
> >same time as all the other columns are inserted. But I can't figure
> >out the syntax. Nothing I try works. Here is the basic insert query:
> >
> >INSERT INTO LOC(
> > /*ID, PK*/
> > PVERSION_ID,
> > NAME,
> > FLOORAREA,
> > LOCKD,
> > CREATED,
> > DESLOCREF,
> > LOCQTY)
> >VALUES (
> > /*:ID,*/
> > :PVERSION_ID,
> > :NAME,
> > :FLOORAREA,
> > :LOCKD,
> > :CREATED,
> > :DESLOCREF,
> > :LOCQTY)
> >
> >I have read that perhaps I should use the OnNewRecord event
>
> Nope. OnNewRecord is an event of a dataset.
>
> >to do
> >this. Can anyone please help me with the syntax for doing this?
>
> Assuming you are using a TIB_Cursor or a TIB_DSQL for this (as you
> should be, since your statement is a DML statement, i.e. it's one you
> *execute*), assign values to your parameters in the BeforeExecute
> event. I don't know where you're finding the values for all the
> other parameters, but here's how you'll pass the value of your
> variable to the 'PVERSION_ID' parameter in this event:
>
> procedure TForm1.IB_Cursor1BeforeExecute(Sender: TIB_Statement);
> begin
> Sender.ParamByName('PVERSION_ID').AsInteger := VAR_PVERSION_ID;
> end;
>
> But, since you have lots of them:
>
> procedure TForm1.IB_Cursor1BeforeExecute(Sender: TIB_Statement);
> begin
> with Sender.Row do
> begin
>
> ByName('PVERSION_ID').AsInteger := VAR_PVERSION_ID;
> ByName('NAME').AsString := SomeStringVar;
> ByName('FLOORAREA').AsBlah := SomeBlahVar;
> ByName('LOCKD').AsWhatever := .....
> ................and so on
> end;
>
> Helen
>


Sorry Helen,

I'm using IBO (I typed [IBO] in the message subject line but it
doesn't seem to show).

How would this affect your instructions above?

Many Thanks

Mitch