Re: [SQL] dynmic column names inside trigger?

2007-11-21 Thread Bart Degryse
I would do something like this (not tested, but conceptually working): CREATE or replace FUNCTION sanitize_text(webtext IN text, cleantext OUT text) AS $body$ BEGIN cleantext = translate(webtext, E'\x92\x96', '''-'); cleantext = regexp_replace(cleantext, E'\x9c', 'oe', 'g'); cleantext = regexp_re

[SQL] PL argument max size, and doubt

2007-11-21 Thread Martin Marques
I was doing some tests to see if I could find a max size for an argument of type TEXT in a PL/PgSQL function (BTW, which it that limit if it exists?). So I made the function to test: CREATE OR REPLACE FUNCTION datoGrande(TEXT) RETURNS BOOLEAN AS $body$ BEGIN EXECUTE $ins1$ INSERT INTO funcdatogra

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

2007-11-21 Thread Rodrigo De León
On Nov 21, 2007 8:23 AM, Martin Marques <[EMAIL PROTECTED]> wrote: > (BTW, which it that limit if it exists?). "In any case, the longest possible character string that can be stored is about 1 GB." See: http://www.postgresql.org/docs/8.2/static/datatype-character.html > So I made the function to

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

2007-11-21 Thread Martin Marques
Rodrigo De León escribió: On Nov 21, 2007 8:23 AM, Martin Marques <[EMAIL PROTECTED]> wrote: (BTW, which it that limit if it exists?). "In any case, the longest possible character string that can be stored is about 1 GB." See: http://www.postgresql.org/docs/8.2/static/datatype-charact

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

2007-11-21 Thread Tom Lane
Martin Marques <[EMAIL PROTECTED]> writes: > Rodrigo De León escribió: >> "In any case, the longest possible character string that can be stored >> is about 1 GB." >> > I was asking about the limit in the argument. Is it the same as the > limits the types have in table definition? Yeah, ultima

[SQL] update on join ?

2007-11-21 Thread Andreas
Hi, I'd like to update a table efficiently where the relevant select-info is in another table that is foreign-linked. Stupid example. 2 tables: things (thing_id integer, name varchar(100), color varchar(100)) inventory (item_id integer, thing_fk integer references things (thing_id), number)

Re: [SQL] update on join ?

2007-11-21 Thread Frank Bax
Andreas wrote: I'd like to update a table efficiently where the relevant select-info is in another table that is foreign-linked. Stupid example. 2 tables: things (thing_id integer, name varchar(100), color varchar(100)) inventory (item_id integer, thing_fk integer references things (thing_id

Re: [SQL] update on join ?

2007-11-21 Thread Richard Broersma Jr
--- On Wed, 11/21/07, Andreas <[EMAIL PROTECTED]> wrote:> > UPDATE inventory > SET number = 0 > WHERE thing_fk IN (SELECT thing_id FROM things WHERE color > = 'red') This is a perfectly acceptable ANSI-SQL update statement. Here is non-ANSI update statement that you are probably after: UPDATE

Re: [SQL] update on join ?

2007-11-21 Thread chester c young
> I tried > > UPDATE things JOIN inventory ON things.thing_id = inventory.thing_fk > SET number = 0 > WHERE color = 'red' > use the cool "from" clause in the update update things t set number = 0 from inventory i where t.thing_id = i.thing_fk and i.color = 'red'; _

[SQL] Bad Schema Design or Useful Trick?

2007-11-21 Thread Richard Broersma Jr
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 defined primary key allows