Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-17 Thread Alain
Ragnar Hafstað escreveu: [how to solve the get next 100 records problem] I tried that. It does not work in the generic case: 6 MegaRec, telephone listing, alphabetical order. lets say pkey is your primary key and skey is your sort key, and there exists an index on (skey,pkey) your first select

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-17 Thread Ragnar Hafstað
On Wed, 2005-05-18 at 00:13 +0200, PFC wrote: > > your subsequent selects are > > select ... from tab WHERE skey>skey_last > >OR (skey=skey_last AND pkey>pkey_last) > > ORDER BY skey,pkey > > LIMIT 100 OFFSET 100; > > why offset

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-17 Thread PFC
your subsequent selects are select ... from tab WHERE skey>skey_last OR (skey=skey_last AND pkey>pkey_last) ORDER BY skey,pkey LIMIT 100 OFFSET 100; why offset ? you should be able to use the skey, pkey values of the last row on the

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-17 Thread Ragnar Hafstað
On Tue, 2005-05-17 at 15:43 -0300, Alain wrote: > [how to solve the get next 100 records problem] I am assuming this is for a web like interface, in other words that cursors are not applicable > > [me] > > if you are ordering by a unique key, you can use the key value > > in a WHERE clause. > >

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-17 Thread Andrew Sullivan
On Tue, May 17, 2005 at 03:43:32PM -0300, Alain wrote: > > I tried using both the name and the primary key (with a combined index), > to get faster to the record I want, but I was not sucessfull in building > a where clause. > > I would appreciate any help, in fact this is my primary reason for

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-17 Thread Alain
No. What is the purpose of your query? You could use ORDER BY and LIMIT..OFFSET to do what you want. I think. The problem is probably speed. I have done a lot of tests, and when OFFSET gets to a few thousands on a multimega-recs database, it gets very very slow... is there not a similar loss

Re: [SQL] ERROR: unterminated quoted string... help

2005-05-17 Thread Scott Marlowe
On Tue, 2005-05-17 at 13:15, Postgres Admin wrote: > Hi > > I'm trying to insert encrypted data into the database and I'm noticing > error dealing with quotes. Below is the error print out... > > suggestions and/or at least point me in the direction to find a solution, > > Thanks, > J > > >

Re: [SQL] ERROR: unterminated quoted string... help

2005-05-17 Thread Postgres Admin
Scott Marlowe wrote: Use a bytea field and use pg_escape_bytea() to prepare the data for insertion. Thanks Scott, I will try it now. J ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-noma

Re: [SQL] triggering an external action

2005-05-17 Thread Jay Parker
On 05/17/2005 01:07 PM, Bricklen Anderson wrote: How about LISTEN and NOTIFY, would they work for this? Yes, that is precisely what I need... and what I have somehow overlooked during at least a dozen passes through the docs. Sigh. Thanks for your help, -jbp -- Jay Parker - UALR Computing Serv

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-17 Thread Ragnar Hafstað
On Tue, 2005-05-17 at 14:48 -0300, Alain wrote: > > Andrew Sullivan escreveu: > > On Thu, May 12, 2005 at 01:07:00PM -0600, [EMAIL PROTECTED] wrote: > > > >>Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle? If > >>so, we can write the following query: > > > > > > No. What is the

[SQL] ERROR: unterminated quoted string... help

