John Siracusa writes:
On 7/8/06 12:35 AM, David Kamholz wrote:
-- there doesn't seem to be a single right syntax for it. INSERT
INTO foo; doesn't work for all databases. Some allow INSERT INTO
foo DEFAULT VALUES;, but I believe that produces an error in mysql.
So we haven't found a
On 7/8/06 12:35 AM, David Kamholz wrote:
-- there doesn't seem to be a single right syntax for it. INSERT
INTO foo; doesn't work for all databases. Some allow INSERT INTO
foo DEFAULT VALUES;, but I believe that produces an error in mysql.
So we haven't found a general solution yet which is the
John Siracusa wrote:
On 7/8/06 12:35 AM, David Kamholz wrote:
-- there doesn't seem to be a single right syntax for it. INSERT
INTO foo; doesn't work for all databases. Some allow INSERT INTO
foo DEFAULT VALUES;, but I believe that produces an error in mysql.
So we haven't found a general
On 7/8/06 11:22 AM, Ash Berlin wrote:
John Siracusa wrote:
Another alternative is:
INSERT INTO foo (anycol) VALUES (DEFAULT);
That works in MySQL and Postgres, where anycol is literally any column in
the table.
That said, so far, I haven't found a syntax that works everywhere.
I'd like to create a row in a table that's empty except for it's
primary key column (e.g. 'id'), which should be automatically
generated by PK::Auto. I go on to possibly insert things into it
and/or have rows in other tables which have it's id as a foreign key.
I'm using Postgresql on FreeBSD
if you do
$foo = $schema-resultset('Foo')-new({});
$foo-bar('bar');
$foo-insert;
The $foo-insert is when the INSERT statement is executed, and it will
set the primary key column itself.
George Hartzell wrote:
I'd like to create a row in a table that's empty except for it's
primary key column
Brett Gardner writes:
if you do
$foo = $schema-resultset('Foo')-new({});
$foo-bar('bar');
$foo-insert;
Thanks, that should work for what I'm trying to do.
Even with this approach, it's still not possible to insert a row in
which all of the columns except the primary key are
The example Brett Gardner gave is equivalent to -create({ bar =
'bar' }). create() is just new() followed by insert. The issue of
wanting to insert a row with *no* values specified is a more general
one, however. In many cases it's probably bad design to need to do
something like that. But