Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread Bo Lorentsen
Michael Fuhr wrote: Right -- when you open a cursor PostgreSQL doesn't know how many rows it will return. PostgreSQL selects a query plan based on an *estimate* of how many rows the query will return, but until you fetch all the rows you can't know for sure how many rows there will be. So if

Re: [SQL] Can EXCEPT Be Used for To Solve This Problem?

2005-08-24 Thread Michael Fuhr
On Wed, Aug 24, 2005 at 05:34:49PM -0600, Michael Fuhr wrote: > On Wed, Aug 24, 2005 at 04:47:16PM -0400, Lane Van Ingen wrote: > > Given the following data in a table named 'foo' : > > id update_time description > > 22005-08-24 00:10:00 transaction1 > > 22005-0

Re: [SQL] Can EXCEPT Be Used for To Solve This Problem?

2005-08-24 Thread Tom Lane
"Lane Van Ingen" <[EMAIL PROTECTED]> writes: > I want to select 2nd oldest transaction from foo (transaction 3). Can't you just do select * from foo order by update_time desc offset 1 limit 1 regards, tom lane ---(end of broadcast)

Re: [SQL] Can EXCEPT Be Used for To Solve This Problem?

2005-08-24 Thread Michael Fuhr
On Wed, Aug 24, 2005 at 04:47:16PM -0400, Lane Van Ingen wrote: > Given the following data in a table named 'foo' : > id update_time description > 22005-08-24 00:10:00 transaction1 > 22005-08-24 00:22:00 transaction2 > 22005-08-24 00:34:00 transacti

[SQL] Can EXCEPT Be Used for To Solve This Problem?

2005-08-24 Thread Lane Van Ingen
Given the following data in a table named 'foo' : id update_time description 22005-08-24 00:10:00 transaction1 22005-08-24 00:22:00 transaction2 22005-08-24 00:34:00 transaction3 22005-08-24 00:58:00 transaction4 I want to select 2nd old

Re: [SQL] how to do a select * and decrypt a column at the same

