Re: [SQL] add column if doesn't exist

2005-09-28 Thread Brandon Metcalf
c == [EMAIL PROTECTED] writes: c> I set up a stored procedure to do this for Slony-I... Replace c> @NAMESPACE@ with your favorite namespace, and slon_quote_brute can c> likely be treated as an identity function unless you use silly c> namespace names :-). Thanks. -- Brandon --

Re: [SQL] Why doesn't the SERIAL data type automatically have a UNIQUE CONSTRAINT

2005-09-28 Thread codeWarrior
"Ferindo Middleton Jr" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Is there some reason why the SERIAL data type doesn't automatically have a > UNIQUE CONSTRAINT. It seems that the main reason for using it is so that > the value for this field keeps changing automatically and

[SQL] Sending function parametars within EXECUTE ''SELECT...

2005-09-28 Thread Mario Splivalo
I've learned that one can't use temporary tables within the function unless EXECUTE'd the SELECTS from that temp table. So, I have a function like this: CREATE FUNCTION Foo1(int4, int4) RETURNS SETOF myType AS ' DECLARE aDataId ALIAS FOR $1; aBid ALIAS FOR $2; return myTyp

Re: [SQL] Sending function parametars within EXECUTE ''SELECT...

2005-09-28 Thread codeWarrior
"Mario Splivalo" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I've learned that one can't use temporary tables within the function > unless > EXECUTE'd the SELECTS from that temp table. > > So, I have a function like this: > > CREATE FUNCTION Foo1(int4, int4) RETURNS SETOF myType

[SQL] Problem with function and trigger...

2005-09-28 Thread Ian Meyer
I have a function declared as such: CREATE OR REPLACE FUNCTION thread_sync() RETURNS trigger AS $$ BEGIN IF TG_OP = 'DELETE' AND OLD.deleted = FALSE THEN UPDATE member SET total_threads=total_threads-1 WHERE id=OLD.member_id; RETURN OLD; ELSEIF TG_OP = 'INSERT' THEN UPDATE member S

Re: [SQL] Problem with function and trigger...

2005-09-28 Thread Tom Lane
Ian Meyer <[EMAIL PROTECTED]> writes: > IF TG_OP = 'DELETE' AND OLD.deleted = FALSE THEN > ERROR: record "old" is not assigned yet > DETAIL: The tuple structure of a not-yet-assigned record is indeterminate. > CONTEXT: PL/pgSQL function "thread_sync" line 2 at if > What am I failing to under

[SQL] Selecting count of details along with details columns

2005-09-28 Thread Axel Rau
Dear pgsql-admin members: Having 2 tables: CREATE TABLE T2 ( idserial PRIMARY KEY, T2_name text ); CREATE TABLE T1 ( idserial PRIMARY KEY, T1_name text, fk_t2 int4REFERENCES t2 ); And some rows: INSERT INTO T2 (T2_name) VALUES('T2-N1'); INSERT INTO T2 (T2_name) V

Re: [SQL] changing a column's position in table, how do you do that

2005-09-28 Thread Daryl Richter
Ferindo Middleton Jr wrote: Is there a way to change the position attribute of a column in a table? I have data that I need to import into various tables in my db on a consistent basis... I usually us e the COPY ... FROM query but I can't control the -order- of the fields my client dumps the da

Re: [SQL] Problem with function and trigger...

2005-09-28 Thread Ian Meyer
On 9/28/05, Tom Lane <[EMAIL PROTECTED]> wrote: > Ian Meyer <[EMAIL PROTECTED]> writes: > > IF TG_OP = 'DELETE' AND OLD.deleted = FALSE THEN > > > ERROR: record "old" is not assigned yet > > DETAIL: The tuple structure of a not-yet-assigned record is indeterminate. > > CONTEXT: PL/pgSQL functi

Re: [SQL] changing a column's position in table, how do you do that

2005-09-28 Thread Michael Glaesemann
On Sep 29, 2005, at 4:38 , Daryl Richter wrote: Ferindo Middleton Jr wrote: Is there a way to change the position attribute of a column in a table? I have data that I need to import into various tables in my db on a consistent basis... I usually us e the COPY ... FROM query but I can't c

[SQL] unsubscribe

2005-09-28 Thread Ricky Sutanto
---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

[SQL] unsubscribe

2005-09-28 Thread noor
please take me out from this group. ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] unsubscribe

2005-09-28 Thread Kenneth Gonsalves
On Thursday 29 Sep 2005 11:47 am, [EMAIL PROTECTED] wrote: > please take me out from this group. ask the guy who put you in the group to do it -- regards kg http://www.livejournal.com/users/lawgon tally ho! http://avsap.org.in ಇಂಡ್ಲಿನಕ್ಸ வாழ்க! ---(end of broadcast)-

Re: [SQL] Sending function parametars within EXECUTE ''SELECT...

2005-09-28 Thread Mario Splivalo
On Wed, 2005-09-28 at 10:01 -0700, codeWarrior wrote: > > > > ---(end of broadcast)--- > > TIP 5: don't forget to increase your free space map settings > > > > FOR rec IN EXECUTE ''SELECT COUNT(col1) AS num FROM tmpTbl WHERE col2 = " || > aBid || ''

Re: [SQL] Sending function parametars within EXECUTE ''SELECT...

2005-09-28 Thread Stewart Ben (RBAU/EQS4) *
> Is there a way to assing variable a value returned from query that > accesses the temporary table in a way you explained above? > > For instance, I can do: > > myValue := col2 FROM tmpTbl WHERE someValue = somethingElse... If I'm parsing this correctly, all you need do is: SELECT col2 INTO my