Re: [SQL] Multiple Databases

2002-10-23 Thread Joe Conway
L 7.3 (in beta testing now) the syntax and usability of contrib/dblink is greatly improved. Joe ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Generating a cross tab (pivot table)

2002-11-07 Thread Joe Conway
find the functions useful and provide suggestions for improvement in functionality I'll try to upgrade them for 7.4. Thanks, Joe ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Proposal of hierarchical queries, a la Oracle

2002-11-16 Thread Joe Conway
reSQL 7.3, as a /contrib module, by Joe Conway. Download 7.3b5 now if you can't wait; Joe would like more people to test his module, anyway. I have it on my personal TODO to approach this for 7.4, but I'll be happy to focus on other things if you'd like to take this on. The conn

Re: [SQL] execute a query in an other db

2002-11-16 Thread Joe Conway
LR wrote: Thank you for your answer. Do you know the name of this package ? Thx Lilian see contrib/dblink. I'd highly recommend using 7.3 (finishing beta, soon to be a release candidate) if you can. It is much better than the one in 7.2 and the syntax has changed some.

Re: [SQL] Proposal of hierarchical queries, a la Oracle

2002-11-19 Thread Joe Conway
Evgen Potemkin wrote: Joe, i've made it already,as send first 'Proposal ...' message, but found a small bug. within nearest days i'll fix it, and post the patch to pgsql-patches. Please note that there was no patch attached to your initial proposal (assuming this is

Re: [SQL] Trees: maintaining pathnames

2002-11-20 Thread Joe Conway
refer to keep the pathname in the same table. In my application, I have about 120,000 nodes in the tree. I am using PL/pgSQL quite a lot. Perhaps moving the triggers to C at a later date may provide a speed increase if the tree expands considerably. I've tested connectby() on a table

Re: [SQL] SQL syntax for concating values in different rows together

2002-12-10 Thread Joe Conway
cat -- Comp = my #1 complaint: Res# 1 = fixed it: Res# 2 = really fixed it! Comp = my #2 complaint: Res# 1 = pbkbac again (2 rows) In the past I think I remember someone trying to solve this kind of problem with a custom aggreg

Re: [SQL] DB2 to Postgresql conversion help.

2002-12-23 Thread Joe Conway
WEEN 1 AND 20 I'm not familiar with DB2, but I'd guess something like: SELECT ID,NAME,CITY,STATE,PROGRAM,CUST_NAME,CUST_ID FROM MERCHANT_BROWSER_VIEW WHERE CUST_ID = 'A51B8CA2' ORDER BY ID LIMIT 20; HTH, Joe ---(end of broadcast)

Re: [SQL] [GENERAL] 7.3.1 function problem: ERROR: cache lookup failed

2003-01-07 Thread Joe Conway
Achilleus Mantzios wrote: On Tue, 7 Jan 2003, Tom Lane wrote: Does your function know about filling in the elemtype field that was recently added to struct ArrayType? She has no clue :) Any pointers would be great. See construct_array() in src/backend/utils/adt/arrayfuncs.c. HTH, Joe

Re: [SQL] Could someone help me fix my array_list function?

2003-01-20 Thread Joe Conway
_mailbox, a_destination_el FROM mail_aliases_list(); a_mailbox | a_destination_el ---+-- alias1| dest1 alias2| dest2 alias2| dest1 alias3| dest3 alias3| dest4 alias4| dest3 alias4| dest4 alias4| dest5 alias5| dest6 alias5| dest7 alias6| dest3 alias6| dest7 alias6| dest4 alias6| dest5 (14 rows) HTH, Joe ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Could someone help me fix my array_list function?

2003-01-20 Thread Joe Conway
| grp1| 102 | user3 101 | grp2| 100 | user1 101 | grp2| 102 | user3 (5 rows) Joe ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL

Re: [SQL] Postgres MD5 Function

2003-01-31 Thread Joe Conway
nction: regression=# select md5('Joe'); md5 -- 3a368818b7341d48660e8dd6c5a77dbe (1 row) HTH, Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Postgres MD5 Function

2003-02-02 Thread Joe Conway
David Durst wrote: Is there anywhere I can get these in binary? Or is my only option to compile Postgres from source?? Depends on the type of binary. E.g. there is a postgresql-contrib-7.3.1-1PGDG.i386.rpm binary available here: ftp://ftp.us.postgresql.org/binary/v7.3.1/RPMS/redhat-7.3/ Joe

Re: [SQL] plpgsql + dblink() question

2003-02-07 Thread Joe Conway
icitly set. Something like this should set a 5 second timeout: select * into tmp from dblink(''host=linux dbname=twins connect_timeout=5'', ''select mysleep();'') as (retval text); See: http://www.us.postgresql.org/users-lounge/docs/7.3/postgres/libpq-connect.htm

Re: [SQL] generic return for functions

2003-06-01 Thread Joe Conway
t I don't think Oracle will support what you want either. Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] "Join" on delimeter aggregate query

2003-06-08 Thread Joe Conway
ression=# select source, tgtlist(target) from src2tgt group by source; source| tgtlist -+--- [EMAIL PROTECTED] | [EMAIL PROTECTED],[EMAIL PROTECTED] [EMAIL PROTECTED] | [EMAIL PROTECTED],[EMAIL PROTECTED] (2 rows) HTH, Joe --

Re: [SQL] Using a RETURN NEXT

2003-06-08 Thread Joe Conway
eturn setof word_case_type) SELECT * FROM word_case(); HTH, Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Catching DML exceptions in PL/pgSQL

2003-06-17 Thread Joe Conway
way to "catch" the exception in PL/pgSQL, but maybe the above would work for you. HTH, Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Joe Conway
est -- b c (2 rows) Doesn't help for 7.3.x, but at least you know help is on the way ;-) Of course, you could always just use the case statement. Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Joe Conway
Joe Conway wrote: In 7.4devel (just starting beta) you can do this: Actually to correct myself, we just started "feature freeze" for 7.4, with beta planned to start on or about July 15th. Sorry for any confusion caused. Joe ---(end of

Re: [SQL] LEAST and GREATEST functions?

2003-07-01 Thread Joe Conway
'select $1[$2]' language 'sql'; regression=# select myelement(array[11,22,33,44,55], 2); myelement --- 22 (1 row) Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] passing a record as a function argument in pl/pgsql

2003-07-01 Thread Joe Conway
ession=# select use_foo(get_foo(2)); use_foo - b (1 row) HTH, Joe ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] LEAST and GREATEST functions?

2003-07-02 Thread Joe Conway
'plpgsql'; select make_greatest(); Now you should have 31 "greatest" functions, accepting from 2 to 32 arguments. *Not* heavily tested, but seemed to work for me. regression=# select greatest(112,2,3,4,5,6,7,8,9,10,1234,2,3,4,5,66,7,8,9,10,1,27,3,4,5,6,347,8,9,10,1,2); greatest -- 1234 (1 row) I'll leave "least()" as an exercise for the reader ;-) HTH, Joe ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Database Upgrade scripts (AKA Conditional SQL execution)

2003-07-07 Thread Joe Conway
way (currently at least) to do this without some kind of function. I've done it in the past with PL/pgSQL. We've had brief discussions in the past about how this could be supported, but nothing conclusive, and no one has cared enough to scratch this particular itch. Joe -

Re: [SQL] Setuid functions

2003-07-08 Thread Joe Conway
R specifies that the function is to be executed with the privileges of the user that created it. The key word EXTERNAL is present for SQL compatibility but is optional since, unlike in SQL, this feature does not only apply to external functions. HTH, Joe --

Re: [SQL] Recursive request ...

2003-07-10 Thread Joe Conway
contrib/tablefunc. The function is called connectby(). HTH, Joe ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] Replacing a simple nested query?

2003-07-13 Thread Joe Conway
lem. I may be missing something, but why can't you just do: select * from attributes where name='obsid' and value='oid00066'; ? Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] Functional Indexes

2003-07-15 Thread Joe Conway
_part(substr(f1, 8, length(f1)), '/'::text, 1), '.'::text, 3) = 'com'::text) AND (split_part(split_part(substr(f1, 8, length(f1)), '/'::text, 1), '.'::text, 2) = 'foobar'::text)) Total runtime: 0.21 msec (3 rows) Joe ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] Recursive request ...

