![]() | |
#11
| |||
| |||
|
|
1. Submitting a job to background, to be run in the future (at time specified by the call, OR immediately) I think pgAgent is very similar to Oracle's dbms_job functionality. http://www.pgadmin.org/docs/1.4/pgagent.html Very nice, but not what I'm looking for. Unless I'm misreading the documentation, this is an external tool, not callable dynamically from inside a stored procedure. |
|
2. Sending messages (data, arguments, pointer to data, whatever) to a different session via in internal queuing system. I guess LISTEN/NOTIFY is be what you are looking for: Hmmmmm.....That's an interesting feature, but [...] So I cant simulate an autonomous commit that way. |
#12
| |||
| |||
|
|
Very nice, but not what I'm looking for. Unless I'm misreading the documentation, this is an external tool, not callable dynamically from inside a stored procedure. The idea would be for a stored procedure to set up a job and submit it at run time based on local conditions. I use that sort of thing (in oracle) to schedule longish reports from a request taken from a web site user. If the report is going to take a long time (more than a second) we dont want the user waiting around for the output, so we submit a backgrand job and let the user carry on with something else while the report chugs away in the background. There's a separate mechanism for allowing the user to check on whether anything is "cooking" and which if any are ready to eat. |
#13
| |||
| |||
|
|
Can I write a stored procedure which does an automonous commit? I saw something on a website that claimed "you can't get there from here" in postgresSql but then suggested calling an pl/perl routine to do that. Can anyone sort me out on that point? I'm coming from Oracle where autonomous commits have been possible for quite a while. Thanks in advance |
#14
| |||
| |||
|
|
I have been advised, and it sounds like a good call to me, that instead of asking "How can I simulate this or that Oracle feature", It would be better to ask "How can I acheive this or that goal using Postgres" |
#15
| |||
| |||
|
|
Lee wrote: Can I write a stored procedure which does an automonous commit? I saw something on a website that claimed "you can't get there from here" in postgresSql but then suggested calling an pl/perl routine to do that. Can anyone sort me out on that point? I'm coming from Oracle where autonomous commits have been possible for quite a while. Thanks in advance I have been advised, and it sounds like a good call to me, that instead of asking "How can I simulate this or that Oracle feature", It would be better to ask "How can I acheive this or that goal using Postgres" So here goes: There are two things I'ld like to be able to do with a postgres database: I). Assume there is a fixed repteoire of (parameterized) reports that a web user might request. I want a stored procedure to look at the name of the report and possibly the value of its parameters so as to decide whether a) The report can be generated in sub-second time, in which case it is generated and displayed to the end user, OR b) If not, then I want the stored procedure to submit the report (and its parameters) to be run asap in background. |
|
II). I'ld like to create a debugging/logging tool (one or more stored procedures and supporting database objects) that can write messages specified from inside a stored procedure under test and containing both static text and the values of run time variables, which would be inserted into a database table and made visible to other sessions, regardless of whether the session from which the message originated did a commit or not. |
#16
| ||||
| ||||
|
|
There are <snip> things I'ld like to be able to do with a postgres database: I). Assume there is a fixed repteoire of (parameterized) reports that a web user might request. SNIP |
|
snip> I want the stored procedure to submit the report (and its parameters) to be run asap in background. |
|
run the report asynchronously |
|
notices don't wait for commit, you can use "RAISE DEBUG" (or "RAISE NOTICE" etc...) to pass messages out of a running stored procedure. theses mmessages are visible to the caller (if correctly configured) and may also be logged by the logging subsystem. the caller needs to be running the procedure asynchronously to see the messages before the result-set is returned. II). I'ld like to create a debugging/logging tool (one or more stored procedures and supporting database objects) that can write messages specified from inside a stored procedure under test and containing both static text and the values of run time variables, which would be inserted into a database table and made visible to other sessions, regardless of whether the session from which the message originated did a commit or not. have a look at RAISE, it'll slow down your reports less than running stuff through DBLINK to write into tables. |
#17
| |||
| |||
|
|
Lee wrote on 17.12.2009 22:59: Can I write to a file (a plain old operating system file, that is) from postgres (Without a commit?) Can I read an operating system file from a postgres stored procedure? There are various solutions for this. Right out of the box you can use the built-in function to read a file: http://www.postgresql.org/docs/8.4/s...ons-admin.html If you need to write to a file as well, you'll need to use something else. |
#18
| |||
| |||
|
|
Jasen Betts wrote: SNIP There are <snip> things I'ld like to be able to do with a postgres database: I). Assume there is a fixed repteoire of (parameterized) reports that a web user might request. SNIP snip> I want the stored procedure to submit the report (and its parameters) to be run asap in background. run the report asynchronously Yes indeed, I want to run the report asynchonously. How can I submit the job (process? stored procedure?) to run asynchronously from inside a running procedure? What is the command or feature I need to invoke? |
|
Thanks for the info on RAISE NOTICE etc. The manuals are pretty clear, but it would have taken me forever to find (or realize that I had found) what I'm looking for absent your help. |
#19
| |||
| |||
|
|
Thomas Kellerer <OTPXDAJCSJVU (AT) spammotel (DOT) com> wrote: Lee wrote on 17.12.2009 22:59: Can I write to a file (a plain old operating system file, that is) from postgres (Without a commit?) Can I read an operating system file from a postgres stored procedure? There are various solutions for this. Right out of the box you can use the built-in function to read a file: http://www.postgresql.org/docs/8.4/s...ons-admin.html If you need to write to a file as well, you'll need to use something else. COPY can write to a file 'out of the box', though it doesn't let you write in an arbitrary format. |

#20
| |||
| |||
|
|
There are two things I'ld like to be able to do with a postgres database: I). Assume there is a fixed repteoire of (parameterized) reports that a web user might request. I want a stored procedure to look at the name of the report and possibly the value of its parameters so as to decide whether a) The report can be generated in sub-second time, in which case it is generated and displayed to the end user, OR b) If not, then I want the stored procedure to submit the report (and its parameters) to be run asap in background. run the report asynchronously notices don't wait for commit, you can use "RAISE DEBUG" (or "RAISE NOTICE" etc...) to pass messages out of a running stored procedure. theses mmessages are visible to the caller (if correctly configured) and may also be logged by the logging subsystem. the caller needs to be running the procedure asynchronously to see the messages before the result-set is returned. II). I'ld like to create a debugging/logging tool (one or more stored procedures and supporting database objects) that can write messages specified from inside a stored procedure under test and containing both static text and the values of run time variables, which would be inserted into a database table and made visible to other sessions, regardless of whether the session from which the message originated did a commit or not. have a look at RAISE, it'll slow down your reports less than running stuff through DBLINK to write into tables. |
![]() |
| Thread Tools | |
| Display Modes | |
| |