Re: [SQL] plpgsql + dblink() question

2003-02-07 Thread Joe Conway
Frankie wrote: The case is when I call a function (from Server 1 at psql prompt) that will call dblink to do some operation on another server(it will take certain time), i.e. Server 2, and meanwhile I just unplug the network cable to Server 2. The consequence is that the function will never return

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] Postgres MD5 Function

2003-01-31 Thread Joe Conway
Larry Rosenman wrote: --On Friday, January 31, 2003 01:34:42 -0800 David Durst <[EMAIL PROTECTED]> wrote: Does there exsist a MD5 Function I can call??? look at /contrib/pgcrypto in the source distribution. Also worth noting is that 7.4 will have (and cvs HEAD has) a builtin md5 function: r

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

2003-01-20 Thread Joe Conway
Michiel Lange wrote: Would the same work for pg_user and pg_group? See: http://www.brasileiro.net:8080/postgres/cookbook/view-one-recipe.adp?recipe_id=11378 With these groups: regression=# select * from pg_group; groname | grosysid |grolist -+--+--- grp1|

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

2003-01-20 Thread Joe Conway
Guy Fraser wrote: This is what I want to do: select attribute,array_list(values,1,sizeof(values)) as value from av_list; Turn : attr6 | {val3,val7,val4,val5} Into : attr6 | val3 attr6 | val7 attr6 | val4 attr6 | val5 You didn't mention the version of PostgreSQL. If you're using < 7.3, go

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] DB2 to Postgresql conversion help.

2002-12-23 Thread Joe Conway
John Pauley wrote: All, Any suggestions on a Postgresql equivalent to the following DB2 sql query: SELECT * FROM (SELECT ID,NAME,CITY,STATE,PROGRAM,CUST_NAME,CUST_ID,ROWNUMBER() OVER (ORDER BY ID ASC) AS RN FROM MERCHANT_BROWSER_VIEW WHERE CUST_ID = 'A51B8CA2' ) AS RESULT WHERE RN BETWEEN 1 AND

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

2002-12-10 Thread Joe Conway
Elizabeth O'Neill's Office Mail wrote: I have two tables in my database a complaint table and a resolution table. One complaint may have several resolutions. I am trying to build a report that will give me the complaint details and all the resolution descriptions for a complaint in one text area/r

Re: [SQL] Trees: maintaining pathnames

2002-11-20 Thread Joe Conway
Dan Langille wrote: Given that I'm considering adding a new field path_name to the tree, I can't see the ltree package will give me anything more than I can get from like. My main reason for adding path_name was doing queries such as: select * from tree where path_name like '/path/to/parent

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 the message you are referr

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. Joe ---

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] Generating a cross tab (pivot table)

2002-11-07 Thread Joe Conway
Richard Huxton wrote: On Thursday 07 Nov 2002 11:47 am, Christoph Haller wrote: Regarding to Terry's request on multiple aggregates and Shahbaz's request for generating a cross tab ( pivot table ) in September, I've found an excellent example on a german inet page http://www.itrain.de/ I've tran

Re: [SQL] Multiple Databases

2002-10-23 Thread Joe Conway
Josh Berkus wrote: Is it possible to create a view using tables from two different postgresql servers? No. It isn't possible with plain old SQL, but it is possible (albeit ugly) using contrib/dblink in PostgreSQL 7.2.x. See README.dblink for documentation and examples. In PostgreSQL 7.3 (i

Re: [SQL] Get A Tree from a table

