Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2002

    Question Unanswered: Last ID with ASP

    Hey all. Nice forum you have here!

    I'm starting an ASP/Oracle project and I need a way to retrieve the last "autoincremented" number in a table (for which I used a sequence and a trigger). How do I do it?

    I have this table named bands which was created like

    CREATE TABLE bands ( band_id NUMBER PRIMARY KEY , band VARCHAR2(255) );

    I have also created this sequence
    create sequence bands_seq start with 1 increment by 1

    And this trigger:
    CREATE OR REPLACE TRIGGER "bands_tri" BEFORE INSERT ON bands FOR EACH ROW BEGIN SELECT bands_seq.nextval INTO :new.band_id FROM dual; END;

    So, after I insert a band's name without specifying its band_id , how do I retrieve the band_id value automatically inserted by my trigger?

    Thanks a lot!

  2. #2
    Join Date
    Mar 2002

    here's how I did it anyway

    never mind, I did it:

    1) I used oo4o instead of ODBC
    2) I used the parameters collection to bind a variable from oracle
    3) I retrieved its value by obj.parameter("yadda").value

    On a side note , oo4o's executeSQL command returned the # of affected rows


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts