Hi Jon Thanks for your reply. I read the article but with Oracle, a sequence and trigger needs to be created for autogenerated primary keys. If I try the code that you gave me, neither the sequence nor trigger are created - ie
C:\DjangoTraining\PK>python manage.py sql test CREATE TABLE "TEST_EMPLOYEE" ( "EMPLOYEE_CODE" NVARCHAR2(10) NULL PRIMARY KEY, "FIRST_NAME" NVARCHAR2(20) NULL, "LAST_NAME" NVARCHAR2(20) NULL ) ; COMMIT; If I let Django create a primary key, they are: C:\DjangoTraining\PK>python manage.py sql test CREATE TABLE "TEST_EMPLOYEE" ( "ID" NUMBER(11) NOT NULL PRIMARY KEY, "FIRST_NAME" NVARCHAR2(20) NULL, "LAST_NAME" NVARCHAR2(20) NULL ) ; CREATE SEQUENCE TEST_EMPLOYEE_SQ; CREATE OR REPLACE TRIGGER TEST_EMPLOYEE_TR BEFORE INSERT ON "TEST_EMPLOYEE" FOR EACH ROW WHEN (new.id IS NULL) BEGIN SELECT TEST_EMPLOYEE_SQ.nextval INTO :new.id FROM dual; END; / COMMIT; Am I missing something here? Thanks again Catriona On Aug 14, 6:24 pm, "Jon Atkinson" <[EMAIL PROTECTED]> wrote: > Catriona, > > I have very little Oracle experience, but also no reason to think that > setting a custom primary key would be different from any other > database backend. > > The documentation is > here:http://www.djangoproject.com/documentation/models/custom_pk/ > > The primary key is set by using 'primary_key=True' in the model. A > simple model with a custom primary key: > > class Employee(models.Model): > employee_code = models.CharField(max_length=10, primary_key=True) > first_name = models.CharField(max_length=20) > last_name = models.CharField(max_length=20) > > I hope this helps. > > --Jon > > On 8/14/07, Catriona <[EMAIL PROTECTED]> wrote: > > > > > > > Hello > > > I am a beginning Django user and would appreciate help on the > > following issue. > > > How do I specify a custom primary key in my model when using Oracle > > 10g > > > I am using the lastest Django version from svn. > > > Thanks for your help > > > Catriona- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---