Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Dmitry Turin
>you are proposing is to ... break the relational model of SQL No. I'm proposing to add new thinking about relational model (primary i want to write "to add new view", but i remember, that "view" is reserved word in SQL :) ). Сonvince yourself, please: create table a ( id num primary key

Re: [SQL] many 'OR' in WHERE-condition

2007-04-20 Thread Richard Huxton
A. Kretschmer wrote: in a SELECT with a condition 'WHERE foo IN (1,2,3,4,...)' with a large ... But if the list increase the planner choose an seq-scan. The amount of values in the list is about 200 and the table has about 250.000 rows. How can we avoid the seq-scan? Are you sure you'd want

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Richard Huxton
Dmitry Turin wrote: you are proposing is to ... break the relational model of SQL No. I'm proposing to add new thinking about relational model (primary i want to write "to add new view", but i remember, that "view" is reserved word in SQL :) ). Сonvince yourself, please: create table a ( id

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Bart Degryse
Trees like you seem to suggest are called hierarchies. If you prefer hierarchies over relationnality you could use a hierarchical database instead of a relational database. When you search the internet you can find plenty of information on eg Adabas, GT.M., IMS, DMSII, Focus, Metakit and many ot

Re: [SQL] many 'OR' in WHERE-condition

2007-04-20 Thread A. Kretschmer
am Fri, dem 20.04.2007, um 12:03:44 +0100 mailte Richard Huxton folgendes: > A. Kretschmer wrote: > >in a SELECT with a condition 'WHERE foo IN (1,2,3,4,...)' with a large > ... > >But if the list increase the planner choose an seq-scan. The amount of > >values in the list is about 200 and the tab

Re: [SQL] Retrieve month from date

2007-04-20 Thread A. Kretschmer
am Fri, dem 20.04.2007, um 17:49:33 +0530 mailte Rohit Khare folgendes: > I am using PGSQL 8.2.3 on Windows XP. > > I have a table called "StudentFeesPayment" with columns "ReceiptNo" and > "ReceiptMonthYear". > The column, "ReceiptMonthYear" stores date in the format "-mm-dd". I have > to fi

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Richard Huxton
Joe wrote: Hi Richard, On Fri, 2007-04-20 at 12:14 +0100, Richard Huxton wrote: I'm not sure that anyone is clear why you just don't write this as a simple php/perl/ruby/whatever script? There are libraries that will output XML for you in most of these I'd suspect, and if not it's just an aft

Re: [SQL] Retrieve month from date

2007-04-20 Thread Bart Degryse
Please always include the error message you get when something isn't working. If you defined your table with quoted identifiers (create table "StudentFeesPayment" as ...) then try Select max("ReceiptNo") from "StudentFeesPayment" where Extract(Month from "ReceiptMonthYear")=4; else try Select

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Achilleas Mantzios
Just some thoughts on the matter: Dmitry, you should acknowledge the fact that in databses you have two kinds of hierarchies: a) The hierarchy denoted by the referential constraints between tables which constitute a Directed Graph (DG), with tables as nodes and FKeys as arrows. b) Hierarchies ap

[SQL] Function to return a multiple colmn table or view

