Re: [SQL] No Documentation for to_char(INTERVAL, mask)

2001-03-07 Thread Karel Zak
On Tue, Mar 06, 2001 at 09:22:25AM -0800, Josh Berkus wrote: > Karel, > > > The 'interval' version of to_char() isn't implemented -- may be in 7.2 > > (it's high in my TODO list:-) > > Grazie. (One of the things I love about PostgreSQL is being able to > get definitive answers on functio

Re: [SQL] Problems with RULE

2001-03-07 Thread Richard Huxton
From: "Jens Hartwig" <[EMAIL PROTECTED]> > Hello Richard, > > this was a very precise analysis - thanks for the effort you made! Precisely wrong in this case. My mistakes have some of the finest tolerances in the world. 8-) > Nevertheless the Tom's explanation of the behaviour in case of views

Re: [SQL] Quick question MySQL --> PgSQL

2001-03-07 Thread Grigoriy G. Vovk
When I did the same task - I've writting a script on the perl, and if you have stable databese structure, I think, it's a best way - write a script which will run by cron /on-demand. Because, I don't remember exactly why (date format is different or something else) but, I couldn't move data from M

Re: [SQL] random

2001-03-07 Thread Tomek Zielonka
On Mon, Mar 05, 2001 at 02:12:15PM -0500, Jelle Ouwerkerk wrote: > Hi > > What would be the best way to select a random row from a result set? > > Possibilities: > > 1) o get the total number of rows using count() >o generate a random number between 1 and the total >o select the n'th ro

Re: [SQL] random

2001-03-07 Thread Tomek Zielonka
On Wed, Mar 07, 2001 at 12:50:36PM +0100, Tomek Zielonka wrote: > On Mon, Mar 05, 2001 at 02:12:15PM -0500, Jelle Ouwerkerk wrote: > > Hi > > > > What would be the best way to select a random row from a result set? > > > > Here's my approach. It allows to get random row from the table, not from

[SQL] sql functions and triggers

2001-03-07 Thread Andrzej Roszkowski
Hello! It is possible to pass ie. insert fields and values to sql function in trigger? I want to define a trigger on insert (select delete etc.) and log some values in different table(s). -- "Code reviews are like sex, just anyone can do it, but skill and training can make you a lot better a

Re: [SQL] sql functions and triggers

2001-03-07 Thread Karel Zak
On Wed, Mar 07, 2001 at 03:03:59PM +0100, Andrzej Roszkowski wrote: > Hello! > > It is possible to pass ie. insert fields and values to sql function in > trigger? I want to define a trigger on insert (select delete etc.) and log > some values in different table(s). Sure, see docs about SPI in

Re: [SQL] No Documentation for to_char(INTERVAL, mask)

2001-03-07 Thread Josh Berkus
Thomas, Karel, > I agree with Karel's point that it may be a pain to use a procedural > language to manipulate a "stringy" interval value. If you use a C > function instead, you can get access to the internal manipulation > functions already present, as well as access to system functions to > ma

Re: AW: [SQL] Problems with RULE

2001-03-07 Thread Tom Lane
"Jens Hartwig" <[EMAIL PROTECTED]> writes: > What would have happened, if I executed an unconditional DELETE? > => DELETE FROM t_xyz; > Which statement would have been generated by PostgreSQL in this case? Unfortunately, I didn't keep the prior discussion, so I don't remember exactly what the r

[SQL] Re: [DOCS] Extending PostgreSQL Using C

2001-03-07 Thread Tom Lane
Hannu Krosing <[EMAIL PROTECTED]> writes: > Boulat Khakimov wrote: >> ERROR: Can't find function encrypt in file /[full path here]/encrypt.so > Can _postgres_ user read /[full path here]/encrypt.so ? Presumably so. If he were unable to load the .so file, he'd be getting a different error mess

AW: [SQL] Problems with RULE

2001-03-07 Thread Jens Hartwig
> [...] > So - if you issue "DELETE FROM t_xyz" you'd want two things to happen: > > 1. where deleted is false set it to true > 2. where deleted was true delete the record > > So - PG rewrites the query into two parts: > > DELETE FROM t_xyz WHERE old.deleted=false > DELETE FROM t_xyz WHERE NOT(old

[SQL] how to get info of function

2001-03-07 Thread Jie Liang
Hi, What system table hold info of user defined function?? Acturally , I want to know how to retrive the defination of a function from its name. Thankes. Jie LIANG St. Bernard Software 10350 Science Center Drive Suite 100, San Diego, CA 92121 Office:(858)320-4873 [EMAIL PROTECTED] www.st

Re: [SQL] No Documentation for to_char(INTERVAL, mask)

2001-03-07 Thread Thomas Lockhart
> I'll take a stab at in in PLPGSQL and post the results. OK. date_part() is your friend ;) - Thomas ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL

[SQL] Newbie: execute function error!

2001-03-07 Thread John GM
I created a sample function: CREATE FUNCTION concat_text (text, text) RETURNS text AS ' BEGIN RETURN $1 || $2; END; ' LANGUAGE 'plpgsql'; The creation was fine. But when I execute the function with : select concat('a', 'b'); I get the error: NOTICE: plpgsql: ERROR during compile of conc

