Visual Paradigm Logo
     Build Quality Applications Faster, Better and Cheaper
 
Home | Products | Download | Documentation | Support | Resources | Partners | Quick Tour | Shop | Company |  
 
   Visual Paradigm Discussion Forum
  Login   [ Register ] Email: Password: Log me on automatically I lost my password  
Recent Topics
Advanced Search
ERROR: 42P01: relation [x] does not exist  
Forum Index -> DB Visual ARCHITECT (DB-VA)
Author Message
bdubs


Joined: 2007/01/03
Messages: 6

Offline

Hello,

I'm getting an exception in the ORM generated sample code when trying to Save operation in CreateDbTestData . I'm using PostgreSQL 8.2 with .NET 2.0 (solution needed conversion from .NET 1.1). My database name is "dbtest" with a single table "dummy". The ListDbTestData sample works properly, so my connection to the database is good.

My .postgresql setup:
Code:
CREATE TABLE dummy (
 	id	integer primary key,
 	smth	varchar(30)
 );


I receive this exception:
Code:
{"ERROR: 42P01: relation \"public.dummy_id_seq\" does not exist"}	System.Exception {Npgsql.NpgsqlException}


During the "Save" call in this code in ormsamples.CreateDbTestData:
Code:
				
 MyPackage.Dummy myPackageDummy = MyPackage.DummyFactory.CreateDummy();
 // Initialize the properties of the persistent object
 myPackageDummy.Smth = "Something";
 myPackageDummy.Save();


I'm an experienced programmer, but new to ORM, dB, and Visual Paradigm.

Thanks,
Eric
 
bdubs


Joined: 2007/01/03
Messages: 6

Offline

I've found a fix. I had to manually add a SEQUENCE to the database, named: <table>_<field>_seq.

It is possible to override the sequence generator. Go to the ERD and right click the primary key and select "Open Specification". ID generation is control by the "ID Generator" field. Some selections require you to enter a custom key. For example, if you select "sequence" you can manually enter "my_seq" as the key. This should correspond to a CREATE SEQUENCE command in your SQL setup code.

Here is my new SQL setup code:
Code:
CREATE TABLE dummy (
 	id	integer primary key,
 	smth	varchar(30)
 );
 
 -- workaround for VP DB-VA error:
 -- 	"ERROR 42P01: relation \"public.dummy_id_seq\" does not exist"
 CREATE SEQUENCE dummy_id_seq
    INCREMENT 1
    START 1;


Is this the recommended way of setting up the dB primary key sequence generation? I'm assuming that the VP database generator does this automatically, and that I'm only seeing it because I'm handcrafting my dB.

Thanks,
Eric
 
Jick


Joined: 2005/04/29
Messages: 2880

Offline

Hi bdubs,

You are correct. Another method is "create table dummy (id serial not null, primary key (id));", it will auto generate "dummy_id_seq" sequence.

Hope this helps.

Best regards,
Jick

Visual Paradigm International Ltd.
http://www.visual-paradigm.com

Build Quality Applications Faster, Better and Cheaper
 
bdubs


Joined: 2007/01/03
Messages: 6

Offline

Jick,

Thanks for the response. Yes, this is very helpful. Your method is easier because "DROP TABLE dummy" will drop both the TABLE and the implicitly created SEQUENCE. This makes my mainenance/setup .postgresql files simpler.

Thanks,
bdubs
 
 
   Forum Index -> DB Visual ARCHITECT (DB-VA)
Go to:   
Powered by JForum 2.1.4 © 2005 - Rafael Steil