2003-07-17 Thread Joe Conway
BenLaKnet wrote: I see connect by in Oracle ??? is there an equivalent in PostgreSQL or not ?? Someone is working on the SQL99 equivalent, but it isn't done yet. Perhaps for 7.5. Joe ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] casting to arrays

2003-07-18 Thread Joe Conway
regression=# select * from person_with_stuff; id | name | stuff +--+ 1 | Bob | {chair,couch,lamp} 2 | Sue | {table,shirt} (2 rows) HTH, Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] casting to arrays

2003-07-18 Thread Joe Conway
uld I just get on the developers list? The closest thing is the TODO list: http://developer.postgresql.org/todo.php But if you want to closely monitor the work actually getting done, subscribe to the HACKERS list. Joe ---(end of broadcast)--- TIP 6:

Re: [SQL] How access to array component

2003-07-19 Thread Joe Conway
foo(10::int2, 20::int2))[1]; foo - 1 (1 row) HTH, Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] How access to array component

2003-07-21 Thread Joe Conway
7.3.3: test=# select f1[1] from (select foo(10::int2, 20::int2) as f1) as ss; f1 1 (1 row) HTH, Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] function returning setof performance question

2003-07-29 Thread Joe Conway
rmance on subsequent calls, if there are any; are you using persistent connections? Alternatively, it might work to use a prepared query. Joe ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] [PERFORM] EXTERNAL storage and substring on long strings

2003-08-04 Thread Joe Conway
re out what is going on. Is there a sample table schema and dataset available (external-storage case) that we can play with? Joe ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] [PERFORM] EXTERNAL storage and substring on long strings

2003-08-06 Thread Joe Conway
Scott Cain wrote: Oh, and I forgot to mention: it's highly compressed (bzip2 -9) and is 109M. Thanks. I'll grab a copy from home later today and see if I can find some time to poke at it. Joe ---(end of broadcast)--- TIP 1: sub

Re: [SQL] Comparing arrays

2003-08-14 Thread Joe Conway
issues with effective use of arrays. For instance, even if you got all this working, you'd find working with arrays in PL/pgSQL painful if not impossible. If you really depend on arrays, I'd strongly suggest testing on 7.4 beta and moving to 7.4 as soon as it is released. HTH Joe ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] "SELECT IN" Still Broken in 7.4b

2003-08-20 Thread Joe Conway
o where id = any (ARRAY[list_of_literals]); Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Table conversion query...

2003-08-20 Thread Joe Conway
C function. There are a couple of questions yet to be answered though: 1) Can there ever be more than one credit account, e.g. -30, -300, +150, +180? 2) What happens if sum(neg values) != sum(pos values)? Throw an error? Joe ---(end of broadcast)---

Re: [SQL] Table conversion query...

2003-08-20 Thread Joe Conway
.glcr := v_last_glcr; result.gldb := v_last_gldb[i]; result.amt := v_last_gldb_amt[i]; return next result; end loop; end if; return; end; ' language plpgsql; regression=# select * from reconcile(null); transdate | glcr | gldb | amt ---

Re: [SQL] How to return a record set from function.

2003-08-28 Thread Joe Conway
: http://www.postgresql.org/docs/view.php?version=7.3&idoc=0&file=xfunc-tablefunctions.html and http://techdocs.postgresql.org/guides/SetReturningFunctions HTH, Joe ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] length of array

2003-08-28 Thread Joe Conway
(1 row) See the following links for more on 7.4's array support: http://developer.postgresql.org/docs/postgres/arrays.html http://developer.postgresql.org/docs/postgres/functions-array.html http://developer.postgresql.org/docs/postgres/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS HTH, Joe -

Re: [SQL] length of array