2007-04-20 Thread Wilkinson, Jim
I am new to psql , so please be patient ! Can someone please provide a small quick example of a a function that take 1 paramater and based on that parameter, returns a table or view ? Etc Note this is just a abstract of the functon, not a working function call !!! Create function viewtest(

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Dmitry Turin
>How do I know with the "id=200" that 200 is an int rather than a byte or >string? Field (of database) and attribute (of tag) are put into one-to-one correspondence. Thus datatype of attribute is datatype of field (which is specified during "create table" or "alter table"). >how do we add the ne

Re: [SQL] many 'OR' in WHERE-condition

2007-04-20 Thread A. Kretschmer
am Fri, dem 20.04.2007, um 12:59:01 +0100 mailte Richard Huxton folgendes: > A. Kretschmer wrote: > > > >It's not my problem - i found it in a forum (german) > >http://pg-forum.de/showthread.php?t=1332 > > > >If the list contains up to 195 entrys -> up to 195 bitmap index scans > >and BitmapOr ->

[SQL] Retrieve month from date

2007-04-20 Thread Rohit Khare
I am using PGSQL 8.2.3 on Windows XP. I have a table called "StudentFeesPayment" with columns "ReceiptNo" and "ReceiptMonthYear". The column, "ReceiptMonthYear" stores date in the format "-mm-dd". I have to find the max(ReceiptNo) where Month of (ReceiptMonthYear)=4. Or whatever month I give.

Re: [SQL] many 'OR' in WHERE-condition

2007-04-20 Thread Richard Huxton
A. Kretschmer wrote: It's not my problem - i found it in a forum (german) http://pg-forum.de/showthread.php?t=1332 If the list contains up to 195 entrys -> up to 195 bitmap index scans and BitmapOr -> 7.839ms If the list contains 196 entrys -> seq-scan -> 5591.567ms It looks like it's gettin

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Joe
Hi Richard, On Fri, 2007-04-20 at 13:50 +0100, Richard Huxton wrote: > OK, but I'm still not seeing how this avoids me having to use > PHP/Perl/etc anyway. I mean, I'm going to need some application logic at > some point, in which case who cares whether the RDBMS has this specific > layout as a

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Joe
Hi Richard, On Fri, 2007-04-20 at 12:14 +0100, Richard Huxton wrote: > I'm not sure that anyone is clear why you just don't write this as a > simple php/perl/ruby/whatever script? There are libraries that will > output XML for you in most of these I'd suspect, and if not it's just an > afternoo

Re: [SQL] Function to return a multiple colmn table or view

2007-04-20 Thread Richard Huxton
Wilkinson, Jim wrote: I am new to psql , so please be patient ! Can someone please provide a small quick example of a a function that take 1 paramater and based on that parameter, returns a table or view ? Etc Note this is just a abstract of the functon, not a working function call !!! C

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Andrew Sullivan
On Fri, Apr 20, 2007 at 05:49:08PM +0300, Dmitry Turin wrote: > I speak about appied specialists (physicists, biologists, etc), which > can NOT do that. > >it's just an afternoon's work > > Not for mentioned people. I think part of the reason I'm sceptical of your plan is that every physicist o

Fwd: Re[2]: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Dmitry Turin
>have you written a TML parser No. I want, that you and other people help me in that. >do you have feedback from actual average users, >that TML is indeed easier to use than SQL? Yes. TML was born in discuss with these users (mainly nucleus physicists, optics , molecular biologists, zoologist an

Re: [SQL] Retrieve month from date

2007-04-20 Thread RPK
Thanks both of you, I ran EXPLAIN command on above suggested query and got following result: "Aggregate (cost=2.77..2.79 rows=1 width=10)" " -> Seq Scan on studentfeespayment (cost=0.00..2.77 rows=1 width=10)" "Filter: (date_part('month'::text, (recieptmonthyear)::timestamp without t

Re: [SQL] Retrieve month from date

2007-04-20 Thread Rodrigo De León
On 4/20/07, RPK <[EMAIL PROTECTED]> wrote: Thanks both of you, I ran EXPLAIN command on above suggested query and got following result: "Aggregate (cost=2.77..2.79 rows=1 width=10)" " -> Seq Scan on studentfeespayment (cost=0.00..2.77 rows=1 width=10)" "Filter: (date_part('month'::

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Dmitry Turin
> he wants to create a universal "database to web" interface language, so > that you and I won't have to deal with the pesky complications of > retrieving data in C with libpq or with PHP, Python and what not > libraries or "adapters", and then have to transform that data for > display to the user.

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Dmitry Turin
>every physicist or biologist ... knew a great deal of Perl They spend own time and force for that. Next generation will not have this need. >they got the computer-support staff (that was my job) And your money. Besides money, they spend own time to explain task to you. >People ... have to lear

Re: [SQL] Retrieve month from date

2007-04-20 Thread RPK
What this query will return: Select Extract(Month from 4/20/2007) from dual; I suspect "dual" is not for PGSQL but Oracle. But I need to run the above query. What is the replacement of "dual" in PGSQL. Bart Degryse wrote: > > Please always include the error message you get when something isn

Re: [SQL] Retrieve month from date

2007-04-20 Thread A. Kretschmer
am Fri, dem 20.04.2007, um 10:30:16 -0700 mailte RPK folgendes: > > What this query will return: > > Select Extract(Month from 4/20/2007) from dual; > > I suspect "dual" is not for PGSQL but Oracle. But I need to run the above > query. What is the replacement of "dual" in PGSQL. Simply "selec

Re: [SQL] Retrieve month from date

2007-04-20 Thread Scott Marlowe
On Fri, 2007-04-20 at 12:30, RPK wrote: > What this query will return: > > Select Extract(Month from 4/20/2007) from dual; > > I suspect "dual" is not for PGSQL but Oracle. But I need to run the above > query. What is the replacement of "dual" in PGSQL. > Well, you're going to have to create a

[SQL] Question on interval

2007-04-20 Thread Wei Weng
Hi all. How do I write a query that converts an interger to the interval type? Like convert integer 10 to INTERVAL '10 seconds'? The integer is a column in a table though, so it is more like convert integer tbl.theInteger to INTERVAL 'tbl.theInteger seconds". Thanks! Wei

Re: [SQL] Question on interval

2007-04-20 Thread Rodrigo De León
On 4/20/07, Wei Weng <[EMAIL PROTECTED]> wrote: Hi all. How do I write a query that converts an interger to the interval type? Like convert integer 10 to INTERVAL '10 seconds'? The integer is a column in a table though, so it is more like convert integer tbl.theInteger to INTERVAL 'tbl.theInte

Re: [SQL] Question on interval

2007-04-20 Thread Michael Glaesemann
On Apr 20, 2007, at 13:53 , Wei Weng wrote: How do I write a query that converts an interger to the interval type? Like convert integer 10 to INTERVAL '10 seconds'? An easy way to do this is: SELECT 10 * INTERVAL '1 second'; The integer is a column in a table though, so it is more like

Re: [SQL] Question on interval

2007-04-20 Thread Scott Marlowe
On Fri, 2007-04-20 at 13:53, Wei Weng wrote: > Hi all. > > How do I write a query that converts an interger to the interval type? > > Like convert integer 10 to INTERVAL '10 seconds'? > > The integer is a column in a table though, so it is more like convert > integer tbl.theInteger to INTERVAL

Re: [SQL] Question on interval

2007-04-20 Thread Steve Crawford
Rodrigo De León wrote: > On 4/20/07, Wei Weng <[EMAIL PROTECTED]> wrote: >> Hi all. >> >> How do I write a query that converts an interger to the interval type? >> >> Like convert integer 10 to INTERVAL '10 seconds'? >> >> The integer is a column in a table though, so it is more like convert >> int