[SQL] select multiple immediate values, but in multiple rows

2005-03-14 Thread Luca Pireddu
Hello all. I'd like to write a query does a set subtraction A - B, but A is is a set of constants that I need to provide in the query as immediate values. I thought of something like select a from (1,2,3.4) except select col_name from table; but I don't know the syntax to specify my set of co

Re: [SQL] postgresql 8.01, plpgsql

2005-03-14 Thread Michael Fuhr
On Tue, Mar 15, 2005 at 01:38:00PM +1000, Timothy Smith wrote: > ok i tried loading it from a file like you suggested and this is what i > got for MY function > > \i /home/timothy/function > psql:/home/timothy/function:35: ERROR: unterminated dollar-quoted > string at or near "$$ Could you at

[SQL] re postgresql 8.01 plpgsql

2005-03-14 Thread Timothy Smith
problem sovled. i was still in psql from 7.4, i only upgraded this morning and left it on there. it was the source of all my grief. ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail c

Re: [SQL] postgresql 8.01, plpgsql

2005-03-14 Thread Timothy Smith
Michael Fuhr wrote: On Tue, Mar 15, 2005 at 11:35:13AM +1000, Timothy Smith wrote: i have the following function in plpgsql giving stynax errors all over the place. When I load the function you posted I get this: test=> \i foo.sql psql:foo.sql:87: ERROR: syntax error at or near "END" at c

Re: [SQL] postgresql 8.01, plpgsql

2005-03-14 Thread Michael Fuhr
On Tue, Mar 15, 2005 at 11:35:13AM +1000, Timothy Smith wrote: > i have the following function in plpgsql giving stynax errors all over > the place. When I load the function you posted I get this: test=> \i foo.sql psql:foo.sql:87: ERROR: syntax error at or near "END" at character 2851 psql:fo

[SQL] postgresql 8.01, plpgsql

2005-03-14 Thread Timothy Smith
i have the following function in plpgsql giving stynax errors all over the place. i have doen createlang on the db, as far as i can see i'm right. is there anything obviously wrong? one thing to note is i followed this example http://www.zigo.dhs.org/postgresql/#insert_or_update and it gives th

[SQL] Generic Function

2005-03-14 Thread lucas
Hi, Can I built a generic function like: CREATE FUNCTION f (text) RETURNS TEXT as $$ return 'select * from $1'; $$ I know its impossible as writed. Also I have looked for EXECUTE procedure but it not run the correct function. Is there a way to construct this clause? Using plpgsql/pltcl/anyt

[SQL] Inserting values in arrays

2005-03-14 Thread Robert . Farrugia
I have the following issue. Given the following tables: CREATE TABLE test ( details varchar[]); CREATE TABLE test2 ( textvalue1 varchar, textvalue2 varchar); INSERT INTO test2 VALUES ('Hello1', 'World1'); INSERT INTO test2 VALUES ('hello2', 'World2'); I would like to insert a row in test for ea

Re: [SQL] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-14 Thread Lance Peterson
Christoph, is that recent functionality? I'm running 7.4 and I get: ERROR: cannot cast type text to bytea I get similar errors when trying to go the other direction. On Mon, 14 Mar 2005 11:32:26 +0100, Christoph Haller <[EMAIL PROTECTED]> wrote: > "Moran.Michael" wrote: > > > > Hello all, > > >

Re: [SQL] Newbie wonder...

2005-03-14 Thread Rod Taylor
On Mon, 2005-03-14 at 10:02 +0100, PFC wrote: > If you want to add a SERIAL field to an existing table, create a > sequence > and then create an integer field with default nextval(seq) and postgres > will fill it automatically. The order in which it will fill it is not > guaranteed tho

Re: [SQL] lower and unicode

2005-03-14 Thread Miroslav Šulc
pginfo wrote: Hi, I am using --no-locale by init db. I readet that if I am using some locale the pg will work very slow. I don't remember reading it will be very slow. I just remember that I've read it will slow down some things (which I think is logical in this case). Have you noticed some speed

Re: [SQL] lower and unicode