2003-08-28 Thread Joe Conway
from t1; id |f1 +--- 1 | {1,2} 2 | {0,0,0} 3 | {0,0,0,0} 3 | {1,2,3,0} (4 rows) regression=# SELECT * FROM t1 WHERE COALESCE(f1[1],0) = 0 and COALESCE(f1[2],0) = 0 and COALESCE(f1[3],0) = 0 and COALESCE(f1[4],0) = 0; id |f1 +--- 2 | {0,0,0} 3 | {0,

Re: [SQL] Oracle 'connect by prior' now eaiser in 7.3?

2003-09-22 Thread Joe Conway
r 7.4 -- perhaps it will be in 7.5. In the meantime, connectby() is in 7.3 and might work for you. HTH, Joe ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] Mystery function error

2003-09-27 Thread Joe Conway
begin return position(searchstr in srcstr); end; ' LANGUAGE 'plpgsql' IMMUTABLE; This could also be done as: CREATE OR REPLACE FUNCTION public.locate(bpchar, bpchar) RETURNS int4 AS ' select position($2 in $1) ' LANGUAGE 'sql'; HTH, Joe

Re: [SQL] Mystery function error

2003-09-28 Thread Joe Conway
.00 rows=1 loops=1) Total runtime: 0.05 msec (2 rows) sql regression=# explain analyze select locate('abc','b'); QUERY PLAN ------ Result (cost=0.00..0.01 r

Re: [SQL] Oracle 'connect by prior' now eaiser in 7.3?

2003-10-14 Thread Joe Conway
'"REF_ID_WINUSER"', 4, 0, '~') AS t("ID_WINUSER" integer, "REF_ID_WINUSER" integer, level integer, branch text); HTH, Joe ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Which is faster SQL or PL/PGSQL

2003-10-20 Thread Joe Conway
when you upgrade to 7.4. HTH, Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] Which is faster SQL or PL/PGSQL

2003-10-20 Thread Joe Conway
Richard Huxton wrote: On Monday 20 October 2003 18:24, Joe Conway wrote: This question gets even more complex in 7.4, where many simple SQL functions will get inlined, and library preloading is available to speed that first PL/pgSQL call. What will be the effects of inlining? Does it mean the

Re: [SQL] Which is faster SQL or PL/PGSQL

2003-10-20 Thread Joe Conway
preloading (starting in 7.4), the first call to other PLs is similar to that of PL/pgSQL. See: http://archives.postgresql.org/pgsql-patches/2003-07/msg00239.php Joe ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] Crosstab question

2003-10-20 Thread Joe Conway
nt the one that says: "contrib/tablefunc backported for PostgreSQL 7.3.x -- sync'd with CVS HEAD 02-Oct-2003" HTH, Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Re: [SQL] Referring to derived column name in a RECORD

2003-10-24 Thread Joe Conway
r_app."joined_on"; (i.e. with double quotes) HTH, Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] connectby

2003-10-28 Thread Joe Conway
BenLaKnet wrote: I use postgresql 7.2.3 How can I use connectby ?? Must I install files ? or packages ? or it is recommanded to upgrade dataserver ? You need to upgrade. Either install 7.3.4 or wait a few weeks and install 7.4 when it is released. Joe ---(end of

Re: [SQL] Query Problem

2003-11-10 Thread Joe Conway
k text, vote int); insert into t values('01','02','c',10); insert into t values('01','02','b',5); regression=# select kk, kj, concat(pngk), sum(vote) from t group by kk, kj; kk | kj | concat | sum +++- 01 | 02 | c,b

Re: [SQL] Equivalent of Reverse() functions

2003-11-27 Thread Joe Conway
replace function reverse(text) returns text as ' return reverse($_[0]); ' language plperl; regression=# select reverse('abcdef'); reverse ----- fedcba (1 row) Joe ---(end of broadcast)--- TIP 2: you can get off all li

Re: [SQL] Scaler forms as function arguments

2003-11-27 Thread Joe Conway
Andreas Tille wrote: test=# select PLpgSQLDepartmentSalaries() ; This should be: regression=# select * from PLpgSQLDepartmentSalaries(); departmentid | totalsalary --+- 1 | 8 2 | 6 (2 rows) HTH, Joe

Re: [SQL] Scaler forms as function arguments

