Devault values for Row in PGSQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Devault values for Row in PGSQL

Post by swraman »

I have a query:

INSERT INTO tr_projects () VALUES ()

which errors. In another thread I found that this will error UNLESS there are default values specified for every column in tr_projects.

There are in fact default values specified; there are 2 (there are 2 columns in tr_projects) and they are:

1) nextval('tr_projects_id_seq'::regclass)
2) 0

But when I run the query, it errors:

Warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near ")" LINE 1: INSERT INTO tr_projects () VALUES () ^ in C:\Program Files\BitNami WAPPStack\apache2\htdocs\ascprojects\tracker\pgsql_database.php on line 186

Is there a setting I have to change in PGSQL to make it use the default values automatically? Why doesnt it take the default values specified?
User avatar
volomike
Forum Regular
Posts: 633
Joined: Wed Jan 16, 2008 9:04 am
Location: Myrtle Beach, South Carolina, USA

Re: Devault values for Row in PGSQL

Post by volomike »

Try:

INSERT INTO tr_projects VALUES ()

?

Just guessing.
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Re: Devault values for Row in PGSQL

Post by swraman »

Thanks for the reply :)
I got it resolved, incase anyone else wants to know:

INSERT INTO table_name(column_name, column_name,...) VALUES(DEFAULT, DEFAULT,...)
User avatar
volomike
Forum Regular
Posts: 633
Joined: Wed Jan 16, 2008 9:04 am
Location: Myrtle Beach, South Carolina, USA

Re: Devault values for Row in PGSQL

Post by volomike »

Really? So using the word DEFAULT without quotes around it -- that works? Surprising.
swraman
Forum Commoner
Posts: 58
Joined: Thu Nov 06, 2008 12:33 am

Re: Devault values for Row in PGSQL

Post by swraman »

Yea, I guess its a built in feature to PGSQL.
Post Reply