[SQL] sql query

2001-02-12 Thread manjul katare
sir , kindly send me the solution of the above query. 1. To calculate th no. of days between 01/01/2000 to 03/02/2001. 2. TO calculate th time in newfoundland from centra standard time from 02-22-97 ,05.00 am. _ Get Your

[SQL] Re: plpgsql grief

2001-02-12 Thread Ian Harding
rob wrote: Hi, I'm having some real headache problems here. Apologies for the length, i just want to get it all out now :) I figured moving some 'simple' db code from my application to it's more natural home in the db would work out. Bummer. Not only do i have to run 7.1 (beta 4) to be

Re: [SQL] parse error in create index

2001-02-12 Thread Hubert Palme
Stephan Szabo wrote: Functional indexes cannot currently take constant values to the function, so it's complaining about the constant 'month'. The current workaround is probably to create a function that does the date_part('month', arg) for you and then use that function in the index

Re: [SQL] parse error in create index

2001-02-12 Thread Hubert Palme
Stephan Szabo wrote: Functional indexes cannot currently take constant values to the function, so it's complaining about the constant 'month'. The current workaround is probably to create a function that does the date_part('month', arg) for you and then use that function in the index

[SQL] Index problem...

2001-02-12 Thread Kim Yunhan
I want to query this... -- SELECT * FROM bbs ORDER BY ref desc, step ASC LIMIT 12; this query doesn't refer the index that made by this query. -- CREATE INDEX idx_bbs ON bbs (ref, step); but, i change the query that "ref desc" to "ref asc". then query refer the index, and i can see a result

[SQL] PL/PGSQL Cook Book

2001-02-12 Thread mark proctor
I've just spent the last day or two trying to get to grips with plpgsql and can't believe how abysmal the documetentation and examples are. I've been trawling through the mailist lists and I notice there was talk back in 1999 abouta PLPGSQL Cook Book - did anything come of this? If no one is

[SQL] plpgsql grief

2001-02-12 Thread rob
Hi, I'm having some real headache problems here. Apologies for the length, i just want to get it all out now :) I figured moving some 'simple' db code from my application to it's more natural home in the db would work out. Bummer. Not only do i have to run 7.1 (beta 4) to be able to dynamically

[SQL] view does not show all records it should

2001-02-12 Thread Giovanni Biscuolo
I set up a simple database in wich all works well, exept one *very* strange (to me) result. Some time ago I created this views: CREATE VIEW mag_scaricati_view AS SELECT s.id_carico, SUM(s.qta_scaricata) AS Scaricati FROM mag_scarico_tbl s GROUP BY s.id_carico; CREATE VIEW

Re: [SQL] parse error in create index

2001-02-12 Thread Hubert Palme
Stephan Szabo wrote: Functional indexes cannot currently take constant values to the function, so it's complaining about the constant 'month'. The current workaround is probably to create a function that does the date_part('month', arg) for you and then use that function in the index

[SQL] Re: plpgsql grief

2001-02-12 Thread rob
snip I feel your pain;^) Here is the text of a post from Tuesday... I think it answers your question which is that you cannot do variable subsititution for table or field names inside procedures. This is not a Postgres specific limitation, MS SQL Server has the same issue. "DR" ==

[SQL] Wierd postgres Problem

2001-02-12 Thread Najm Hashmi
Hi All, I am trying to define a new set of tables an I am getting this strange syntex problem on date, or timestamp data types. I am also getting error on not null constranit as well... Postgres is behaving strangely first definations with not null cmdb=# create table media_received (

Re: [SQL] parse error in create index

2001-02-12 Thread Tom Lane
Hubert Palme [EMAIL PROTECTED] writes: adressen= CREATE INDEX xxx ON geburtstage (geb_monat(geburtstag)); ERROR: DefineIndex: (null) class not found adressen= Apparently you're using 6.5 or older ... I'd recommend updating! IIRC, in = 6.5 you *must* specify an operator class for a

Re: [SQL] view does not show all records it should

2001-02-12 Thread Tom Lane
Giovanni Biscuolo [EMAIL PROTECTED] writes: CREATE VIEW mag_scaricati_view AS SELECT s.id_carico, SUM(s.qta_scaricata) AS Scaricati FROM mag_scarico_tbl s GROUP BY s.id_carico; Grouped views don't work very well in versions before 7.1, though I'm not sure if that is the issue here or

Re: [SQL] view does not show all records it should

2001-02-12 Thread Ross J. Reedstrom
On Mon, Feb 12, 2001 at 03:54:39PM +0100, Giovanni Biscuolo wrote: I set up a simple database in wich all works well, exept one *very* strange (to me) result. Some time ago I created this views: CREATE VIEW mag_scaricati_view AS SELECT s.id_carico, SUM(s.qta_scaricata) AS Scaricati