2003-11-27 Thread Joe Conway
'SQL' ; regression=# SELECT * FROM test(ARRAY[1,3]); id | idval +--- 1 | a 3 | c (2 rows) HTH, Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Seq Scans when index expected to be used

2003-11-29 Thread Joe Conway
seq scan is faster. Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] Seq Scans when index expected to be used

2003-11-29 Thread Joe Conway
nted. IIRC it's a hard problem due to the way Postgres does MVCC. Check the archives. explain analyze vs explain. Normally, would've used "explain analyze" but in this case it's taking way too long so I used "explain". I can understand that, but most people

Re: [SQL] Radius of a zip code

2003-12-26 Thread Joe Conway
Y LIMIT $numtoshow; "; return $sql; } The "X * 60 * 1.15078" converts differences in degrees lat/long into rough distances in miles. Hope this helps. Joe ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] Problem with plpgsql function

2004-01-15 Thread Joe Conway
ROM get_account_info('test.com'); HTH, Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Fetching a single column from a record returning function

2004-01-20 Thread Joe Conway
some light. What's wrong with: select msgcount from fn_email(1) as (email_folder_id int4,email_folder_name varchar,descrip varchar,msgcount int8,unreadcount int8,size int8); ? Try showing us more detail about what you want to do and why it isn't currently working. Joe --

Re: [SQL] array_lower /array_prepend doubt

2004-01-21 Thread Joe Conway
left-hand operand. For example: SELECT array_dims(1 || ARRAY[2,3]); array_dims [0:2] (1 row) SELECT array_dims(ARRAY[1,2] || 3); array_dims ---- [1:3] (1 row) " Joe ---(end of broadcast)--- TIP 9: the planner

Re: [SQL] array_lower /array_prepend doubt

2004-01-21 Thread Joe Conway
sion=# create table a(f1 int, f2 int[]); CREATE TABLE regression=# insert into a values (1,'{1,2}'); INSERT 565511 1 regression=# update a set f2[0] = 0 where f1 = 1; UPDATE 1 regression=# select array_dims(f2) from a; array_dims ---- [0:2] (1 row) Joe -

Re: [SQL] array_lower /array_prepend doubt

2004-01-21 Thread Joe Conway
99 defines an array as always having a lower bound of 1, making our behavior an extension to the standard. We may need another extension to the array literal syntax in order to deal with this. I'll report back after I've had some time to study it. Joe

Re: [SQL] How to retrieve N lines of a text field.

2004-01-29 Thread Joe Conway
EXIT; END IF; RETURN NEXT oneline; END LOOP; RETURN; END ' LANGUAGE 'plpgsql'; regression=# select * from first_n_lines('abc\ndef\nghi', 2); first_n_lines --- abc def (2 rows) HTH, Joe ---(end of br

Re: [SQL] array_lower /array_prepend doubt

2004-02-12 Thread Joe Conway
Bruce Momjian wrote: Is this a TODO? Probably -- something like: Modify array literal representation to handle array index lower bound of other than one Joe ---(end of broadcast)--- TIP 6: Have you searched our list archives? http

Re: [SQL] arrays and polygons

2004-02-13 Thread Joe Conway
1 row) You need to explicitly cast at least the first polygon in order to get an array of polygons (versus an array of text). HTH, Joe ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] crosstabs

2004-02-19 Thread Joe Conway
Philippe Lang wrote: I need to do something similar to a cross tabulation, but without any aggregation. See the crosstab() function found in contrib/tablefunc Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister

Re: [SQL] Compiling pl/pgsql functions

2004-02-19 Thread Joe Conway
Rodrigo Sakai wrote: I insist in my question, is there a way to compile the plpgsql codes or something like that no think about writting this postgres functions in C?? yes Joe ---(end of broadcast)--- TIP 9: the planner will ignore your desire

Re: [SQL] Scalar in a range (but textual not numeric)

2004-02-25 Thread Joe Conway
Richard Huxton wrote: That's not quite the same though, because it means I need to split ABCAA..ABDBB into ABCAA..ABCZZ and ABDAA..ABDZZ but it's close enough unless someone is feeling clever this evening. Would (a series of) partial indexes help? Joe

Re: [SQL] Last day of month

