Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Posts: 168
Joined: Thu 03 Jul 2008 23:55


Post by JORGEMAL » Mon 28 Dec 2009 23:57

I have a situation in which there are 2 tables, a parent and a child, but in my case the child table is filled first. When the user finishes typing the child records he or she can decide whether or not to keep the information. If the data is kept then a record is generated in the parent table and at this time the child records are connected. While no parent record exists, the field in the child table that will connect to the parent table is temporarily filled with a value of -1, such a field is of type bigint. This issue prevents me from defining a relation because the user is inserting child records with no parent. I asked this question in a PostgreSQL forum and I was told to set the value of NULL instead of -1.
Is this possible for an integer or bigint field? If so, how?

Jorge Maldonado

Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 29 Dec 2009 12:34

First of all, the mentioned field in the child table needs to be nullable. Please check it via your PostgreSQL DBMS.

To insert NULL into the table you can:
1) Leave the corresponding cell in your grid blank, if the ID column of the grid is displayed.
2) Add the NULL parameter inside the update command text, if the ID column of the grid is hidden from user. This will be something like this:

Code: Select all

PgSqlCommand com = new PgSqlCommand("INSERT INTO MyTable VALUES (null, " + myValue.ToString() + ")");

Post Reply