On Wed, 2004-10-27 at 22:45 -0700, Jonathan Daugherty wrote:
# CREATE OR REPLACE FUNCTION get_default_value (text, text, text) RETURNS text AS '
# SELECT adsrc
# FROM pg_attrdef, pg_class, pg_namespace, pg_attribute
# WHERE
# adrelid = pg_class.oid AND
# pg_class.relnamespace =
On Thursday October 28 2004 11:42, Robby Russell wrote:
Thanks, this seems to work well. My goal is to actually create a php
function that takes a result and returns the insert_id like
mysql_insert_id() does, but without needing to know the sequence names
and such. I would make a psql
On Thu, 2004-10-28 at 16:51 -0600, Ed L. wrote:
On Thursday October 28 2004 11:42, Robby Russell wrote:
Thanks, this seems to work well. My goal is to actually create a php
function that takes a result and returns the insert_id like
mysql_insert_id() does, but without needing to know the
On Thu, Oct 28, 2004 at 04:51:05PM -0600, Ed L. wrote:
But I didn't understand why you care to get rid of the explicit reference to
the sequence object in your code in the first place. In PostgreSQL, at
least for the past 5 years if not longer, if you create a SERIAL column for
# But I didn't understand why you care to get rid of the explicit reference to
# the sequence object in your code in the first place. In PostgreSQL, at
# least for the past 5 years if not longer, if you create a SERIAL column for
# (schemaname, tablename, columnname), then your sequence will
On Thursday October 28 2004 5:31, Michael Fuhr wrote:
On Thu, Oct 28, 2004 at 04:51:05PM -0600, Ed L. wrote:
But I didn't understand why you care to get rid of the explicit
reference to the sequence object in your code in the first place. In
PostgreSQL, at least for the past 5 years if not
Ed L. [EMAIL PROTECTED] writes:
In PostgreSQL, at least for the past 5 years if not longer, if you create a
SERIAL column for (schemaname, tablename, columnname), then your sequence
will *always* be schemaname.tablename_columnname_seq. If that naming
convention changes, there will be a whole
On Thu, Oct 28, 2004 at 07:55:51PM -0400, Greg Stark wrote:
Ed L. [EMAIL PROTECTED] writes:
In PostgreSQL, at least for the past 5 years if not longer, if you create a
SERIAL column for (schemaname, tablename, columnname), then your sequence
will *always* be
I am trying to track down a method of determining what a sequence name
is for a SERIAL is in postgresql.
For example,
CREATE TABLE foo (id SERIAL PRIMARY KEY NOT NULL, bar TEXT);
\d foo
Table public.foo
Column | Type | Modifiers
On Wed, 2004-10-27 at 21:06 -0700, Robby Russell wrote:
I am trying to track down a method of determining what a sequence name
is for a SERIAL is in postgresql.
For example,
CREATE TABLE foo (id SERIAL PRIMARY KEY NOT NULL, bar TEXT);
\d foo
Table public.foo
On Wed, 2004-10-27 at 21:33 -0700, Robby Russell wrote:
I figured out how to get this:
foo= SELECT adsrc FROM pg_attrdef WHERE adrelid = (SELECT oid FROM
pg_class WHERE relname = 'foo');
adsrc
nextval('public.foo_id_seq'::text)
(1
On Wed, Oct 27, 2004 at 09:33:21PM -0700, Robby Russell wrote:
So, it was a nice attempt, but I am back to the need to of determining
the sequence name using a schema and a table.
The schema of a table is stored in pg_class.relnamespace, which is an
Oid of the pg_namespace catalog. With that
Robby Russell [EMAIL PROTECTED] writes:
Ok, so how would I go about getting the sequence name for a SERIAL
field on any given schema.table?
8.0 will have a function pg_get_serial_sequence to do this for you.
If you can't wait, the secret is to look in pg_depend for the dependency
link from the
# I figured out how to get this:
#
# foo= SELECT adsrc FROM pg_attrdef WHERE adrelid = (SELECT oid FROM
# pg_class WHERE relname = 'foo');
#adsrc
#
# nextval('public.foo_id_seq'::text)
# (1 row)
#
# However, this will break as soon as I do
On Wed, Oct 27, 2004 at 09:06:15PM -0700, Robby Russell wrote:
Ok, so how would I go about getting the sequence name for a SERIAL
field on any given schema.table? I would like to build a function
that would return this value if I pass it the schema and table (and
fieldname is necessary)
# CREATE OR REPLACE FUNCTION get_default_value (text, text, text) RETURNS text AS '
# SELECT adsrc
# FROM pg_attrdef, pg_class, pg_namespace, pg_attribute
# WHERE
# adrelid = pg_class.oid AND
# pg_class.relnamespace = pg_namespace.oid AND
# pg_attribute.attnum = pg_attrdef.adnum
16 matches
Mail list logo