Using MyGeneration, doodads, and Oracle XE, is it possible to implement an "auto number primary key"

Posted by Michael Rosario on Stack Overflow See other posts from Stack Overflow or by Michael Rosario
Published on 2010-04-24T20:51:49Z Indexed on 2010/04/24 20:53 UTC
Read the original article Hit count: 512

Filed under:
|
|
|

Hello world.

Using MyGeneration, doodads, and Oracle XE, is it possible to implement an "auto number primary key" scheme?

Problem facts: I am using Oracle XE. I have implemented the following table and trigger:

CREATE TABLE  "USERS" 
   (    "ID" NUMBER(38,0), 
    "USER_NAME" VARCHAR2(50), 
    "PASSWORD" VARCHAR2(50), 
    "EMAIL" VARCHAR2(100), 
     CONSTRAINT "USERS_PK" PRIMARY KEY ("ID") ENABLE
   )
/

CREATE OR REPLACE TRIGGER  "BI_USERS" 
  before insert on "USERS"               
  for each row  
begin   
    select "USERS_SEQ".nextval into :NEW.ID from dual; 
end; 

/
ALTER TRIGGER  "BI_USERS" ENABLE
/

MyGeneration / Doodads created the following stored proc...

CREATE OR REPLACE PROCEDURE "XXX"."PI_USERS"
(
    p_ID IN USERS.ID%type,
    p_USER_NAME IN USERS.USER_NAME%type,
    p_PASSWORD IN USERS.PASSWORD%type,
    p_EMAIL IN USERS.EMAIL%type
)
IS
BEGIN


    INSERT
    INTO USERS
    (
        ID,
        USER_NAME,
        PASSWORD,
        EMAIL
    )
    VALUES
    (
        p_ID,
        p_USER_NAME,
        p_PASSWORD,
        p_EMAIL
    );
END PI_USERS;

The sequence and trigger combination is working fine. The BusinessEntity class in C# does not receive the new ID.

Any recommended ways to allow the calling code receive the new record ID?

© Stack Overflow or respective owner

Related posts about mygeneration

Related posts about Oracle