Re: [SQL] Wierd postgres Problem

2001-02-12 Thread Peter Eisentraut
Najm Hashmi writes: cmdb=# create table media_received ( cmdb(# comp_id not null, cmdb(# dept_id not null, ^ Those two fields should have a data type. Same in your other examples. cmdb(# date_rec timestamp default 'now', cmdb(# units int4 default 0, cmdb(# media_type

Re: [SQL] Wierd postgres Problem

2001-02-12 Thread Michael Fork
Your missing your fields types, i.e.: CREATE TABLE media_received ( comp_id SERIAL NOT NULL, dept_id INT4NOT NULL, date_recTIMESTAMP DEFAULT 'now', that should fix your problem... Michael Fork - CCNA - MCP - A+ Network

Re: [SQL] plpgsql grief

2001-02-12 Thread Josh Berkus
Rob, I figured moving some 'simple' db code from my application to it's more natural home in the db would work out. Bummer. Not only do i have to run 7.1 (beta 4) to be able to dynamically generate queries, I'm finding it *extrememly* difficult to get to get my simple functions to work

Re: [SQL] plpgsql grief

2001-02-12 Thread Tom Lane
Michael Ansley [EMAIL PROTECTED] writes: create function testfunc (text) returns int4 as ' declare sql varchar; begin sql=''SELECT id AS res2 FROM ''||$1 ; execute sql ; return res2; end; ' language 'plpgsql' ; Please note the AS syntax rather than INTO. That won't work :-(

Re: [SQL] plpgsql grief

2001-02-12 Thread Josh Berkus
Rob, Just need the info - i can do the rest. I also, due to my business requirements, need to do this as quickly as possible - maybe not the expert you perhaps are grin No expert at all, according to Tom Lane. As it goes I've implemented most of what I wanted in pl/tcl (having learned tcl

Re: [SQL] plpgsql grief

2001-02-12 Thread Josh Berkus
Tom, (and keep in mind that Postgres functions currently have trouble with NULLS as input parameters). Not in 7.1 they don't ... Really? Terrific. Sadly, I have 25+ PL/pgSQL functions not set up to accept NULLs ... Can you point me to (or tell me where to search) the developer notes

Re: [SQL] What's wrong with this function

2001-02-12 Thread mark proctor
the select query returns the first row to rec. You can then access its values with: rec.field_name at END LOOP it jumps back to FOR checks to see if there any more rows and if so moves to the next row and repeats the loop. It also looks like your missing a LOOP keyword at the end of the FOR

[SQL] ORDER BY in SQL functions

2001-02-12 Thread K. Ari Krupnikov
Are ORDER BYs allowed in SQL functions? Or do SQL functions work like views that are as unordered as their underlting tables? CREATE FUNCTION foo (INT) RETURNS SETOF INT AS ' SELECT id FROM table WHERE some_colunm $1 ' LANGUAGE 'sql'; works. But if I try CREATE FUNCTION foo

[SQL] Re: plpgsql grief

2001-02-12 Thread Ian Harding
Tcl is my bread and butter but, coincidentally, I have just started considering pl/tcl 2 days ago as the choice for server side pg programming. I do it in microsoft t-sql right now, and plsql is pretty close to that. However, tcl is like English to me, so I think I will go that way unless

Re: [SQL] Wierd postgres Problem

2001-02-12 Thread Tomek Zielonka
On Tue, Feb 13, 2001 at 10:20:09AM -0500, Najm Hashmi wrote: Hi All, hi I am trying to define a new set of tables an I am getting this strange syntex problem on date, or timestamp data types. I am also getting error on not null constranit as well... Postgres is behaving strangely first

Re: [SQL] PL/PGSQL Cook Book

2001-02-12 Thread Bruce Momjian
Even a PL/PgSQL FAQ would be good. mark proctor writes: I've been trawling through the mailist lists and I notice there was talk back in 1999 abouta PLPGSQL Cook Book - did anything come of this? If no one is maintaining something like this and people think its a good idea I think we

[SQL] pg_dump question

2001-02-12 Thread Carolyn Lu Wong
When dumping database, is it possible to dump datetime values without the timezone info? I'm currentlyl using 6.5.

Re: [SQL] postgres's users take on onlamp

2001-02-12 Thread Volker Paul
Well, maybe if Postgres' name was Mostgres, the "M" would stand for Mostgres instead of MySQL ... V.Paul clayton cottingham wrote: heya: just wondering if anyone has any comments on this onlamp is o'rielly's new ideal that ,really, has been in use for quite a while its anacronym