2004-02-25 Thread Joe Conway
too quick on the draw. Try this instead: regression=# select date_trunc('month', current_date + '1 month'::interval) - '1 day'::interval; ?column? - 2004-02-29 00:00:00 (1 row) Joe ---(end of broadcast)--

Re: [SQL] Trouble with composite types

2004-02-29 Thread Joe Conway
rue? Also, how do I add a member function to a type? What you are trying to do is currently unsupported. There have been multiple discussions in the past on this -- try searching the archives for more info. Joe ---(end of broadcast)--- TIP 6

Re: [SQL] plpgsql function returning SETOF RECORD Question

2004-02-29 Thread Joe Conway
tors_2(int) RETURNS SETOF record AS ' SELECT * FROM distributors WHERE did = $1; ' LANGUAGE SQL; SELECT * FROM distributors_2(111) AS (f1 int, f2 text); f1 | f2 -----+- 111 | Walt Disney HTH, Joe ---(end of broadcast)-

Re: [SQL] returning a recordset from PLpg/SQL

2004-03-01 Thread Joe Conway
t8); hid | context | width -+-+--- 1 | test1 | 2.8 2 | test2 | 3.28 (2 rows) regression=# select write_sql(4); write_sql ----- se

Re: [SQL] Encoding bytea

2004-03-03 Thread Joe Conway
ion=# select 'insert into t values(' || quote_literal(bytea2text(f)) || ');' from t; ?column? insert into t values('a\\003\\000\\001b'); (1 row) regression=# insert into t valu

Re: [SQL] Array_append does not work with Array variables in PL/pgSQL?

2004-04-01 Thread Joe Conway
an element to a NULL valued array, you wind up with a NULL result. It is similar to: regression=# select (NULL || 'abc') is null; ?column? -- t (1 row) Joe ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Array_append does not work with Array variables in PL/pgSQL?

2004-04-01 Thread Joe Conway
Josh Berkus wrote: BTW, did you get my e-mail to Hackers about ARRAY[] IS NULL? I saw it, but I've been too swamped to really read it. I'll try to carve out some time this afternoon. Joe ---(end of broadcast)--- TIP 5: Have you c

Re: [SQL] [pgsql-advocacy] SQL Spec Compliance Questions

2004-04-01 Thread Joe Conway
able. I really don't quite understand this, but I don't think we have it ;-) HTH, Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] [pgsql-advocacy] SQL Spec Compliance Questions

2004-04-02 Thread Joe Conway
reading it, I think it is related to (or at least similar to) the work Tom is currently doing to allow composite types as table attributes. Joe ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] SQL Standatd

2004-04-07 Thread Joe Conway
Bruce Momjian wrote: Martin Marques wrote: Also, for some reason I can't get to sqlstandards.org. Is there any other place where I can get the SQL200X docs? Not sure. See: http://www.wiscorp.com/sql/sql_2003_standard.zip Joe ---(end of broa

Re: [SQL] function returning array

