Re: [SQL] Convert serial column to regular integer

2007-05-11 Thread Collin Peters
Anything pre-8.2? On 5/11/07, Rodrigo De León <[EMAIL PROTECTED]> wrote: CREATE TABLE dtab (i SERIAL); ALTER TABLE dtab ALTER COLUMN i DROP DEFAULT; ALTER SEQUENCE dtab_i_seq OWNED BY NONE; DROP SEQUENCE dtab_i_seq; ---(end of broadcast)---

[SQL] Convert serial column to regular integer

2007-05-11 Thread Collin Peters
I have a need to convert an incorrectly typed serial column to a regular integer column. Basically this just involves removing the sequence. I am able to successfully remove the default value (DROP DEFAULT) (which seems to use nextval) and now pgadmin does show the column as an integer, but I ca

Re: [SQL] Insert into VIEW using RULE. Not possible to use nextval()?

2007-05-04 Thread Collin Peters
rrect within the RULE. This was my second question. If I call "INSERT INTO Vschematic_insert(..." simultaneously 1000 times is it guaranteed to be correct? On 5/3/07, Richard Broersma Jr <[EMAIL PROTECTED]> wrote: --- Collin Peters <[EMAIL PROTECTED]> wrote: > The exact pro

Re: [SQL] Insert into VIEW using RULE. Not possible to use nextval()?

2007-05-03 Thread Collin Peters
The exact problem is that you can't use nextval() with an INSERTable VIEW Problem is the same as that in this post: http://archives.postgresql.org/pgsql-sql/2003-07/msg00333.php On 5/3/07, Richard Broersma Jr <[EMAIL PROTECTED]> wrote: --- Collin Peters <[EMAIL PROTECTED]&g

[SQL] Insert into VIEW using RULE. Not possible to use nextval()?

2007-05-03 Thread Collin Peters
tivity_user_activity_id_seq') as id, CURRENT_DATE, 1, 2, 27, 'foo' LOOP INSERT INTO user_activity_single(mviews.id, etc...) END LOOP; Performance wise this doesn't seem as good. In my case the SELECT statement would be around 4000 records. Any tips for me? Regards, Coll

[SQL] Possible to access value in RECORD without knowing column name?

2007-05-02 Thread Collin Peters
In plpgsl, if I have a RECORD variable that is populated via some dynamic SQL, is it possible to access the columns in that RECORD object without knowing the column names? I.e. Can I grab whatever value is the 3rd column? random_colname = 'foobar'; sql = 'SELECT col1, col2, ' || random_colname |

Re: [SQL] Dynamic prepare possible in plpgsql?

2007-05-02 Thread Collin Peters
So if I have an INSERT inside a LOOP in a plpgsql function, it is only prepared once? Regards, Collin On 5/1/07, Jonah H. Harris <[EMAIL PROTECTED]> wrote: On 5/1/07, Collin Peters <[EMAIL PROTECTED]> wrote: > Is it faster to use PREPARE for the various INSERT statements ins

Re: [SQL] Dynamic prepare possible in plpgsql?

2007-05-01 Thread Collin Peters
statements inside a plpgsql function? Perhaps I am wrong and it does its PREPARE work when the function is parsed. Collin On 4/30/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Collin Peters" <[EMAIL PROTECTED]> writes: > Is it possible to have a dynamic PREPARE statement in plpg

[SQL] "is not distinct from" syntax error?

2007-04-30 Thread Collin Peters
From: http://www.postgresql.org/docs/8.2/static/functions-comparison.html " The ordinary comparison operators yield null (signifying "unknown") when either input is null. Another way to do comparisons is with the IS [ NOT ] DISTINCT FROM construct: expression IS DISTINCT FROM expression expressi

[SQL] Dynamic prepare possible in plpgsql?

2007-04-30 Thread Collin Peters
Is it possible to have a dynamic PREPARE statement in plpgsql? Something like PREPARE users_plan ( || 'text, text' || ) AS INSERT INTO pp_users( || 'col1, col2' || ) VALUES($1, $2); Regards, Collin ---(end of broadcast)---

[SQL] Question about "AT TIME ZONE"

2006-12-05 Thread Collin Peters
The following is taken from section 9.9.3 of the help docs === Examples (supposing that the local time zone is PST8PDT): SELECT TIMESTAMP '2001-02-16 20:38:40' AT TIME ZONE 'MST'; Result: 2001-02-16 19:38:40-08 SELECT TIMESTAMP WITH TIME ZONE '2001-02-16 2

[SQL] Multi-table insert using RULE - how to handle id?

2006-07-19 Thread Collin Peters
I am learning about how to use rules to handle a multi-table insert. Right now I have a user_activity table which tracks history and a user_activity_users table which tracks what users are associated with a row in user_activity (one to many relationship). I created a rule (and a view called user_

[SQL] Am I crazy or is this SQL not possible

2006-06-01 Thread Collin Peters
I am having some serious mental block here. Here is the abstract version of my problem. I have a table like this: unique_id (PK) broadcast_id date_sent status 1 1 2005-04-0430 2 1 2005-04-01 30 3

[SQL] Help with simple query

2005-12-28 Thread Collin Peters
I have a simple table called notes which contains notes for users. The table has 4 columns: note_id (auto-incrementing primary key), user_id (foreign key to a users table), note (varchar), and modified_date (timestamp). Is there a nice simple query I can run that will return me a list of all the

[SQL] Text->Date conversion in a WHERE clause

2005-10-12 Thread Collin Peters
ssumption I made that the offending row would not even be included as it should have already been discarded. Is this not the case?How can I overcome this problem? There appears to be no isDate() function in postgresql like there is in sql server. Regards, Collin Peters ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

[SQL] Using UPDATE FROM

2004-09-10 Thread Collin Peters
incorrectly or can postgres not handle this kind of UPDATE? Regards, Collin Peters ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your