Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Triggers and ADO
Hi Jen
I can't use this trigger aftre inserting row because ID field is main
key (like Autonumber in MS Access)
Artur
"Jen Decker" <jen_at_sunflower.com> wrote in message
news:B796AEA0.4487%jen_at_sunflower.com...
> Dear Artur,
> I think you need to insert the row first then use your sequence to fill
the
> column.
>
> CREATE OR REPLACE TRIGGER TR_MY_TABLE_INSERT
> AFTER INSERT ON MY_TABLE
> FOR EACH ROW
> BEGIN
> SELECT SQ_MY_TABLE_ID.nextval INTO :new.ID FROM DUAL;
> END;
>
> I hope this helps.
> Jen
>
> Artur wrote:
>
> > Hi
> > I am having a problem with adding new records to a table using ADO. A
> > table has unique column named "ID".
> > When I adding new row to the table I use trigger ( SQ_MY_TABLE_ID is a
> > sequence) :
> >
> > CREATE OR REPLACE TRIGGER TR_MY_TABLE_INSERT
> > BEFORE INSERT ON MY_TABLE
> > FOR EACH ROW
> > BEGIN
> > SELECT SQ_MY_TABLE_ID.nextval INTO :new.ID FROM DUAL;
> > END;
> >
> > To add new data I use:
> > _variant_t val("My String")
> > m_Recordset->AddNew();
> > m_Recordset->Fields->GetItem(2)->Value = val;
> > m_Recordset->Update();
> >
> > val = m_pRS->Fields->GetItem("ID")->Value;
> > // variable val CONTAINS "ID" = 0 ???????
> > How can I get those ID ?????
> >
> > Thank you,
> > Artur
>
Received on Thu Aug 09 2001 - 07:25:18 CDT