[SQL] How to build this field

2001-03-08 Thread juerg . rietmann
Hi everybody I need to build an additional field (metakey) out of three fields in the table. SELECT a.a_kurzbez, a.a_ausgabenr, a.a_bundnr, a.a_nr, a.a_z_blaenge, a.a_z_laenge, a.a_z_umfang FROM auftrag a should be changed to something like SELECT (a.a_kurzbez + a.a_ausgabenr + a.a_bundnr) as

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

2001-03-08 Thread Karel Zak
On Wed, Mar 07, 2001 at 08:38:25AM -0800, Josh Berkus wrote: > 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 > >

Re: [SQL] How to build this field

2001-03-08 Thread Christof Glaser
Hi Juerg, > I need to build an additional field (metakey) out of three fields in > the table. > > SELECT a.a_kurzbez, a.a_ausgabenr, a.a_bundnr, a.a_nr, a.a_z_blaenge, > a.a_z_laenge, a.a_z_umfang FROM auftrag a > > should be changed to something like > > SELECT (a.a_kurzbez + a.a_ausgabenr + a.

Re: [SQL] Buglet?

2001-03-08 Thread Tom Lane
Christopher Sawtell <[EMAIL PROTECTED]> writes: > It that a bug? You could argue that. The handling of NULL arrays (not to mention NULLs in arrays) is pretty brain-d^H^H^H^H^H^Hsimplistic; I don't think the original designer thought about NULLs at all. All of the array code could use an overhau

[SQL] How to drop an trigger

2001-03-08 Thread Frank Joerdens
I've created quite a few foreign key constraints in the database that I am currently working on, and now that I've altered the structure and dropped a table that had a foreign key reference to a couple of other tables, I need to get rid of those foreign keys (they weren't dropped automagically wit

[SQL] Re: How to drop an trigger

2001-03-08 Thread Frank Joerdens
On Thu, Mar 08, 2001 at 04:42:46PM +0100, Frank Joerdens wrote: > I've created quite a few foreign key constraints in the database that I > am currently working on, and now that I've altered the structure and > dropped a table that had a foreign key reference to a couple of other > tables, I need

Re: [SQL] quotes in pl/pgsql 0n variable type text or varchar

2001-03-08 Thread Najm Hashmi
Roberto Mello wrote: > 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 wr

Re: [SQL] Re: How to drop an trigger

2001-03-08 Thread Frank Joerdens
On Thu, Mar 08, 2001 at 05:06:29PM +0100, Frank Joerdens wrote: > On Thu, Mar 08, 2001 at 04:42:46PM +0100, Frank Joerdens wrote: > > I've created quite a few foreign key constraints in the database that I > > am currently working on, and now that I've altered the structure and > > dropped a table

[SQL] Writing SQL functions in Postgres

2001-03-08 Thread Boulat Khakimov
Hi, I want to write an SQL function in postgres that returns row as a result. The problem is the select statement inside the funtion has a two table join. So I dont know what to put after SETOF CREATE FUNCTION dummy() RETURNS SETOF ? AS 'select a.name,b.cc from tblusers a,

Re: [SQL] How to build this field

2001-03-08 Thread Christof Glaser
Josh, > > [ stuff deleted ] > > CREATE FUNCTION metakey (text, int4, int4) returns text as > > ' SELECT $1 || ' ' || text($2) || ' ' || text($3) ' > > LANGUAGE 'sql'; > > > > || is the "concatenate text" operator. > > > > Change the param types and cast them as you need. > > ... But keep in mind

Re: [SQL] Re: How to drop an trigger

2001-03-08 Thread Tom Lane
Frank Joerdens <[EMAIL PROTECTED]> writes: >> Just an idea: Is it safe to just delete the corresponding row in >> pg_trigger? > No, it ain't: After deleting the rows corresponding to the offending > triggers in pg_trigger, I can't vacuum, or dump. You need to adjust the reltriggers counts in the

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

2001-03-08 Thread Josh Berkus
karel, > Now I'm not writing to_char(interval), because current source (7.1) > is > freeze for new features and I'm waiting for 7.2 devel. cycle and I'm > spending > time with other things (PL/Python, the Mape project etc..). > > If it's *really important* for you I can write it next week(s)

Re: [SQL] Writing SQL functions in Postgres

2001-03-08 Thread dev
Boulat Khakimov <[EMAIL PROTECTED]> said: > I want to write an SQL function in postgres that returns > row as a result. > > The problem is the select statement inside the funtion has > a two table join. So I dont know what to put after SETOF > > CREATE FUNCTION dummy() > RETURNS SETOF ? >

[SQL] Access tables inside pl/pgsql functions

2001-03-08 Thread Michael Davis
I would like to create a pl/pgsql function that can select from a table even though users can't select from the table directly. For example, create a table and function that hits the table as the postgres user. Log in as another user and select function_name();. This fails because the user

[SQL] explain EXPLAIN?

2001-03-08 Thread David Olbersen
Hello, I'm looking for a better tutorial of how EXPLAIN works. I know Mr. Tom Lane wrote a "quick & dirty explanation" and that "plan-reading is an art that deserves a tutorial, and I haven't had time to write one". In which case I'd like to know if there's any other tutorials/resources.

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

2001-03-08 Thread Kyle
Tom Lane wrote: > Here's another twist though.  Is this a bug too or is this just beyond our reach? > psql:lead1.sql:64: ERROR:  Unable to select an aggregate function avg(date) It's just that we don't have any avg() function for date --- nor for timestamp, which is a little more surprising.   FY

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

2001-03-08 Thread Tom Lane
Kyle <[EMAIL PROTECTED]> writes: >> You could probably gin up a usable avg(timestamp) using the avg(float8) >> routines, since a timestamp is really just a double under the hood. > When you say "gin up" are you talking about C, PL/XXX, or just casts? I was thinking of full-scale cheating: make a

[SQL] perl dbd

2001-03-08 Thread Ken Kline
my apologies if this is not the coreect list but I cannot seem to install the package DBD-Pg-0.73-1.i386.rpm it complains that it needs libpq.so.1 i have the following installed from a source package rebuild: postgresql-7.0.3-2 ..server ..devel ..perl ..tk ..odbc ..tcl thanks as always Ken

[SQL] List Concatination

2001-03-08 Thread Josh Berkus
Folks, I have an interesting problem. For purpose of presentation to users, I'd like to concatinate a list of VARCHAR values from a subtable. To simplify my actual situation: CREATE TABLE clients ( client_id SERIAL PRIMARY KEY, client_name VARCHAR(50) ); CREATE TABLE c