2004-04-13 Thread Joe Conway
turns varchar[] results := parseString(''abc,def,ghi'','',''); tmpv := results[1]; RAISE NOTICE '' tmpv = % '',tmpv;-- tmpv will be null. END; How is parseString() defined? What Postgres version? Joe ---(end

Re: [SQL] function returning array

2004-04-15 Thread Joe Conway
27;'blah''" you still get NULL. It is similar to this: regression=# select NULL || 'blah'; ?column? -- (1 row) HTH, Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] Last day of month

2004-06-08 Thread Joe Conway
date_trunc('month', current_date + '1 month'::interval); date_trunc - 2004-03-01 00:00:00 (1 row) Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command

Re: [SQL] pivot-like transformation

2004-06-20 Thread Joe Conway
/static/arrays.html http://www.postgresql.org/docs/7.4/static/functions-array.html http://www.postgresql.org/docs/7.4/static/functions-comparisons.html http://www.postgresql.org/docs/7.4/static/sql-expressions.html#SQL-SYNTAX-ARRAY-CONSTRUCTORS HTH, Joe ---(end of broadcast

Re: [SQL] Empty array IS NULL?

2004-06-28 Thread Joe Conway
supported, attempting to construct an array with a NULL element results in NULL, not an empty array. Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Empty array IS NULL?

2004-06-28 Thread Joe Conway
there are some non-trivial technical difficulties to be solved. Unfortunately that won't change in the upcoming 7.5 either :( -- perhaps for 7.6. Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister c

Re: [SQL] Empty array IS NULL?

2004-06-28 Thread Joe Conway
there are some non-trivial technical difficulties to be solved. Unfortunately that won't change in the upcoming 7.5 either :( -- perhaps for 7.6. Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister c

Re: [SQL] Converting a plperlu function to a plpgsql function

2004-07-22 Thread Joe Conway
x27;,'); string_to_array - {1,2,3} (1 row) Second line: if ($r=~/^-([0-9]?)([A-z_]+)/) { my $locid = $1; my $table = $2; Not sure about this one. Hopefully someone else can chime in. Maybe a little less efficient, but it seems like it would be easy enough to parse when true. HTH, Joe

Re: [SQL] contrib/tablefunc crosstab

2004-08-05 Thread Joe Conway
_sql) That is the hashed version that will do what you're looking for. HTH, Joe ---(end of broadcast)--- TIP 8: explain analyze is your friend

Re: [SQL] function expression in FROM may not refer to other relations

2004-08-10 Thread Joe Conway
e2 +---+--+---+--- 1 | one |1 | A | A 2 | two |2 | Z | Z 3 | three |1 | A | A (3 rows) Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] ERROR: Cross-database references are not implemented

2004-08-10 Thread Joe Conway
roughly behave like individual databases do in MSSQL. See: http://www.postgresql.org/docs/7.4/static/ddl-schemas.html If you really need cross-database queries, see contrib/dblink (which would also work across servers), but it isn't as flexible as using schemas. HTH

Re: [SQL] Wierded error in recursive function; debugging ideas?

2004-08-10 Thread Joe Conway
Version is 7.4.1 There is no in_array() function in Postgres that I'm aware of -- you sure that isn't array_in()? The rest of that error message doesn't seem to be there in 7.4 either. Can we see the function? Joe ---(end of broadcast)---

Re: [SQL] reply to setting

2004-08-11 Thread Joe Conway
-to header. Also true. Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] Wierded error in recursive function; debugging ideas?

2004-08-11 Thread Joe Conway
Josh Berkus wrote: [2] Wrong datatype for second argument in call to in_array SQL: SELECT sf_event_decendants(66645,111) Are you sure this message isn't coming from some PHP middleware, e.g. peardb or something. See: http://us2.php.net/manual/en/function.in-array.php

Re: [SQL] SQL Challenge: Arbitrary Cross-tab

2004-08-17 Thread Joe Conway
pplication layer procedural code is likely to be the easiest and fastest way to go. crosstab just wraps the procedural code in an SRF for you. Joe ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] SQL Challenge: Arbitrary Cross-tab

2004-08-18 Thread Joe Conway
#x27;select case_id, ''cat'' as cat, timekeeper_id from authorized_timekeepers order by 1',4) as t(case_id int, tk1 text, tk2 text, tk3 text, tk4 text); case_id | tk1 | tk2 | tk3 | tk4 -+-+-+-+- 132113 | 021 | 115 | 106 | 14 | 106 | 021 | 115 | 108 213447 | 047 |

Re: [SQL] array_in: '{}}'::text[]

2004-08-23 Thread Joe Conway
version - PostgreSQL 8.0.0beta1 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7) (1 row) Look for a fix soon, at a cvs repository near you Joe

Re: [SQL] reply to setting

2004-08-23 Thread Joe Conway
. Interesting idea -- thanks! Joe ---(end of broadcast)--- TIP 7: don't forget to increase your free space map settings

Re: [SQL] PL/pgSQL multidimension (matrix) array in function

2004-09-20 Thread Joe Conway
;plpgsql'; regression=# select * from testarray(2,3); testarray --- {1} {1,1} {1,1,1} {2} {2,2} {2,2,2} (6 rows) HTH, Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

<    1   2   3   >