2002-10-07 Thread Joe Conway
Scott Yaung wrote: > I like to do something like this:(build a tree from relationship) [snip] > How can i make it by sql , and sql functions > Thanks lot and regards. There have been quite a few discussions of this topic in the past, so I would suggest you search through the archives. In 7.3 (c

Re: [SQL] Suggestion: md5/crypt functions in sql

2002-10-06 Thread Joe Conway
Aasmund Midttun Godal wrote: > It would be very usefull to have these in sql, so that it is even easier to create >tables with encrypted passwords. > See contrib/pgcrypto Joe ---(end of broadcast)--- TIP 6: Have you searched our list archives

Re: [SQL] rows in order

2002-10-04 Thread Joe Conway
Camila Rocha wrote: > Is there a way to put in order the rows in a table? the problem is that i w= > ant to keep a "tree" in the db, but the leaves must be ordered... > does someone have an idea? If you don't mind trying 7.3 beta, there is a function called connectby() in contrib/tablefunc. It w

Re: [SQL] split function for pl/pgsql

2002-10-02 Thread Joe Conway
Frederic Logier wrote: > Great ! have you some example for call a pl/perl function from a > pl/pgsql function ? I don't use PL/Perl, but I think you should be able to do: SELECT INTO var my_plperl_func(text_to_split); from within your PL/pgSQL function. > And could i use an int array in pl/pg

Re: [SQL] Stored Procedures

2002-10-02 Thread Joe Conway
[EMAIL PROTECTED] wrote: > Ok, if this does not apply to versions prior to 7.3beta > then what do I need to do if I am running 7.2.1? When I > try to use the SETOF to retrun a row set, I only get > one column. First, prior to 7.3 there is no SCHEMA support in Postgres. Everything lives in ess

Re: [SQL] Stored Procedures

2002-10-02 Thread Joe Conway
david williams wrote: > Also, > > the table definition MUST be in the Public Schema. I use my own schema > names but in order for the table to be found by the function it ( the > table ) must be in the public schema. Although it can be empty. (Note: this discussion does not apply to Postgre

Re: [SQL] split function for pl/pgsql

2002-10-02 Thread Joe Conway
Frederic Logier wrote: > hi, > > i'm looking for a split function, like perl or php. > I need doing a pl/pgsql function with a split return an array. > I must do some loop with this array for mass inserting. > > I think of doing it with pl / perl but I need to do insert and I don't > find exampl

Re: [SQL] function return multiply rows

2002-09-27 Thread Joe Conway
Jeroen Olthof wrote: > What is going wrong here? > > An example of what I'm trying to do. > > vw_teams is a view but same problem when trying it on a single table > CREATE FUNCTION test() RETURNS SETOF vw_teams AS 'select * from vw_teams;' > LANGUAGE 'sql'; > > SELECT test(); > > results in >

Re: [SQL] [GENERAL] Latitude / Longitude

2002-09-12 Thread Joe Conway
Tim Perdue wrote: > Hi Folks - > > I'm working on a global weather database for a client and have hit an issue > which I'm sure has been solved before. Unfortunately, the site search doesn't > pull up anything. > > Essentially, I've got two tables, one with city/county/lat/long and another

Re: [SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Joe Conway
Beth Gatewood wrote: > well, I know that I will have only a single sequence that will generate the > primary key per table. So basically, this type of function, for me needs > only to return the value of the primary key. > > I believe I mentioned in one of my posts the motivation behind not want

Re: [SQL] Hardware performance for large updates

2002-09-06 Thread Joe Conway
Josh Berkus wrote: > Particularly, the difficulty is that this application gets many small > requests during the day (100 simultaneous uses) and shares a server > with Apache. So I have to be concerned about how much memory each > connection soaks up, during the day. At night, the maintainence

Re: [SQL] Hardware performance for large updates

2002-09-05 Thread Joe Conway
Josh Berkus wrote: > The problem: The update series (done as a function) takes 10-15 > minutes. During this time, the CPU is never more than 31% busy, only > 256mb of 512 is in use, and the disk channel is only 25% - 50% > saturated.As such, is seems like we could run things faster. > > What

Re: [SQL] VACUUM not doing its job?

2002-08-03 Thread Joe Conway
Kristian Eide wrote: > Thanks, very helpful, although there does not seem to be much description of > what the two free space map options in postgresql.conf actually do. Doing a > VACUUM ANALYZE VERBOSE on my largest table gives me: > > NOTICE: Pages 43681: Changed 208, Empty 0; Tup 1921387: Vac

Re: [SQL] VACUUM not doing its job?

2002-08-03 Thread Joe Conway
Kristian Eide wrote: > This is not good as the database is in use 24/7, and without the indexes > everything comes to a screeching halt. This means I probably will have to > stop the programs using the database for the time it takes to re-create the > indexes; this is better than having to dump/re

Re: [SQL] contrib/dblink suggestion

2002-07-30 Thread Joe Conway
Bhuvan A wrote: > I am using postgresql 7.2.1. > I badly require to interconnect between databases. contrib/dblink seems to > be handy and ofcourse it well suits my requirement. But while browsing > across, i heard that it is not advicable to use it. So i wish to know > someone's experience in usi

Re: [SQL] Returning rows from functions

2002-07-10 Thread Joe Conway
David Durst wrote: > I was wondering if there was a way of returning a complete row from a > function, in reading the documentation of CREATE FUNCTION. I was under the > impression that you could return a row by using setof, but this does not > seem to be true. > Can anyone help? The short answer

Re: [SQL] SQL Challenge: Skip Weekends

2002-06-20 Thread Joe Conway
Josh Berkus wrote: > Folks, > > Hey, I need to write a date calculation function that calculates the > date after a number of *workdays* from a specific date. I pretty > much have the "skip holidays" part nailed down, but I don't have a > really good way to skip all weekends in the calucla

Re: [SQL] Please help me out on this insert error

2002-06-13 Thread Joe Conway
Vernon Wu wrote: > Command: > > Insert into profile (userid, haveChildren)values('id98', 'No'); > > Error: > > ERROR: Relation 'profile' does not have attribute 'havaChildren' ^^^ From the error message, looks like you spelled haveChild

Re: [SQL] How to use BYTEA type?

2001-11-01 Thread Joe Conway
Christopher Sawtell wrote: > Greetings folks, > > Please could a kind soul tell be how to extract data from a BYTEA type of > field into a file, or better still tell me where I can find some doco? Bruce has already written some minimal documentation which is in the 7.2 beta. I'm hoping t

Re: [SQL] ROUND function ??

2001-10-08 Thread Joe Conway
> select ROUND(0.5) ; returns 0 > select ROUND(1.5) ; returns 2; > select ROUND(2.5) ; returns 2; > select ROUND(3.5) ; returns 4;so on . > I'm sure you would have figured out what's happening !!! Why ?? > How do I get to approximate any number x.5 as x+1 ?? Looks like a bug to me: test=# se

Re: [SQL] Search by longitude/latitude

2001-10-08 Thread Joe Conway
> Hi all, > > I need to implement "Find all hospitals in a 5 mile radius". Say I have all > the coordinates on them stored in a table with the fields longitude and > latitude. Has anybody some sample code for that? > > Best regards, > Chris > Here's a plpgsql function that will do what you need.

Re: [SQL]

2001-09-03 Thread Joe Conway
> im new in postgresql (actually came from SQL Server) and i was trying a > script like this > > insert into table1(field1,field2) values (select field1, field2 from table > 2); > > i dont know if this is possible (inserting a set of entries via resultset > from a select stmt in one command). If

Re: [SQL] Name Alike Challenge

2001-08-07 Thread Joe Conway
> The "Name Alike" PL/pgSQL function has been posted on Roberto Mello's > cookbook: > > http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp?recipe_id=96 7 > > This function requires Joe Conway's port of the Metaphone and > Levenshtein functions to PostgreSQL, available from /contrib on

Re: [SQL] Outer Join Syntax

2001-08-01 Thread Joe Conway
Subject: [SQL] Outer Join Syntax > I'm doing a feasability study on porting our flagship product to Postgres > (from MS_SQL). I have run across a few snags, the largest of which is the > outer join syntax. MS has some nice syntactical sugar with the *=/=* > operators that Postgres dosen't seem

Re: [SQL] Fuzzy matching?

2001-07-31 Thread Joe Conway
> > > > Actually, this may even be closer to what you want: > > http://www.php.net/manual/en/function.levenshtein.php > > Hey, that's terrific! I didn't know that those programs existed > outside fo expensive proprietary software. > > Now, who can I talk into porting them (metaphone, levenstein)

Re: [SQL] Fuzzy matching?

2001-07-31 Thread Joe Conway
> > Sounds like you want something along the lines of soundex or metaphone? I > > don't see either function in PostgreSQL, but take a look at the PHP manual > > to see examples: http://www.php.net/manual/en/function.soundex.php , > > http://www.php.net/manual/en/function.metaphone.php > > > > See

Re: [SQL] Fuzzy matching?

2001-07-31 Thread Joe Conway
> And the fuzzy_match should return True if the two phrases are no more > than that number of characters different. Thus, we should get: > > fuzzy_match('Thornton','Tornton',1) = TRUE > fuzzy_match('Thornton','Torntin',1) = FALSE > fuzzy_match('Thornton','Torntin',2) = TRUE > > Unfortunately, I c

Re: [SQL] Big table - using wrong index - why?

2001-07-30 Thread Joe Conway
> phones=# \d i_pl_pseq > Index "i_pl_pseq" > Attribute | Type > ---+-- > entity| character varying(3) > pseq | bigint > btree > > phones=# explain select * from phonelog where entity = '001' and pseq >= > 9120 and pseq <= 9123; > NOTICE: QU

Re: [SQL] How can we match a condition among 2 diff. tables?

2001-07-13 Thread Joe Conway
> > Now, i need to get the details of all employees who did > > receive NONE of the salesorders. ie.. i wish to select the > > records of table 'employee' whose 'emp_id' are not > > there in table 'salesorder'. > > > > I need to accompolish in a single query! This should work: select e

Re: [SQL] Problems handling errors in PL/pgSQL

2001-04-23 Thread Joe Conway
> However, not all types of errors are so trapped. The most problematic > un-trapped error is referential integrity: if an INSERT or UPDATE fails > because of a referential integrity violation, the PL/pgSQL function will > still see the statement as a success and not error out. Example: > I'm

Re: [SQL] Help

2001-03-26 Thread Joe Conway
> Thanks for your valuable information. I tried the > cron. i typed >cron -e > and entereed into the input area. but i don't know how > to save the cron file. I pressed ctrl+z and came out > from cron. but i edit the cron file i found nothing on > it.(i.e using pico filename.) Please tell me

Re: [SQL] Help

2001-03-25 Thread Joe Conway
> I am a user postgresql. I want to update a table > automatically when we reach monthend. i.e i want to > update some table on 31 of every month automatically > without any user attention. I want to know how to do > this. If anyone knows how to do this please mail me. i > will be ever thankfu

Re: [SQL] Oracle to PostgreSQL help: What is (+) in Oracle select?

2001-03-16 Thread Joe Conway
> A select is done across two tables, however when joining the foreign > key, the right hand side of the equallity has (+) appended > > SELECT o.* from one o, two t where o.key = t.key(+) > > Does anyone know what this does and how I can reproduce the select in > PostgreSQL? Hi Chris, The (+) in

Re: [SQL] RE: C function for use from PLpgSQL trigger

2001-02-06 Thread Joe Conway
> You could send the column name directly into your c function. For example: > c_function_name(NEW.col1, NEW.col2, NEW.col3). Otherwise I am not sure how > to send NEW into a C function. You could try declaring NEW in your C > function as a tuple. Thanks for your reply. I was hoping that I cou

[SQL] Fw: C function for use from PLpgSQL trigger

2001-02-03 Thread Joe Conway
ssage 'NEW used in a non-rule query') or gain > access to the trigger tuple from within my C function? It seems that > although PLpgSQL is called as a trigger, the C function is called as a > regular function (makes sense) and thus has no access to the trigger tuple > (my problem). &

[SQL] current host and dbname info

2001-01-27 Thread Joe Conway
Hi, I've been searching the docs and been unable to find the answer to this -- is there a way to get the current database server host tcpip address, postmaster port, and database name from a SQL query? I'd like to access those from within a plpgsql function without having to create and populate

[SQL] single byte unsigned integer datatype

2001-01-14 Thread Joe Conway
Hello, I was looking for a datatype to represent a single byte unsigned integer. The closest thing I can find looking through the online manual is a one byte char. Are there any side-effects of using a char datatype for this purpose? Is there a better datatype to use? Thanks in advance, Joe

Re: [SQL] Optimization recommendations request

2000-12-29 Thread Joe Conway
Subject: Re: [SQL] Optimization recommendations request > > What does explain show for your query? > I sent this a week ago using the wrong (i.e. not the one I signed up with) reply-to address, so it didn't make it to the list until just now. In the meantime I ran explain and noticed that the i

[SQL] Optimization recommendations request

2000-12-29 Thread Joe Conway
; -- then tried create index foo_idx1 on foo using HASH (guid); SELECT ks FROM foo WHERE guid = 'f9ee1930f4010ba34cc5ca6efd27d988eb4f921d'; The query currently takes in excess of 40 seconds. I would appreciate any suggestions for optimizing to bring this down substantially. Thanks in advance, Joe Conway

[SQL] Fw: Optimization recommendations request

2000-12-23 Thread Joe Conway
fd27d988eb4f921d'; > > The query currently takes in excess of 40 seconds. I would appreciate any > suggestions for optimizing to bring this down substantially. > > Thanks in advance, > > Joe Conway >

Re: [SQL] psql question

2000-11-23 Thread Joe Conway
> > On machines where I've installed PostgreSQL 7.0.2 from RPM, psql allows use > > of the up arrow key for history and the escape/tab key for command > > completion, but on my remote web host (webpipe.net) those keys don't work. > > What do I need to do to get these features working on my remote

[SQL] psql question

2000-11-23 Thread Joe Conway
Hello, I've been searching off-and-on for an answer to this question, but I haven't found anything but fleeting references. Here's the problem/question: On machines where I've installed PostgreSQL 7.0.2 from RPM, psql allows use of the up arrow key for history and the escape/tab key for command

<    1   2