[SQL] Retrieving the new "nextval" for primary keys....

2002-08-28 Thread Greg Patnude
I am using postgreSQL with Perl::CGI and Perl::DBI::Pg... I would like to be able to insert a row from my Perl script [$SQL->exec();] and have postgreSQL return the id of the newly inserted record (new.id) directly to the Perl script for further processing... Anyone with a solution / idea ??? Nea

[SQL] Why must the function that a trigger calls return "opaque" ???

2002-08-30 Thread Greg Patnude
This seem rather limiting... Suppose I want a trigger that after insert, returns the currval(sequence) of the newly inserted row automatically without having to run another query ??? GP ---(end of broadcast)--- TIP 3: if posting/reading throug

Re: [SQL] determining how many products are in how many categories

2004-02-15 Thread Greg Patnude
You might be better off with something more like this: SELECT COUNT(P.*) AS p_count, P.p_product_category_id FROM p_product P WHERE P.p_product_category_id IN (SELECT DISTINCT id FROM p_product_category) GROUP BY P.p_product_category_id; obviously tailored to YOUR schema... not mine... -- Greg

Re: [SQL] Unique Constraint with foreign Key

2004-02-15 Thread Greg Patnude
IMARY KEY default nextval('nextbz_seq'), x varchar NOT NULL REFERENCES a(x), ); -- Greg Patnude / The Digital Demention 2916 East Upper Hayden Lake Road Hayden Lake, ID 83835 (208) 762-0762 "Bruno Wolff III" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] &

Re: [SQL] nextval problem

2004-02-17 Thread Greg Patnude
New feature for posgreSQL 7.3 & later -- sequences are automatically dropped when the owning table is dropped -- you need to recreate the sequence The easiest way is in your CREATE TABLE tblName ( id serial PRIMARY KEY, blah..., blah..., ) WITH OIDS; -- Greg Patnude /

Re: [SQL] Unique Constraint with foreign Key

2004-02-17 Thread Greg Patnude
; Table A would have 1, 99 2, 99 .. 99,99 and table B would have 1, 1 1, 2 .. 1, 99 Greg Patnude / The Digital Demention 2916 East Upper Hayden Lake Road Hayden Lake, ID. 83835 (208) 762-0762 Send replies to: [EMAIL PROTECTED] Website: http://www.left-center.com -Original M

[SQL] User defined types -- Social Security number...

2004-02-20 Thread Greg Patnude
000-12-3456' Either that or the question is: How can I coerce postgreSQL into using an input / output "mask"... -- Greg Patnude / The Digital Demention 2916 East Upper Hayden Lake Road Hayden Lake, ID 83835 (208) 762-0762 ---(end of broadcast)-

Re: [SQL] User defined types -- Social Security number...

2004-02-29 Thread Greg Patnude
ny leading zeros - I just need to make sure that something "looks" like a valid SSN in the formattig (nnn-nn-) and that I can store / retrieve it with the approoriate format -- what I am really trying to accomplish is an "input mask"... I hadn't considered using a Doma

Re: [SQL] table constraints

2005-03-01 Thread Greg Patnude
foreign keys and primary keys have to be defined as unique at the table / column level if you want to implement a check constraint -- your contrived example doesn't stand up all that well -- If you want to use constraints -- then your database schema should conform to traditional RDBMS theory a

Re: [SQL] best way to swap two records (computer details)

2005-03-18 Thread Greg Patnude
How about a user defined function ??? CREATE OR REPLACE FUNCTION harwareupdate(integer, integer) RETURNS BOOLEAN AS ' update pieces set p_name = \'LSALES1\', p_location = \'Mike Haley\', p_site = \'L\' where p_id = $1; update pieces set p_name = \'SPARE\', p_location = \'spare\', p_

Re: [SQL] New record position

2005-03-31 Thread Greg Patnude
There's a difference between "natural" order (the location in the database or on disk) and "record" order (the order specified by the primary key)... -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Browne Sent: Wednesday, March 30, 2005 3:04 PM To

Re: [SQL] Tidying values on variable instantiation

2005-08-26 Thread Greg Patnude
IMHO: It's not necessarily the job of the RDBMS to be responsible for formatting and cleaning of your data... This is a job better suited for the application layer and the data model... The RDBMS should only be responsible for enforcing constraints on the data... not validating or purifying the d

Re: [SQL] SEVEN cross joins?!?!?

2005-10-11 Thread Greg Patnude
Aha ! A gamer... playing with armor and hit points and things -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Frank Bax Sent: Tuesday, October 11, 2005 1:06 PM To: pgsql-sql@postgresql.org Subject: Re: [SQL] SEVEN cross joins?!?!? At 08:29 AM 10/1