Re: [SQL] PL argument max size, and doubt

2007-11-22 Thread Tom Lane
Martin Marques <[EMAIL PROTECTED]> writes: > Tom Lane escribió: >> Martin Marques <[EMAIL PROTECTED]> writes: >>> I have always heard that modification queries should be EXECUTED in PL. >>> AFAICR. >> >> Run far away from whatever source gave you that advice... > Sorry, it was with DDL commands

Re: [SQL] PL argument max size, and doubt

2007-11-22 Thread Martin Marques
Tom Lane escribió: > Martin Marques <[EMAIL PROTECTED]> writes: > >> I have always heard that modification queries should be EXECUTED in PL. >> AFAICR. > > Run far away from whatever source gave you that advice... Sorry, it was with DDL commands. ---(end of broadcast)--

Re: [SQL] SQL state: 22P02

2007-11-22 Thread Rodrigo De León
On Nov 22, 2007 11:24 AM, Franklin Haut <[EMAIL PROTECTED]> wrote: >num return > -- >0 0 >null false >1212 >a false >12ab false > > it´s possible get these results ? Try: SELECT NUM , CASE WHEN TRIM(NUM) ~

[SQL] SQL state: 22P02

2007-11-22 Thread Franklin Haut
Hi, I got the message "SQL state: 22P02" to produce: create table test (num varchar(20)); insert into test (num) values (null); select * from test where cast(num as int8) = 0;   --ok, no error insert into test (num) values ('123123'); select * from test where cast(num as int8) = 123123; 

Re: [SQL] dynmic column names inside trigger?

2007-11-22 Thread Bart Degryse
I don't really see how you could test a non-existing column. Here > if old.story is not null and new.story != old.story then > new.story = sanitize_text(new.story); you would always use fields from OLD and NEW otherwise you can't even create the trigger. If a table has 3 fields (field1, field2 a

Re: [SQL] dynmic column names inside trigger?

2007-11-22 Thread Louis-David Mitterrand
On Tue, Nov 20, 2007 at 11:56:02AM -0500, Tom Lane wrote: > Louis-David Mitterrand <[EMAIL PROTECTED]> writes: > > I'd like to use it on other tables an columns but how can the column > > name be dynamic inside the procedure. > > It can't --- plpgsql has no support for that. You could probably m

Re: [SQL] dynmic column names inside trigger?

2007-11-22 Thread Louis-David Mitterrand
On Wed, Nov 21, 2007 at 09:14:14AM +0100, Bart Degryse wrote: > I would do something like this (not tested, but conceptually working): Hello, > BEGIN > if old.story is not null and new.story != old.story then > new.story = sanitize_text(new.story); > end if; > --checks on other field can be inc

Re: [SQL] How to have a unique primary key on two tables

2007-11-22 Thread D'Arcy J.M. Cain
On Thu, 22 Nov 2007 12:11:20 +0100 "Bart Degryse" <[EMAIL PROTECTED]> wrote: > When you use serial a kind of macro is performed: in fact an integer field is > created, a sequence is created with a name based on the table's name and the > nextval of that sequence is used as the default value for t

Re: [SQL] Bad Schema Design or Useful Trick?

2007-11-22 Thread Richard Huxton
Richard Broersma Jr wrote: Below I've included sample table definitions for a vertically partitioned disjunctive table hierarchy. I wanted to point out the use of the composite primary key declaration that is applied to two columns that are clearly not a candidate key. However, using the badly

Re: [SQL] Loading 8.2 data into 8.1

2007-11-22 Thread Peter Eisentraut
Am Dienstag, 20. November 2007 schrieb Andreas Joseph Krogh: > Is it considered "safe" to use 8.1's pg_dump to dump an 8.2-db and load it > into 8.1? No, pg_dump will complain if you try that. It could work, with manual fixups perhaps, but it is far from "safe". -- Peter Eisentraut http://deve

Re: [SQL] How to have a unique primary key on two tables

2007-11-22 Thread A. Kretschmer
am Thu, dem 22.11.2007, um 12:01:59 +0100 mailte Daniel bodom_lx Graziotin folgendes: > Hi everybody, > I need to have a primary key which has to be unique on two tables. > E.g.: > > CREATE TABLE first > ( > id serial NOT NULL, > testo text, > ) > > CREATE TABLE second > ( > id serial NOT

Re: [SQL] How to have a unique primary key on two tables

2007-11-22 Thread Bart Degryse
When you use serial a kind of macro is performed: in fact an integer field is created, a sequence is created with a name based on the table's name and the nextval of that sequence is used as the default value for the field. Now you have to do these steps "manually". CREATE SEQUENCE "public"."t

[SQL] How to have a unique primary key on two tables

2007-11-22 Thread Daniel "bodom_lx" Graziotin
Hi everybody, I need to have a primary key which has to be unique on two tables. E.g.: CREATE TABLE first ( id serial NOT NULL, testo text, ) CREATE TABLE second ( id serial NOT NULL, testo text, ) When I insert some text on "first", I would like first.id = second.id + 1, and vice versa.