Re: [SQL] obtuse plpgsql function needs

2003-07-22 Thread elein
You'll need to pass the values down to your concat function (which I suggest you don't call concat) and have it return a text type. What exactly is your problem? I must be missing something. elein On Tue, Jul 22, 2003 at 06:31:52PM -0400, Robert Treat wrote: > given > > cr

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread elein
will hang onto this problem and if either of us finds a solution, I'd like to publish it in general bits. elein On Wed, Jul 23, 2003 at 09:06:49AM -0400, Robert Treat wrote: > On Tue, 2003-07-22 at 19:33, elein wrote: > > You'll need to pass the values down to your > > co

Re: [SQL] obtuse plpgsql function needs

2003-07-23 Thread elein
So, other than C, plperl or pltcl is the way to go. As long as they can input generic composite types (I wasn't sure of that, but I should have known), they can access columns as array elements so you can loop through them. And they'll tell you the number of arguments. Ta da! elein O

Re: [SQL] obtuse plpgsql function needs

2003-07-24 Thread elein
know, I know, send a patch. --elein On Thu, Jul 24, 2003 at 01:07:18AM -0400, Tom Lane wrote: > elein <[EMAIL PROTECTED]> writes: > > So, other than C, plperl or pltcl is the way to go. > > As long as they can input generic composite types > > (I wasn't sure

Re: [SQL] Large Objects and Bytea

2003-09-25 Thread elein
In this week's General Bits, we talk about using large objects. Perhaps this might help you understand what is involved with using them. http://www.varlena.com/GeneralBits/ cheers, [EMAIL PROTECTED] On Thu, Sep 25, 2003 at 09:41:28AM +0530, Kumar wrote: > Hi Friends, > > I am running Postgre

Re: [SQL] Running tally

2003-10-11 Thread elein
You can use plpythonu (or tcl or C or R) to do running sums. For plpythonu, you must initialize the SD[] by calling it first with the proper argument. create or replace function runsum(int,int) returns int as ' if args[0] == 1: SD["currval"] = 0 return SD["currval"] else:

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread elein
This is an example of the problem. It used to expand the middle thing to 15. elein=# select 'x' || ' '::char(15) || 'x'; ?column? -- xx (1 row) On Tue, Feb 17, 2004 at 06:10:56PM -0500, Tom Lane wrote: > "news.postgresql.org" <[EMAIL

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-17 Thread elein
update of the char(n) to text for the operator "corrupts" the char() value. elein On Tue, Feb 17, 2004 at 06:40:49PM -0500, Tom Lane wrote: > elein <[EMAIL PROTECTED]> writes: > > This is an example of the problem. It used to expand > > the middle thing

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-18 Thread elein
So exactly what is the order of casts that produces different results with: 'x' || ' ' || 'x' and 'x' || ' '::char15 || 'x' Are operators being invoked both (text,text)? I'm trying to understand the precedence that causes

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-02-19 Thread elein
ently than cat for text and varchar because of the different trimming behaviour. I can do this patch if there is agreement. But I may not be able to do it immediately. elein On Wed, Feb 18, 2004 at 11:58:37PM -0500, Tom Lane wrote: > elein <[EMAIL PROTECTED]> writes: > > S

Re: [SQL] Function To Log Changes

2004-04-06 Thread elein
A plpython solution is available in Issue #66 of PostgreSQL GeneralBits. http://www.varlena.com/GeneralBits/66 Let me know if this helps. elein On Mon, Apr 05, 2004 at 01:01:39PM -0400, Gavin wrote: > Hi All, I have been tinkering with a function to log the changes made on > any column t

Re: [SQL] SQL challenge--top 10 for each key value?

2004-04-10 Thread elein
"] = 1 return SD["nextno"] ' language 'plpythonu'; And clearly it can be done faster as a little C function. elein On Fri, Apr 09, 2004 at 09:06:39AM -0700, Josh Berkus wrote: > Rod, > > > Something along the lines of the below would accomplish what

Re: [SQL] SQL challenge--top 10 for each key value?

2004-04-10 Thread elein
This solution will be in Monday's edition of PostgreSQL General Bits (http://www.varlena.com/GeneralBits). (In other words, if it doesn't do what you mean, let me know now!) CREATE TYPE topscores AS (id integer, query integer, checksum char(32), score integer); CREATE OR REPLACE FUNCTION tops

Re: [SQL] SQL challenge--top 10 for each key value?

2004-04-11 Thread elein
connection. So any values stored in it need to be initialized at the appropriate time *outside* of the first use. elein On Sun, Apr 11, 2004 at 12:38:20AM -0400, Greg Stark wrote: > > elein <[EMAIL PROTECTED]> writes: > > > create or replace function pycounter(integer) &

Re: [SQL] CHAR(n) always trims trailing spaces in 7.4

2004-06-03 Thread elein
Apparently the ::char is cast to varchar and then text? That explains x || ' ' || x On Tue, Feb 17, 2004 at 05:07:24PM -0700, scott.marlowe wrote: > On Tue, 17 Feb 2004, Tom Lane wrote: > > > elein <[EMAIL PROTECTED]> writes: > > > This is an example of the

Re: [SQL] searching polygons

2004-06-05 Thread elein
to a circle to use the operators, but it will still tell you whether the smaller polys are contained within or overlap the larger. elein On Tue, Feb 17, 2004 at 07:01:51PM -, David wrote: > What query would i have to use to search for an item using a polygon as a > parameter? (i.e a very

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

2004-08-17 Thread elein
f you must. You can't really do it w/o loops or aggregates. (I wish (hope?) I were wrong about this.) --elein On Tue, Aug 17, 2004 at 07:55:11PM -0700, Josh Berkus wrote: > Folks, > > I have a wierd business case. Annoyingly it has to be written in *portable* > SQL92, wh

Re: [SQL] UPDATEABLE VIEWS ... Examples?

2005-06-16 Thread elein
There is a write up on these at: http://www.varlena.com/GeneralBits/82.php --elein [EMAIL PROTECTED]Varlena, LLCwww.varlena.com PostgreSQL Consulting, Support & Training PostgreSQL General Bits

Re: [SQL] how to create rule as on delete

2005-10-24 Thread elein
I think you want a delete trigger which does your insert and then follows through with the delete by returning old. --elein [EMAIL PROTECTED] On Tue, Oct 18, 2005 at 09:43:34PM -0700, efa din wrote: > This is my rule for doing the delete event. The rule > can be created. But the prob

Re: [SQL] "large" IN/NOT IN subqueries result in query returning wrong data

2005-12-27 Thread elein
me not in ( > > select t1.name from t1 limit 261684) > > --> 0 > > > What is so magical about 261683? > > Most likely, the 261684'th row of t1 has a NULL value of name. > Many people find the behavior of NOT IN with nulls unintuitive, > but it's per SQ

Re: [SQL] "large" IN/NOT IN subqueries result in query returning wrong data

2005-12-27 Thread elein
On Tue, Dec 27, 2005 at 07:25:40PM -0500, Tom Lane wrote: > elein <[EMAIL PROTECTED]> writes: > > In 8.0 we get: > > >elein=# select 1 in (NULL, 1, 2); > > ?column? > >-- > > t > >(1 row) > > >

Re: [SQL] Returning String as Integer

2006-05-05 Thread elein
Use the to_number() function to convert text to numbers. In the manual under functions and operators. The other function like it is to_date(). --elein [EMAIL PROTECTED] On Fri, May 05, 2006 at 02:37:13PM -0700, Kashmira Patel (kupatel) wrote: > Hi all, >I have a table with a column o