Re: [GENERAL] How to lock and unlock table in postgresql

2011-11-17 Thread Siva Palanisamy
Hi Alban, Thanks for the reply. 1) I'm using PostgreSQL 8.1; So, I can't use RETURNING clause! 2) The function I gave is just to put my understanding! Thanks for spotting the error though. Regards, Siva. -Original Message- From: Alban Hertroys [mailto:haram...@gmail.com] Sent:

Re: [GENERAL] How to lock and unlock table in postgresql

2011-11-17 Thread andreas
Zitat von Siva Palanisamy siv...@hcl.com: Hi Alban, Thanks for the reply. 1) I'm using PostgreSQL 8.1; So, I can't use RETURNING clause! You should Upgrade ASAP! 8.1 is 'out of lifetime'. Regards, Andreas -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make

[GENERAL] How to lock and unlock table in postgresql

2011-11-16 Thread Siva Palanisamy
Hi ya, I've 2 tables: One being the master (table1) and another being the slave (table2). I want to lock table1 until the below function completes, and it should unlock the same at last. Below is my function. Pls guide me on how to apply locking table1 and unlocking the same finally. The

Re: [GENERAL] How to lock and unlock table in postgresql

2011-11-16 Thread John R Pierce
On 11/16/11 10:10 PM, Siva Palanisamy wrote: If there is a better solution, kindly let me know. use nextval('seqname') ... full transactional integrity without any blocking or locking. -- john r pierceN 37, W 122 santa cruz ca mid-left

Re: [GENERAL] How to lock and unlock table in postgresql

2011-11-16 Thread Siva Palanisamy
Hi John, Thanks for the solution. If I use currval('sqlname') in a loop of 7 records, what will happen if a record is inserted manually? I guess it will alter the sequences, and wrong values/chain might be introduced in foreign tables in the below function. Could you please clarify me on

Re: [GENERAL] How to lock and unlock table in postgresql

2011-11-16 Thread John R Pierce
On 11/16/11 11:16 PM, Siva Palanisamy wrote: Thanks for the solution. If I use currval('sqlname') in a loop of 7 records, what will happen if a record is inserted manually? I guess it will alter the sequences, and wrong values/chain might be introduced in foreign tables in the below

Re: [GENERAL] How to lock and unlock table in postgresql

2011-11-16 Thread Alban Hertroys
On 17 Nov 2011, at 7:10, Siva Palanisamy wrote: If there is a better solution, kindly let me know. CREATE OR REPLACE FUNCTION Fun() RETURNS VOID AS ' DECLARE Id INTEGER; BEGIN INSERT INTO table1 VALUES (DEFAULT, ''Sample'', DEFAULT); SELECT MAX(id) INTO Id