2005-03-14 Thread pginfo
Hi, I am using --no-locale by init db. I readet that if I am using some locale the pg will work very slow. Have you noticed some speed penalty by using cs_CZ.utf8. regards, ivan. Miroslav Šulc wrote: pginfo wrote: Hi, I am uusing pg 8.0.1 on FreeBSD 5.3 but I am ready t use the version taht suppor

[SQL] How does the planner treat a table function.

2005-03-14 Thread KÖPFERL Robert
Hi, we have got some tables (uw?) and functions. One function is defined like get_abc(): SELECT a,b,c from table_x; What happens if I query something like SELECT a,b from get_abc() where a=5; while table_x is rather big? Will PSQL at first query all records of table_x and then apply a where

Re: [SQL] lower and unicode

2005-03-14 Thread Miroslav Šulc
pginfo wrote: Hi, I am uusing pg 8.0.1 on FreeBSD 5.3 but I am ready t use the version taht supports correct unicode. I think that should be fine. I use PostgreSQL 8.0.1 on Linux (Gentoo) without these problems (I used cs_CZ.utf8 to init my db). What you write seems to me that you have your data

Re: [SQL] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-14 Thread Christoph Haller
"Moran.Michael" wrote: > > Hello all, > > I have a table with a VARCHAR column that I need to convert to a BYTEA. > > How do I cast VARCHAR to BYTEA? > > The following doesn't seem to work as it yields the 'cannot cast varchar to > bytea' error message: > > varchar_data::bytea > > On the

Re: [SQL] lower and unicode

2005-03-14 Thread pginfo
Hi, I am uusing pg 8.0.1 on FreeBSD 5.3 but I am ready t use the version taht supports correct unicode. regards, ivan. Miroslav Šulc wrote: Are you using PostgreSQL on Windows? If so, you should read the FAQ here http://pginstaller.projects.postgresql.org/FAQ_windows.html#2.6. On Windows, UNICO

Re: [SQL] Newbie wonder...

2005-03-14 Thread PFC
If you want to add a SERIAL field to an existing table, create a sequence and then create an integer field with default nextval(seq) and postgres will fill it automatically. The order in which it will fill it is not guaranteed though ! However, you might also like to de-dupe your data once

Re: [SQL] group by before and after date

2005-03-14 Thread PFC
I have 2 tables 1 has a date field and component need by that date and the other has all the upcoming orders. I am trying to build a query that will give me the Date and ComponentNeed and also how many components have been ordered before that date and how many after. PostGreSQL is telling me I

Re: [SQL] How to cast VARCHAR to BYTEA and vice-versa?

2005-03-14 Thread Ragnar Hafstað
On Tue, 2005-03-08 at 07:31 -0800, Moran.Michael wrote: > Hello all, > > I have a table with a VARCHAR column that I need to convert to a BYTEA. > > How do I cast VARCHAR to BYTEA? have you looked at the encode() and decode() functions ? http://www.postgresql.org/docs/7.4/interactive/functions

Re: [SQL] finding schema of table that called a trigger

2005-03-14 Thread Richard Huxton
Jeff Hoffmann wrote: Is there a variable defined that has the schema of the table that called the trigger (like TG_RELNAME = table name)? I didn't see anything in the documentation. Is the only way to get that to look it up with TG_RELID? I must admit I don't know of one. Hmm - it would obviou

Re: [SQL] lower and unicode

2005-03-14 Thread Miroslav Šulc
Are you using PostgreSQL on Windows? If so, you should read the FAQ here http://pginstaller.projects.postgresql.org/FAQ_windows.html#2.6. On Windows, UNICODE (UTF8) is not supported because Windows natively supports only UTF16 (I'm just repeating something I have read somewhere). Miroslav pginf

Re: [SQL] sql: "LIKE" problem

2005-03-14 Thread Richard Huxton
Her Goo wrote: > I am using "postgresql-7.3.2-1" now! > > I met a problem when using "LIKE" in "WHERE" clause. > For example, a table named "t_test", and its data looks like below: > > # SELECT * FROM t_test; > id | c_name > + > 1 | abc\ > 2 | abc\de > (2 rows) > # SELECT * FRO