2005-08-24 Thread Scott Marlowe
On Tue, 2005-08-16 at 14:53, The One wrote: > Hello, > > I have a table with one encrypted column. > How can I do a select statement such that it will select all columns > from the table and at the same time will decrypt it too? A view should be able to do that... ---(en

Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread Michael Fuhr
On Wed, Aug 24, 2005 at 04:29:00PM +0200, Bo Lorentsen wrote: > Michael Fuhr wrote: > >...which is the same reason a cursor doesn't know how many rows it will > >fetch until you fetch them all (or MOVE to the end of the cursor, > >which fetches the rows internally). > > So, Postgresql is not hiddin

Re: [SQL] How to join several selects

2005-08-24 Thread Zac
Josep Sanmartí wrote: Hello, I have a 'big' problem: I have the following table users(name, start_time, end_time), a new row is set whenever a user logs into a server. I want to know how many users have logged in EVERYDAY between 2 different dates. The only idea that I have is making several

Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread Bo Lorentsen
Michael Fuhr wrote: ...which is the same reason a cursor doesn't know how many rows it will fetch until you fetch them all (or MOVE to the end of the cursor, which fetches the rows internally). So, Postgresql is not hidding something for me, it just, like me, don't know ? /BL

Re: [SQL] How to join several selects

2005-08-24 Thread Michael Glaesemann
On Aug 24, 2005, at 11:03 PM, Sean Davis wrote: On 8/24/05 9:46 AM, "Josep Sanmartí" <[EMAIL PROTECTED]> wrote: Hello, I have a 'big' problem: I have the following table users(name, start_time, end_time), a new row is set whenever a user logs into a server. I want to know how many user

Re: [SQL] How to join several selects

2005-08-24 Thread Rod Taylor
On Wed, 2005-08-24 at 15:46 +0200, Josep Sanmartí wrote: > Hello, > I have a 'big' problem: > I have the following table users(name, start_time, end_time), a new row > is set whenever a user logs into a server. I want to know how many > users have logged in EVERYDAY between 2 different dates. Th

Re: [SQL] How to join several selects

2005-08-24 Thread Sean Davis
On 8/24/05 9:46 AM, "Josep Sanmartí" <[EMAIL PROTECTED]> wrote: > Hello, > I have a 'big' problem: > I have the following table users(name, start_time, end_time), a new row > is set whenever a user logs into a server. I want to know how many > users have logged in EVERYDAY between 2 different dat

[SQL] How to join several selects

2005-08-24 Thread Josep Sanmartí
Hello, I have a 'big' problem: I have the following table users(name, start_time, end_time), a new row is set whenever a user logs into a server. I want to know how many users have logged in EVERYDAY between 2 different dates. The only idea that I have is making several select (one for each da

Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread Michael Fuhr
On Wed, Aug 24, 2005 at 02:50:07PM +0200, Bo Lorentsen wrote: > Russell Simpkins wrote: > >If you need a count, why not just execute one of the methods to get a > >count. i.e.e select count(id) ... > > The reason why i don't just make a count and then a selection of data > is performance. ...w

Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread Bo Lorentsen
Russell Simpkins wrote: If you need a count, why not just execute one of the methods to get a count. i.e.e select count(id) ... The reason why i don't just make a count and then a selection of data is performance. /BL ---(end of broadcast)-

Re: [SQL] SQLException - SET AUTOCOMMIT TO OFF is no longer supported

2005-08-24 Thread Joel Fradkin
I am getting ready to start using jboss with postgres (newer to jboss then postgres). Is there a mailing list for java postgres support? Can you post the connection elements for JBOSS or is that something documented in the JDBC driver?   Joel Fradkin   Wazagua, Inc. 2520 Trailma

Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread John DeSoi
On Aug 24, 2005, at 6:31 AM, Bo Lorentsen wrote: How sad, then I have to repeat the query, first for counting and last for data fetch :-( No, you can use the MOVE command and read how many rows you moved with something like MOVE LAST IN mycursor; http://www.postgresql.org/docs/8.0/inter

Re: [SQL] SQLException - SET AUTOCOMMIT TO OFF is no longer supported

2005-08-24 Thread Russell Simpkins
  I have created datasource but getting this error on JBOSS startup.   Using: PostgreSQL 8.0 JBOSS: JBOSS-3.2.6   16:09:37,093 WARN  [TransactionImpl] XAException: tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=dinesh//1, BranchQual=] errorCode=XA_UNKNOWN(0)

Re: [SQL] SQLException - SET AUTOCOMMIT TO OFF is no longer supported

2005-08-24 Thread Russell Simpkins
  16:09:37,093 WARN  [TransactionImpl] XAException: tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=dinesh//1, BranchQual=] errorCode=XA_UNKNOWN(0) org.jboss.resource.connectionmanager.JBossLocalXAException: Error trying to start local tx: ; - nested throwable: (org.jb

Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread Russell Simpkins
[EMAIL PROTECTED] wrote: You cannot count the number of rows in a cursor, unfortunately. I recently ran in to this problem. How sad, then I have to repeat the query, first for counting and last for data fetch :-( /BL If you need a count, why not just execute one of the methods to get a c

Re: [SQL] SQLException - SET AUTOCOMMIT TO OFF is no longer supported

2005-08-24 Thread Dinesh Pandey
After using correct version of JDBC driver I am able to start JBOSS server.   Thanks Dinesh Pandey   I have created datasource but getting this error on JBOSS startup.   Using: PostgreSQL 8.0 JBOSS: JBOSS-3.2.6   16:09:37,093 WARN  [TransactionImpl] XAException: tx=Tr

[SQL] SQLException - SET AUTOCOMMIT TO OFF is no longer supported

2005-08-24 Thread Dinesh Pandey
I have created datasource but getting this error on JBOSS startup.   Using: PostgreSQL 8.0 JBOSS: JBOSS-3.2.6   16:09:37,093 WARN  [TransactionImpl] XAException: tx=TransactionImpl:XidImpl [FormatId=257, GlobalId=dinesh//1, BranchQual=] errorCode=XA_UNKNOWN(0) org.jboss.resource.conne

Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread Bo Lorentsen
[EMAIL PROTECTED] wrote: You cannot count the number of rows in a cursor, unfortunately. I recently ran in to this problem. How sad, then I have to repeat the query, first for counting and last for data fetch :-( /BL ---(end of broadcast)--

Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread Bo Lorentsen
Thomas Borg Salling wrote: Bo Lorentsen wrote: Is it possible to get the total number of rows found in a cursor, or must I make a count(*) and then a select ? Perhaps: GET DIAGNOSTICS rc = ROW_COUNT; Ok, and when I use the C interface the "DECLARE .." function will return the row count ?

Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread neil.saunders
You cannot count the number of rows in a cursor, unfortunately. I recently ran in to this problem. As far as I am aware, the only way to count them is to either iterate through them, or if you are only expecting one or two, perform multiple FETCHES and test if the record set returned is empty

Re: [SQL] Tuple insert missing query in ongoing transaction

2005-08-24 Thread Szűcs Gábor
Dear DAQ, Thanks for the native answer ;) For those who have concerns reading Hungarian, here is an excerpt including my answer. You adviced me to issue an ACCESS EXCLUSIVE lock on table "shift" in transaction B, before issuing the actual insert, so that the insert will wait till the end of

Re: [SQL] Number of rows in a cursor ?

2005-08-24 Thread Thomas Borg Salling
Bo Lorentsen wrote: Is it possible to get the total number of rows found in a cursor, or must I make a count(*) and then a select ? Perhaps: GET DIAGNOSTICS rc = ROW_COUNT; (see http://archives.postgresql.org/pgsql-novice/2003-06/msg00143.php and http://www.postgresql.org/docs/8.0/interacti

[SQL] Number of rows in a cursor ?

2005-08-24 Thread Bo Lorentsen
Hi ... Is it possible to get the total number of rows found in a cursor, or must I make a count(*) and then a select ? /BL ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq