Subject Re: [IBO] Inserts using TIB_Cursor
Author Jason Wharton
Cursor's are not ideal for handling inserts.
Use a TIB_Query since it has buffering capabilities.

Jason Wharton
CPS - Mesa AZ
http://www.ibobjects.com

-- We may not have it all together --
-- But together we have it all --


----- Original Message -----
From: "Ross Williams" <ross@...>
To: <IBObjects@yahoogroups.com>
Sent: Friday, March 07, 2003 11:16 AM
Subject: Re: [IBO] Inserts using TIB_Cursor


> I obviously wasn't very clear.
>
> My code for the insert looks like this:
>
> Function InsertMediaRecord: TModalResult;
> Begin
> With TMediaEditForm.Create(nil) do
> Try
> With TIB_CURSOR(MediaCursorDataSource.DataSet) do
> Begin
> IB_Transaction.StartTransaction;
> Open;
> Insert;
> end;
> Result := ShowModal;
> If Result = mrOK then
> Begin
> MediaCursorDataSource.DataSet.Post;
> MediaCursorDataSource.DataSet.IB_Transaction.Commit;
> end
> else
> Begin
> MediaCursorDataSource.DataSet.Cancel;
> MediaCursorDataSource.DataSet.Close;
> MediaCursorDataSource.DataSet.IB_Transaction.Rollback;
> end;
> finally
> Free;
> end;
> end;
>
> MediaCursorDataSource is on the TMediaEditForm and has its dataset set at
> design time to the TIBO_Cursor on a datamodule. This similar procedure
does
> work for editing a record:
>
> Function EditMediaRecord(ID:Integer): TModalResult;
> Begin
> With TMediaEditForm.Create(nil) do
> Try
> With TIB_CURSOR(MediaCursorDataSource.DataSet) do
> Begin
> IB_Transaction.StartTransaction;
> ParamByName('p' + MEDIAID).AsInteger := ID;
> Open;
> Edit;
> end;
> Result := ShowModal;
> If Result = mrOK then
> Begin
> MediaCursorDataSource.DataSet.Post;
> MediaCursorDataSource.DataSet.IB_Transaction.Commit;
> end
> else
> Begin
> MediaCursorDataSource.DataSet.Cancel;
> MediaCursorDataSource.DataSet.Close;
> MediaCursorDataSource.DataSet.IB_Transaction.RollBack;
> end;
> finally
> Free;
> end;
> end;
>
> This cursor is used exclusively for editing and inserting records.
>
>
> At 09:43 AM 3/7/03, you wrote:
> >Ross Williams wrote:
> > >
> > > I can't get an insert to work with the TIB_Cursor. I have a form set
up
> > > that I use for editing that works fine. I set the cursor to live and
it
> > > edits. When I try inserting a new record - I start the transaction,
insert
> > > the record, enter values in the same form I am using for editing and
then
> > > post it and commit the transaction. There is no error, but the record
is
> > > not posted or committed. I then tried adding insertsql property to
> > > explicitly create the insert. I used the sql generated by a TIB_Query
for
> > > the same table and pasted it into the instertsql property. The result
was
> > > the same.
> > >
> > > How does this work?
> > >
> >
> >The TIB_Cursor is basically for reports. Start at the beginning and
> >process once.
> >
> >Use the grid.
> >--
> >Raymond Kennington
> >Programming Solutions
> >W2W Team B

> Ross Williams
> Citizens for Sensible Transportation/
> Coalition for a Livable Future
> Terminal Sales Building
> 1220 SW Morrison, Suite 535
> Portland OR 97205
>
> Phone: 503-225-0003
> Fax: 503-225-0333
> Web: www.cfst.org
> Email: ross@...