Re: [SQL] insert a sequence

2007-05-11 Thread Ireneusz Pluta
ivan marchesini napisał(a): Dear postgres Users, I have a simple question I think. I have a table that contains some columns one of these columns (the columns ID) contains distinct integer values ... I need to insert into this table some other records but I only need that values were inserted int

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread Gábriel Ákos
On Fri, 11 May 2007 19:09:07 +0500 imad <[EMAIL PROTECTED]> wrote: > You might be looking for PostgreSQL RECORD data type. Thanks. Give me an example please. I saw the documentation already. > > --Imad > www.EnterpriseDB.com > > On 5/11/07, Gábriel Ákos <[EMAIL PROTECTED]> wrote: > > Hi, > > >

[SQL] PL/PGSQL Record type question

2007-05-11 Thread Gábriel Ákos
Hi, How should I define a record type (there is no table with this record type) programmatically in pl/pgsql? I'd like to return a record with 3 string elements, 2 integers and 1 date. Rgds, Akos -- Üdvözlettel, Gábriel Ákos -=E-Mail :[EMAIL PROTECTED]|Web: http://www.i-logic.hu =- -=Tel/fax

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread imad
You might be looking for PostgreSQL RECORD data type. --Imad www.EnterpriseDB.com On 5/11/07, Gábriel Ákos <[EMAIL PROTECTED]> wrote: Hi, How should I define a record type (there is no table with this record type) programmatically in pl/pgsql? I'd like to return a record with 3 string elements

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread John DeSoi
You can use CREATE TYPE: http://www.postgresql.org/docs/8.2/interactive/sql-createtype.html Example from the documentation: CREATE TYPE compfoo AS (f1 int, f2 text); Then make your function return compfoo (or setof compfoo). Alternately, you can define your function with out or in/out par

[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] Convert serial column to regular integer

2007-05-11 Thread Rodrigo De León
On 5/11/07, Collin Peters <[EMAIL PROTECTED]> wrote: 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 no

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread imad
create a function with return type as a RECORD. CREATE FUNCTION xyz() RETURNS record AS $$ declare abc RECORD; begin abc := (1, 2); return abc; end; $$ language plpgsql; And execute the function in this fashion: select a, b from xyz() as (a int, b int); Do you like that ... :-) --Imad www

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread Robins
Hi Gabriel, There are two ways to do this: 1. Imad's way (Define the function with the return type as RECORD). Its only problem is that while querying from this function, you need to give a proper SELECT query or else PG returns an error. e.g. As Imad gives in his example ... CREATE FUNCTION x

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread imad
On 5/11/07, Robins <[EMAIL PROTECTED]> wrote: Hi Gabriel, There are two ways to do this: 1. Imad's way (Define the function with the return type as RECORD). Its only problem is that while querying from this function, you need to give a proper SELECT query or else PG returns an error. Yeah ...

Re: [SQL] Convert serial column to regular integer

2007-05-11 Thread Tom Lane
"=?ISO-8859-1?Q?Rodrigo_De_Le=F3n?=" <[EMAIL PROTECTED]> writes: > On 5/11/07, Collin Peters <[EMAIL PROTECTED]> wrote: >> Is there any way to remove the sequence fully? > ALTER SEQUENCE dtab_i_seq OWNED BY NONE; Pre-8.2 that command doesn't exist, but you can get the same effect if you manually

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] check_constraint and Extract not working?

2007-05-11 Thread Fernando Hevia
Just to be sure I am getting this right: I have a big table I want to partition: create table big_table ( row_date timestamp with time zone, row_data character varying(80) }; A nice solution would be to spread its rows in one of 12 child tables according to which month the date f