Re: [SQL] sessions and prepared statements

2006-06-16 Thread John DeSoi
On Jun 15, 2006, at 11:49 AM, chester c young wrote: in PHP for example, where there are multiple sessions and which you get is random: how do you know if the session you're in has prepared a particular statement? and/or how do you get a list of prepared statements? last, is there any a

Re: [SQL] sessions and prepared statements

2006-06-16 Thread Rod Taylor
On Fri, 2006-06-16 at 08:27 -0400, John DeSoi wrote: > On Jun 15, 2006, at 11:49 AM, chester c young wrote: > > > in PHP for example, where there are multiple sessions and which you > > get is random: > > > > how do you know if the session you're in has prepared a particular > > statement? > >

Re: [SQL] sessions and prepared statements

2006-06-16 Thread Michael Fuhr
On Fri, Jun 16, 2006 at 08:55:16AM -0400, Rod Taylor wrote: > BEGIN; > SAVEPOINT; > SELECT * FROM temporary_prepared_statement; > ROLLBACK TO SAVEPOINT < on failure>; > CREATE TEMPORARY TABLE temporary_prepared_statement ...; > COMMIT; > > Now you have a place to store and retrieve prepared connec

Re: [SQL] Repetitive code

2006-06-16 Thread Joe
Aaron Bono wrote: Each of your queries has the filter xxx >= $dt where the xxx is the first column in each select. You could simplify the query by turning the unioned selects into a sub-query and then putting the $dt filter in the outer query. It would probably have to be two subqueries unle

[SQL] concurrency problem

2006-06-16 Thread sathish kumar shanmugavelu
Dear all,   I tried the lock table option today.   yes it works fine when saving simultaneously.   but after two or three times even when all of us close our application, the lock exists there in the database. when we run the select query from other db tool it hangs up.     our code looks like 

Re: [SQL] concurrency problem

2006-06-16 Thread Aaron Bono
I would use a BIGSERIAL for the ID.  It simplifies your inserts, you don't have to mess with any locking and the sequence is maintained for you outside your transaction so two transactions can do inserts without stepping on each other. This is how I handle auto generated numbers.The only downside i

Re: [SQL] Repetitive code

2006-06-16 Thread Richard Broersma Jr
> AFAIK PostgreSQL does not support materialized views but it's > interesting that you mention that because in essence the query is used > to materialize a view, i.e., it's part of an INSERT / SELECT into a > table which is then joined back to the other tables to construct a web > page as well

Re: [SQL] concurrency problem

2006-06-16 Thread Ash Grove
>INSERT INTO rcp_patient_visit_monitor ( >entry_no, patient_id, visit_date, > is_newpatient, > visit_type, is_medical, >is_review, is_labtest, is_scan, > is_scopy, is_xray, > weight, height) >VALUES ((SELECT > coalesce(max(entry_no)+1, 1

Re: [SQL] Repetitive code

2006-06-16 Thread Tom Lane
Richard Broersma Jr <[EMAIL PROTECTED]> writes: > http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html > However, I am not sure if this link shows how postgresql supports > materialized views or if it just shows how to simulate a materialized > view with procedural code. The lat

Re: [SQL] sessions and prepared statements

2006-06-16 Thread Aaron Bono
If you are using pooled connections, doesn't PostgreSQL manage the prepared statements for you?  I would expect that, once I prepare a statement, if I attempt to do it again, PostgreSQL would say, "righty then, already done it, here you go".  Then again, I don't know what PostgreSQL does under the

Re: [SQL] concurrency problem

2006-06-16 Thread Aaron Bono
I know this is a Java issue but I would recommend something more like:     Statement stmt = con.createStatement();    try {   stmt.execute("begin");   stmt.execute("lock table rcp_patient_visit_monitor");    psSave.executeUpdate(); //psSave is a prepared statement    stmt.execute("

Re: [SQL] listen_addresses = '*' ok, specific address(es) no

2006-06-16 Thread Geoffrey Knauth
Thank you Tom Lane and Phillip Smith, you've answered my questions. --Geoff On Jun 15, 2006, at 22:46, Tom Lane wrote: Geoffrey Knauth <[EMAIL PROTECTED]> writes: Andrew Sullivan wrote: Well, do you actually have an interface with that address? I think I do, in that the machine's wirele

Re: [SQL] Repetitive code

2006-06-16 Thread Aaron Bono
I haven't stared at your query as long as you have so I may have missed something but it looks like in all the selects you are combining the first column in the select is the column you filter on.  So the the outer query doesn't have to know wiether it is a new or changed row: SELECT * FROM (     S

Re: [SQL] Repetitive code

2006-06-16 Thread Joe
Aaron Bono wrote: I haven't stared at your query as long as you have so I may have missed something but it looks like in all the selects you are combining the first column in the select is the column you filter on. So the the outer query doesn't have to know wiether it is a new or changed row:

Re: [SQL] Repetitive code

2006-06-16 Thread Greg Stark
"Aaron Bono" <[EMAIL PROTECTED]> writes: > I haven't stared at your query as long as you have so I may have missed > something Likewise I'm perhaps speaking too quickly, but at the risk of making a fool of myself: you should perhaps realize that UNION has to do a fair amount of work to eliminate

Re: [SQL] sessions and prepared statements

2006-06-16 Thread PFC
in PHP for example, where there are multiple sessions and which you get is random: how do you know if the session you're in has prepared a particular statement? and/or how do you get a list of prepared statements? last, is there any after login trigger that one could use to prepare st

[SQL] keeping last 30 entries of a log table

2006-06-16 Thread Jeff Frost
I need to write a function which inserts a log entry in a log table and only keeps the last 30 records. I was thinking of using a subquery similar to the following: insert into log (account_id, message) values (1, 'this is a test); delete from log where account_id = 1 and id not in ( select id

Re: [SQL] concurrency problem

2006-06-16 Thread sathish kumar shanmugavelu
Dear group    Its my mistake that i did not reveal the whole scenario.   Actually  within that  begin  and  commit, i insert in 10 tables. The above said table is the key table.   I fetch the consultatioin_no and add one to it, i should know this consultation_no to save the other 10 tables. because