[SQL] work on rows

2001-03-07 Thread Rachel Coin
Hello,   I have a problem with a sql query.I have two tables : the first contains categories and the second subcategories.   What kind of select may I use to get something like Yahoo! categories ( each "main" category gets *at most* three sub-categories..   Thanks Regards,   Rachel        

Re: [SQL] Permissons on database

2001-03-07 Thread Roland Roberts
> "bk" == Boulat Khakimov <[EMAIL PROTECTED]> writes: bk> How do I grant permissions on everything in the selected bk> databes? bk> GRANT doesnt take as on object database name nor does it bk> accept wild chars Attached is some Perl code I wrote long ago to do this. Thi

Re: [SQL] work on rows

2001-03-07 Thread dev
Author: Rachel Coin <[EMAIL PROTECTED]> I have a problem with a sql query.I have two tables : the first contains categories and the second subcategories. What kind of select may I use to get something like Yahoo! categories ( each "main" category gets *at most* three sub-categories.. Do yo

Re: [SQL] Newbie: execute function error!

2001-03-07 Thread dev
On 3/6/01, 5:55:05 AM, John GM <[EMAIL PROTECTED]> wrote regarding [SQL] Newbie: execute function error!: > I created a sample function: > CREATE FUNCTION concat_text (text, text) RETURNS text AS ' > BEGIN > RETURN $1 || $2; > END; ' > LANGUAGE 'plpgsql'; > The creation was fine. But whe

[SQL] quotes in pl/pgsql

2001-03-07 Thread Najm Hashmi
Hi all, I just want to know how to put quotes around a string. Is there a function to do so? If not how can I escape a single quote. Thank you in advance. begin:vcard n:Hashmi;Najm x-mozilla-html:FALSE org:Mondo-Live.com;www.flipr.com adr:;; version:2.1 email;internet:[EMAIL PROTECTED] x-m

[SQL] A query that doesn't work on 7.1

2001-03-07 Thread Kyle
Here's a query that doesn't work on 7.1.  Is this a bug or am I doing something wrong? The last two selects yield: ERROR:  Sub-SELECT uses un-GROUPed attribute m1.ropnum from outer query Basically, everything works until I apply the avg() function and try to aggregate the results.   drop table mt

Re: [SQL] quotes in pl/pgsql

2001-03-07 Thread clayton cottingham
Najm Hashmi wrote: > > Hi all, I just want to know how to put quotes around a string. Is there a > function to do so? > If not how can I escape a single quote. > Thank you in advance. > > > > ---

Re: [SQL] A query that doesn't work on 7.1

2001-03-07 Thread Tom Lane
Kyle <[EMAIL PROTECTED]> writes: > Here's a query that doesn't work on 7.1. Is this a bug or am I doing > something wrong? Hmm, I think you have found some subtle bugs in aggregate processing; offhand it seems like both these queries should be legal. I'll see what I can do about it.

Re: [SQL] quotes in pl/pgsql

2001-03-07 Thread Justin Clift
Hi Najm, Is this what you mean? CREATE FUNCTION foobar(int4) returns int4 as 'DECLARE textbuf varchar(120); BEGIN  textbuf := ''Example Text ''; insert into sometable (something) values (textbuf); RETURN 0; END;' LANGUAGE 'plpgsql'; Najm Hashmi wrote: > > Hi all, I

Re: [SQL] quotes in pl/pgsql

2001-03-07 Thread Roberto Mello
On Thu, Mar 08, 2001 at 05:54:38PM -0500, Najm Hashmi wrote: > Hi all, I just want to know how to put quotes around a string. Is there a > function to do so? > If not how can I escape a single quote. Others have answered how to quote a single string. I wrote an entire section on quotes o

Re: [SQL] A query that doesn't work on 7.1

2001-03-07 Thread Tom Lane
>> Here's a query that doesn't work on 7.1. Is this a bug or am I doing >> something wrong? > Hmm, I think you have found some subtle bugs in aggregate processing; > offhand it seems like both these queries should be legal. I'll see what > I can do about it. Not so subtle after all :-(. Curio

[ADMIN] how to reload a function

2001-03-07 Thread Jie Liang
I have 2 plpgsql defined functions, say: create function A() returns ... as' . 'language 'plpgsql'; create function B() returns ... as ' declare begin select A(..) into myvar from end; 'language 'plpgsql'; If I modify function A (drop && re_create), then I have t

[SQL] postgresql beta-4,5 BUG

2001-03-07 Thread guard
DELPHI can't use TABLE component ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

[SQL] Buglet?

2001-03-07 Thread Christopher Sawtell
chris=# select *, array_element_count(pupils_on_leave) as number_awol_pupils from absence ; date | lesson_number | pupils_on_leave | pupils_awol | number_awol_pupils +---+-+---+ 2001-03-08 0

Re: [SQL] No Documentation for to_char(INTERVAL, mask)

2001-03-07 Thread Thomas Lockhart
> > Given the lack of to_char(interval), I'd like to write a PLPGSQL > > function to fill the gap in the meantime... > I mean is too much difficult write a 'interval' to_char() version in > some procedural language without access to real (internal) form of > 'interval'. I agree with Karel