Re: [SQL] Returning a set from an function

2006-04-10 Thread codeWarrior
Keith: This is the general approach I use over and over and over -- This is a PLPGSQL function that returns a SETOF tablename%ROWTYPE If you need the full schema and table and everything that goes with this -- let me know --- CREATE OR REPLACE FUNCTION sys_aclsubmenu(int4) RETURNS SETOF sys

[SQL] how to use recursion to find end nodes of a tree

2006-04-10 Thread mike
Hello All, I have been having a really hard time trying to come up with a pl/pgsql recursive function to returns the end nodes of a tree. Here is an example table definition: CREATE TABLE parent_child ( parent_id integer NOT NULL, child_id integer NOT NULL ); INSERT INTO parent_child (parent_i

Re: [SQL] how to use recursion to find end nodes of a tree

2006-04-10 Thread Yasir Malik
Hello All, I have been having a really hard time trying to come up with a pl/pgsql recursive function to returns the end nodes of a tree. Here is an example table definition: CREATE TABLE parent_child ( parent_id integer NOT NULL, child_id integer NOT NULL ); INSERT INTO parent_child (parent_id

Re: [SQL] have you feel anything when you read this ?

2006-04-10 Thread Markus Schaber
Hi, Eugene, Eugene E. wrote: > he did not request this representation. it is _by_default_ He used a function that provided it by default. He could use the other function that allows him to select which representation he wants. > if you wish to provide it by request, please do it. I cannot prov

[SQL] concatenation with a null column (using ||) nulls the result?

2006-04-10 Thread Neil Harkins
inventory=> SELECT cabinets_name, cabinets_description FROM cabinets WHERE cabinets_datacenters = 2; cabinets_name | cabinets_description ---+-- 548-4th-Cab2 | 548-4th-RR1 | 548-4th-RR2 | 548-4th-Cab1 | (4 rows) inventory=> SELECT cabinets_name || ' - '

Re: [SQL] concatenation with a null column (using ||) nulls the result?

2006-04-10 Thread Tom Lane
Neil Harkins <[EMAIL PROTECTED]> writes: > Is this standard SQL behavior? Yes. SQL92 6.13 , general rule 2: 2) If is specified, then let S1 and S2 be the re- sult of the and , respectively. a) If either S1 or S2 is the null value, then the result

Re: [SQL] concatenation with a null column (using ||) nulls the result?

2006-04-10 Thread Alvaro Herrera
Neil Harkins wrote: > Note: The cabinets_description for the "548-4th-Cab1" row is " ", > not NULL, hence it being displayed. Is this standard SQL behavior? Yes; something || NULL yields NULL. If you want NULL to behave as "" for the purpose of the concatenation, try SELECT cabinets_name || '

Re: [SQL] concatenation with a null column (using ||) nulls the result?

2006-04-10 Thread Terry Lee Tucker
On Monday 10 April 2006 05:55 pm, Alvaro Herrera saith: > Neil Harkins wrote: > > Note: The cabinets_description for the "548-4th-Cab1" row is " ", > > not NULL, hence it being displayed. Is this standard SQL behavior? > > Yes; something || NULL yields NULL. If you want NULL to behave as "" > for

Re: [SQL] concatenation with a null column (using ||) nulls the

2006-04-10 Thread Ross Johnson
On Mon, 2006-04-10 at 14:36 -0700, Neil Harkins wrote: > inventory=> SELECT cabinets_name, cabinets_description > FROM cabinets WHERE cabinets_datacenters = 2; > cabinets_name | cabinets_description > ---+-- > 548-4th-Cab2 | > 548-4th-RR1 | > 548-4th-RR2 |

Re: [SQL] how to use recursion to find end nodes of a tree

2006-04-10 Thread Ross Johnson
On Mon, 2006-04-10 at 16:09 +0100, [EMAIL PROTECTED] wrote: > Hello All, > > I have been having a really hard time trying to come up with a pl/pgsql > recursive function to returns the end nodes of a tree. > Here is an example table definition: > > CREATE TABLE parent_child ( > parent_id intege

[SQL] global variables in plpgsql?

2006-04-10 Thread dave . bath
Folks, In v8.0.3 documentation, plperl, plpython and pltcl allow declaration of variables that are global and persistent within a session. begin_quote 37.4. Global Values in PL/Perl You can use the global hash %_SHARED to store data, including code references, between function calls for the lifet

[SQL] GROUP BY issue

2006-04-10 Thread Jure Kodzoman (Dhimahi)
Hy list. I have 3 tables: performance event pool_performance each event has it's performances, and can be assigned to one or more pools. pool_performance holds performance_id, pool_id and from_date performance has event_id and performance_id as primary key what I want to do is select min(p

[SQL] slow 'IN' clause

2006-04-10 Thread FavoYang
I have a slow sql: SELECT * FROM mytable WHERE id IN (1,3,5,7,3k here...); mytable is about 10k rows. if don't use the "IN" clause, it will cost 0,11 second, otherwise it will cost 2.x second I guess pg use linear search to deal with IN clause, is there any way to let pg use other search metho

[SQL] Special meaning of NL string

2006-04-10 Thread Vellinga, Fred
Title: Message Hello,   I wonder if there is an issue with the string 'NL'. In my application NL stands for Netherlands and is thus a country code abreviation.   The query   SELEC

Re: [SQL] [GENERAL] pgcrypto-crypt

2006-04-10 Thread Chris
AKHILESH GUPTA wrote: how do we compare the existing data in the table with the entered one? same way as anything else, for example: select * from users where passwd=md5('my_password'); is there any other function which we can use here for both cases encryption as well as for decryption at t

[SQL] Joins involving functions

2006-04-10 Thread Jeff Boes
I have a function that returns a row from a table, e.g.: create table foo (a integer); create function f_foo (integer) returns foo language 'sql' as $foo$ select * from foo where a = $1 limit 1 $foo$ create table bar (b integer); select * from bar cross join f_foo(bar.b) as foo; Unfortunatel

Re: [SQL] [GENERAL] pgcrypto-crypt

2006-04-10 Thread chris smith
On 4/6/06, AKHILESH GUPTA <[EMAIL PROTECTED]> wrote: > dear all, > i want to encrypt and decrypt one of the fields in my table (i.e-password > field) > i have searched and with the help of pgcrypto package, using function > "crypt", i am able to encrypt my data, > but there is nothing which i fo

Re: [SQL] Special meaning of NL string

2006-04-10 Thread Tom Lane
"Vellinga, Fred" <[EMAIL PROTECTED]> writes: > The query > SELECT COUNT(*) FROM Table WHERE Field1 = 'NL' OR Field2 = 'NL' > does a sequence scan instead of an index scan, and is thus very slow. If I > replace NL by BE (Belgium) the query does an index scan. Probably, 'NL' is a lot more common tha

Re: [SQL] global variables in plpgsql?

2006-04-10 Thread John DeSoi
On Apr 10, 2006, at 9:17 PM, [EMAIL PROTECTED] wrote: So, a couple of questions 1) Can you declare global values from plpgsql? 2) If so, is there a way of avoiding namespace pollution? (perhaps the equivalent to Oracle's use of plsql package variables) plpgsql does not have global v