Re: [SQL] Function returns error (view)

2008-02-27 Thread Bart Degryse
Please send the complete DDL for your function and the tables it uses. Also inform us of the database version you're using. >>> "Professor Flávio Brito" <[EMAIL PROTECTED]> 2008-02-27 21:42 >>> Hi After I did it I received it SELECT * FROM search_password('Paul'); ERROR: set-valued functi

Re: [SQL] operator class

2008-02-27 Thread Tom Lane
"miquel_ibanez" <[EMAIL PROTECTED]> writes: > CREATE TYPE t_cod_t_activ AS ( > cod_t_activ CHAR(10) > ); If you just want an alias for char(10), a domain would probably work better. CREATE TYPE AS is meant for creating multi-field row types. > Does it mean that I cannot create

Re: [SQL] Subselects returning array and ANY...

2008-02-27 Thread Josh Berkus
Dawid, > But you are right, though! I just need to leave off the subselect! > Thanks! SELECT h.* FROM haystack h JOIN needles ON straw = ANY (straws); > > (not exactly what I was looking for, but it works ;)) Yeah, the problem with your first query is that it's returning a rowset of arrays, no

Re: [SQL] Subselects returning array and ANY...

2008-02-27 Thread Dawid Kuroczko
On Thu, Feb 28, 2008 at 1:11 AM, Josh Berkus <[EMAIL PROTECTED]> wrote: > Dawid, > >SELECT * FROM foo WHERE t = ANY (SELECT '{x4,5,zzz}'::text[]); > > ERROR: operator does not exist: text = text[] > > HINT: No operator matches the given name and argument type(s). You > > might need to add

Re: [SQL] Subselects returning array and ANY...

2008-02-27 Thread Josh Berkus
Dawid, >SELECT * FROM foo WHERE t = ANY (SELECT '{x4,5,zzz}'::text[]); > ERROR: operator does not exist: text = text[] > HINT: No operator matches the given name and argument type(s). You > might need to add explicit type casts. Drop the second SELECT, I think. postgres=# select 'x' = ANY

[SQL] Subselects returning array and ANY...

2008-02-27 Thread Dawid Kuroczko
A simple text case =# CREATE TEMP TABLE foo (t text); CREATE TABLE =# INSERT INTO foo SELECT 'x'||n FROM generate_series(1,100) AS x(n); INSERT 0 100 This works: SELECT * FROM foo WHERE t = ANY ('{x4,5,zzz}'::text[]); And this works too: SELECT * FROM foo WHERE t IN (SELECT t FROM foo LIMIT

[SQL] operator class

2008-02-27 Thread miquel_ibanez
Hello I have just started with postgreSQL. I have a file with the following commands : CREATE TYPE t_cod_t_activ AS ( cod_t_activ CHAR(10) ); CREATE TABLE tip_activ ( id_tip_activt_cod_t_activ, des_t_activ t_des_t_activ

Re: [SQL] Function returns error (view)

2008-02-27 Thread Professor Flávio Brito
Hi After I did it I received it SELECT * FROM search_password('Paul'); ERROR: set-valued function called in context that cannot accept a set SQL state: 0A000 Context: PL/pgSQL function "search_password(" line 14 at return next Error at WHERE login= Paul ?? Thanks for your help Flávio 2008/

Re: [SQL] SQL standards in Mysql

2008-02-27 Thread Steve Crawford
Dean Gibson (DB Administrator) wrote: ...For example, I think phpBB is the only major message board software that supports PostgreSQL (see http://www.phpbb.com/about/features/compare.php ), and in fact has for some time. Of course, they have a DB abstraction layer (wow, what an concept!), whi

Re: [SQL] how do I get table DDL from psql (not from pg_dump)

2008-02-27 Thread Frank Bax
Sofer, Yuval wrote: I need to extract table DDL (create script) from database connection (using sql, by retrieving system table info or by activating some pg function) This command should output the SQL you need... echo '\d tablename' | psql -E ---(end of broadcast

Re: [SQL] REFERENCES and INHERITS restrictions?

2008-02-27 Thread Gregory Stark
"Stefan Scheidegger" <[EMAIL PROTECTED]> writes: > Why is this not possible? It seems that this is about inheritance. When I > reference directly to tbl_child1, everything works just fine. I'm afraid inheritance doesn't work with foreign key references. You can have references to specific tables

Re: [SQL] how do I get table DDL from psql (not from pg_dump)

2008-02-27 Thread A. Kretschmer
am Wed, dem 27.02.2008, um 5:22:33 -0600 mailte Sofer, Yuval folgendes: > Hi > > > > I need to extract table DDL (create script) from database connection (using > sql, by retrieving system table info or by activating some pg function) > > > > Is this possible in postgres? Why not using p

[SQL] how do I get table DDL from psql (not from pg_dump)

2008-02-27 Thread Sofer, Yuval
Hi I need to extract table DDL (create script) from database connection (using sql, by retrieving system table info or by activating some pg function) Is this possible in postgres? Please help Thanks Yuval Sofer BMC Software CTM&D Business Unit DBA Team 972-52-4286-282 [EMAI

Re: [SQL] Function returns error (view)

2008-02-27 Thread Markus Bertheau
2008/2/27, Bart Degryse <[EMAIL PROTECTED]>: > > > For rather "simple" queries like this one PostgreSQL indeed seems to be > quite smart. > I have quite a lot of statements where it does make a difference though > (PostgreSQL 8.2.4). I would rather find a situation where an explicit join is planne

[SQL] REFERENCES and INHERITS restrictions?

2008-02-27 Thread Stefan Scheidegger
Hi all I’m confronted with the following problem: I have a base table with several child tables which also use the parent’s primary key as their own primary key: CREATE TABLE tbl_parent ( p_id serial NOT NULL, p_time timestamp(6) with time zone NOT NULL DEFAULT '1970-01-01 01:00:00+01'::

Re: [SQL] Function returns error (view)

2008-02-27 Thread Bart Degryse
For rather "simple" queries like this one PostgreSQL indeed seems to be quite smart. I have quite a lot of statements where it does make a difference though (PostgreSQL 8.2.4). As long as I have one statement where it makes a difference I will use the join rather than the IN(subselect) just to b

Re: [SQL] Function returns error (view)

2008-02-27 Thread Markus Bertheau
2008/2/27, Bart Degryse <[EMAIL PROTECTED]>: > > I would also suggest you replace the > ...t.cod_user IN (subselect) > by a join construction. I think it's more performant. In recent versions PostgreSQL is quite smart when planning IN, so that shouldn't be a concern. Markus -- Markus Bertheau B