2005-05-17 Thread Postgres Admin
Hi I'm trying to insert encrypted data into the database and I'm noticing error dealing with quotes. Below is the error print out... suggestions and/or at least point me in the direction to find a solution, Thanks, J INSERT INTO sample.users (user_name, first_name) VALUES ('jokers', '=ïµiF!¶6

Re: [SQL] triggering an external action

2005-05-17 Thread Bricklen Anderson
Jay Parker wrote: I am trying to find the best way for a database trigger to signal a client process to take an action. Specifically, I am working on the classic problem of creating and modifying system accounts based on the updates to a "person registry" database. The basic model I'm working

Re: [SQL] triggering an external action

2005-05-17 Thread Magnus Hagander
>I am trying to find the best way for a database trigger to signal a >client process to take an action. > >Specifically, I am working on the classic problem of creating and >modifying system accounts based on the updates to a "person registry" >database. > >The basic model I'm working with has t

[SQL] triggering an external action

2005-05-17 Thread Jay Parker
I am trying to find the best way for a database trigger to signal a client process to take an action. Specifically, I am working on the classic problem of creating and modifying system accounts based on the updates to a "person registry" database. The basic model I'm working with has triggers

Re: [SQL] interesting SQL puzzle - concatenating column with itself.

2005-05-17 Thread PFC
I'm just curious - what's the 'OFFSET 0' for? Trick to fool postgres into thinking it can't rewrite out your subquery and eliminate it ... ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-17 Thread Alain
Andrew Sullivan escreveu: On Thu, May 12, 2005 at 01:07:00PM -0600, [EMAIL PROTECTED] wrote: Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle? If so, we can write the following query: No. What is the purpose of your query? You could use ORDER BY and LIMIT..OFFSET to do what you w

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle?

2005-05-17 Thread Bruno Wolff III
On Thu, May 12, 2005 at 13:07:00 -0600, [EMAIL PROTECTED] wrote: > Hi: > > Oracle has a pseudo-column "ROWNUM" to return the sequence number in which a > row was returned when selected from a table. The first row ROWNUM is 1, the > second is 2, and so on. > > Does Postgresql have a similar ps

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-17 Thread Scott Marlowe
On Thu, 2005-05-12 at 14:07, [EMAIL PROTECTED] wrote: > Hi: > > Oracle has a pseudo-column "ROWNUM" to return the sequence number in which a > row was returned when selected from a table. The first row ROWNUM is 1, the > second is 2, and so on. > > Does Postgresql have a similar pseudo-column "

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle?

2005-05-17 Thread Andrew Sullivan
On Thu, May 12, 2005 at 01:07:00PM -0600, [EMAIL PROTECTED] wrote: > > Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle? If > so, we can write the following query: No. What is the purpose of your query? You could use ORDER BY and LIMIT..OFFSET to do what you want. I think. A --

Re: [SQL] CASCADE and TRIGGER - Some weird problem

2005-05-17 Thread Ramakrishnan Muralidharan
Hi, The issue is due to records in Account_message is still exists for the records which are going to be deleted from the Message table. Please check the sequence of deleting the records. When I tried to delete a record using your example, the following exception is raised. ERROR: update o

[SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle?

2005-05-17 Thread Dennis.Jiang
Hi: Oracle has a pseudo-column "ROWNUM" to return the sequence number in which a row was returned when selected from a table. The first row ROWNUM is 1, the second is 2, and so on. Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle? If so, we can write the following query: select

[SQL] plpython setof

2005-05-17 Thread Sim Zacks
Anybody know how to return a setof from a plpython function? ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] getting duplicate number is there a

2005-05-17 Thread Ezequiel Tolnay
You can select "for update", so you ensure that the rows are locked for your current transaction's use exclusively. If the rows in question had been modified by another ongoing transaction, then the select will get blocked until the other transaction is finished. Cheers, Ezequiel Tolnay [EMAIL

Re: [SQL] interesting SQL puzzle - concatenating column with itself.

2005-05-17 Thread Dmitri Bichko
> SELECT your_concat( memo_text ) FROM > (SELECT memo_id, sequence, memo_text FROM table ORDER BY memo_id, sequence > OFFSET 0) AS foo > GROUP BY memo_id I'm just curious - what's the 'OFFSET 0' for? Dmitri ---(end of broadcast)--- TIP 5: Have yo

Re: [SQL] getting duplicate number is there a

2005-05-17 Thread Bruno Wolff III
On Mon, May 16, 2005 at 17:36:21 -0400, Joel Fradkin <[EMAIL PROTECTED]> wrote: > I was using SET TRANSACTION ISOLATION LEVEL SERIALIZABLE in MSSQL. > > > > Is there something similar in postgres to ensure its not in the middle of > being updated? Postgres also has SET TRANSACTION ISOLATION

Re: [SQL] getting duplicate number is there a

2005-05-17 Thread Joel Fradkin
I actually had the same thought (a counter table, I might be able to add fields to the location table, but we have several applications case is just an example). I agree that is probably the safest way and it also fixes another issue I have been having when a user wants to transfer a case to anothe

Re: [SQL] getting duplicate number is there a

2005-05-17 Thread Richard Huxton
Joel Fradkin wrote: I was using SET TRANSACTION ISOLATION LEVEL SERIALIZABLE in MSSQL. Is there something similar in postgres to ensure its not in the middle of being updated? Yep - see the SQL COMMANDS reference section under SET TRANSACTION ... You could use LOCK TABLE too. See Chapter 12 - Concu