Start, restart, stop and status stored procedure - howto?

First:
- this and other otn forums are awesome!
- apex is neat
Second:
- I have O'Reilly books: "Oracle pl/sql programming" and "Mastering Oracle SQL"
- Also tried to search / google best practices around stopping 'hanging stored procedures' and creating logics for such happening
Challenge:
I would like to implement simple solution for starting, stopping, restarting and maybe even getting status of stored procedures. Sounds like unix runlevels but in "userspace" without the sys rights.
Finally I would like to have this functionality in apex-application where predefines stored procedures could be started, restarted, stopped and maybe even status could be retrieved.
start - this is simple, start - but maybe check if such stored procedure is already started ( so this start will fail)
stop - send signal to certain procedure(s) that now it/they should exit immediately
restart - actually stop+start
status - maybe via status table indicating e.g. records_processed/records_to_be_processed
Mostly I need this stop so what would be the best way to write "exit" for stored procedure? I would like to avoid the following approach:
SELECT sid, serial# , username, schemaname, osuser FROM gv$session;
ALTER SYSTEM KILL SESSION '<sid>,<serial#>' IMMEDIATE;
/paavo
Edited by: paavo on Jul 13, 2009 11:35 AM - added status to subject :)

paavo wrote:
Thank you, very good references, but still I think my challenge persist on stop still because I try to do this without the rights to v$session etc. tables.
So what would be the best way to deliver stop-message to executing stored procedure. E.g.
- via table which is regularly checked by stored procedure (e.g. in loop it selects from the table)
/paavoI think for stopping such a procedure you have only two sensible possibilities.
First option is to kill the session. For this you or the logic that does the kill needs the appropriate rights to do it.
Second option would be to programm this behaviour. The procedure can listen to a kind of signal and if it gets that signal it is stopped. This signal can be a value in a parameter table, but it can also be a message in some pipe/advanced queue. However this means the procedure will stop only at certain defined points (whenever it checks for the stop signal).
Btw: You didn't mention what is the business case behind that technical request. Maybe you can elaborate a little on that too.

Similar Messages

  • When using podcast i switch to radio-canada live and it start to stop and restart it and voice control start and stop by it self

    When i listen music on my iphone 4 using podcast (training session  workout) i switched to radio-canada live and after a while it start to stop and start radio-canada live and voice control stop and start by itself???

    I have no idea what may have caused your MacBook to stop working, but from your description it kind of sounds like it may have started before you ran Software Update and installed the new Apps. Just the general slow feeling and bugginess is what tips me off. You said that you weren't sure if you had closed all open windows, that doesn't matter if the computer restarts itself. It automatically closes all other open applications when restarting.
    As to your data being retrievable, if when you take it in they do a fresh install of the OS, then no, it will not be unless you want to pay several thousand dollars to a software retrieval company.
    I am glad to hear that you have taken into the Apple Store to get it fixed, and that you have all of your purchased music backed up to your iPod. You should be able to just transfer it all back to iTunes once you get your computer back should it be necessary.
    As a side note, the proper place for this topic would probably in the MacBook forums, not iTunes since there is no evidence that iTunes started the issue.

  • Wrapped in a function and/or stored procedure, recursive CTE stops working

    This query builds an hierarchical tree from a single table with the typical 
    value/reports_to_value columns. 
    When running in SQL manager returns like 7 records (note i'm avoiding infinite 
    loop by blocking top level value)
    WITH c 
    AS
        SELECT deptid, reports_to_dept
        FROM glo_tree
        WHERE deptid = '18538'
        UNION ALL
        SELECT t.deptid, t.reports_to_dept
        FROM glo_tree T  
        INNER JOIN c 
    ON t.deptid = c.reports_to_dept
        where t.deptid <> '00001'
    SELECT deptid  
    FROM c 
    However, the exact same query, if wrapped in a function and/or stored procedure, 
    returns 0 records (no error message whatsoever)
    CREATE FUNCTION [dbo].[checkDept] (@deptid varchar(16))
    RETURNS TABLE
    AS
    RETURN
        WITH c 
        AS
            SELECT  deptid, reports_to_dept
            FROM    glo_tree
            WHERE   deptid = @deptid
        UNION ALL
        SELECT  t.deptid, t.reports_to_dept
        FROM    glo_tree T  
        INNER JOIN c 
        ON      t.deptid = c.reports_to_dept
    SELECT deptid  
    FROM c 
    GO
    CREATE PROCEDURE [dbo].[getDept] (@deptid varchar(16))
    AS
        SELECT deptid
        FROM dbo.checkDept(@deptid)
    Then call them like:
    select * FROM checkDept('18538')exec getDept @deptid='18538'
    Both return nothing

    Thanks Patrick, i don't think it can do that, i call it like:
    select * FROM checkDept('18538')exec getDept @deptid='18538'Just to make sure, i've changed the function like:WHERE ltrim(rtrim(deptid)) = @deptidStill the same thing

  • When I try to buy any app or song from iTunes app or app store on iPhone 5 it seems to start the stops and goes back to baseline in a second or two

    When I try to buy any app or song from iTunes app or app store on iPhone 5 it seems to start the stops and goes back to baseline in a second or two.
    It did it with my old iPhone 4 in last month or so, and it I hoped it would go once I updated to new iPhone 5. The problem has transferred to new phone too.
    I can't sign in to iTunes account on iPhone. It takes the password then resets to baseline. No error message comes up. On the base computer (pc) it will allow me to sign up and buy songs, apps etc. I can then sync the phone and put them on it. It just won't let me buy direct from the .
    As there are no error messages I am at a loss what to do. I have updated the payment details on my account, and my husband has an iPhone 4 and has no such problems. We share the same wifi. I have tried with 3G as well as wifi, with no luck.
    I am pretty much out of ideas, and have tried searching forums but there is so much overlap between queries that I can't find a similar problem from someone else, but I am sure it exists!
    Can anyone please help me?
    Thanks in advance
    Sarah

    I figured it out!
    I read a solution for something that sounded similar.
    Anyone in similar position:
    Open iTunes app on iPhone, and pick an option from bottom, such as music. Then scroll down to bottom of page and where your iTunes ID is, press on it, and pick sign out.
    Then return to home screen, and double press home button and press and hold on first icon showing, until a minus symbol appears in the top left of icons present. Press on each minus symbol on each app in turn, until all app icons have disappeared. Then Restart the phone by pressing and hold the home button and the on/off/standby button at top of phone, until the apple symbol appears in centre of blank screen.
    Swipe to turn phone fully on and open settings and scroll down to iTunes and apps option and tap that. Pick sign in and put in your apple ID, it will accept it and then return to home screen and open iTunes a you'll find it works fine
    Simple really, but some like me won't think f this themselves!
    Hope that helps

  • Can we have an example of using update, insert, and delete stored procedure

    I would like to see an example of using retrieve (return resultset), update, insert, and delete stored procedures in JSF. I need to see syntax how JSF can call those stored procedures. This option is absolutely important when building web-application. Currently, I haven't found resource to do for this purpose yet. The database can be any such Oracle, DB2, pointbase, etc that support stored procedures.
    Anyone knows?
    Thanks,
    Tue Vu

    Hi ttv,
    I asked around a bit and here's some more info:
    To bind a ResultSet to a read only Data Table component just set the "value" property of the Data Table component to point at it, and JSF will synthesize a DataModel around it.
    * Note that because we can't call the stored procedure at design time, Creator can't do the fancy table layout stuff it does for rowsets. You'll need to hand craft the columns just like the Google Client example.
    * As I mentioned previously, you will have to manually code the stored procedure access in your java code - see the code clip I mentioned in previous reply (and if this is via a stored procedure, then any textbook about JDBC will undoubtedly have examples). Simplest way might be a getter method on the page bean that contains the call to the stored procedure and returns the resulting ResultSet object.
    * Don't forget to close the result set - we typically do this at the end of the request (i.e. add a close in the afterRenderResponse() method.
    * Don't throw exceptions - or if you have to, make sure you close the result set in a finally clause (thrown exceptions bypass the afterRenderResponse method in the lifecycle).
    * You give up on the caching provided by our RowSetDataModel (which can't be connected to a ResultSet even manually), so I would recommend that you only use datatables to display the data and then go to a single row page to do edits/deletes (similar to the TwoPage example in AppModel and the Update, Insert Delete tutorial).
    And yes please do submit an example - we will gladly post it!!! :) The best way to submit this kind of thing would be through:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
    on the right side, Related Links, under Creator Heros, click Submit Content and there you can send it in!
    Hope this helps!
    Val

  • Can I stop (Kill) an Stored Procedure?

    Hi All,
    I have several Stored Procedures to extract data from a database to anothe database the SP's takes approximately 3 hours, they are calls from java.
    Can I stop the SP from java code and rollback all the actions from him????

    I dont know how you will kill from JAVA, because you may need to identfy the ORACLE session and run a new JAVA program and kill it. IF you can connect through ORACLE then you can tr this (provided you have the previlages)
    Get the session id by using the following SQL.
    SELECT sid, serial#,osuser, program FROM v$session;
    Use this to kill the session.
    ALTER SYSTEM KILL SESSION 'sid,serial#';
    Thanks

  • Help Needed in Creating Java Class and Java Stored Procedures

    Hi,
    Can anyone tell how can i create Java Class, Java Source and Java Resource in Oracle Database.
    I have seen the Documents. But i couldn't able to understand it correctly.
    I will be helpful when i get some Examples for creating a Java Class, Java Source and Stored Procedures with Java with details.
    Is that possible to Create a Java class in the oracle Database itself ?.
    Where are the files located for the existing Java Class ?..
    Help Needed Please.
    Thanks,
    Murali.v

    Hi Murali,
    Heres a thread which discussed uploading java source file instead of runnable code on to the database, which might be helpful :
    Configure deployment to a database to upload the java file instead of class
    The files for the java class you created in JDev project is located in the myworks folder in jdev, eg, <jdev_home>\jdev\mywork\Application1\Project1\src\project1
    Hope this helps,
    Sunil..

  • Creating and calling stored procedure using jdbc

    When I try to create and call a stored procedure using JDBC a very confusing error message about non-existence of the procedure just created is thrown. Using Informix database (IDS 10). Any pointers to point out what am doing wrong would be great!
    Thanks
    import java.io.FileNotFoundException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Scanner;
    public class CreateStoredProc {
    public static void main(String args[]){
    if (0 == args.length)
    return;
    try {
    Class.forName("com.informix.jdbc.IfxDriver");
    Connection conn = DriverManager.getConnection("jdbc:informix-sqli://10.76.244.120:30000/sampledb:INFORMIXSERVER=krisunda;user=root;password=cisco");
    String q = " create procedure runproc() "+
    " define i int; "+
    " let i = 0; "+
    " end procedure; "+
    " execute procedure runproc(); ";
    Statement stmt = conn.createStatement ();
    stmt.execute (q);
    } catch (Exception e) {
    e.printStackTrace();
    The stack trace:
    java.sql.SQLException: Routine (runproc) can not be resolved.
    at com.informix.jdbc.IfxSqli.a(IfxSqli.java:3204)
    at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3518)
    at com.informix.jdbc.IfxSqli.dispatchMsg(IfxSqli.java:2353)
    at com.informix.jdbc.IfxSqli.receiveMessage(IfxSqli.java:2269)
    at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2157)
    at com.informix.jdbc.IfxSqli.executeExecute(IfxSqli.java:2132)
    at com.informix.jdbc.IfxResultSet.b(IfxResultSet.java:378)
    at com.informix.jdbc.IfxStatement.a(IfxStatement.java:1299)
    at com.informix.jdbc.IfxStatement.executeImpl(IfxStatement.java:1269)
    at com.informix.jdbc.IfxStatement.c(IfxStatement.java:989)
    at com.informix.jdbc.IfxStatement.execute(IfxStatement.java:875)
    at CreateStoredProc.main(CreateStoredProc.java:37)
    Caused by: java.sql.SQLException
    at com.informix.util.IfxErrMsg.getSQLException(IfxErrMsg.java:373)
    at com.informix.jdbc.IfxSqli.E(IfxSqli.java:3523)
    ... 10 more

    DriverManager.getConnection("jdbc:informix-sqli://10.76.244.120:30000/sampledb:INFORMIXSERVER=krisunda;user=root;password=cisco");check with ur sys admin wheather the particular user in the database has >execute privilage(rights) also.i mean execute the SP in the DB level.I guess that a root user will have the enough right.
    String q = " create procedure runproc() "+
    " define i int; "+<" let i = 0; "+
    " end procedure; "+
    " execute procedure runproc(); ";
    Statement stmt = conn.createStatement ();
    stmt.execute (q);Try to use the following code:
    String q = " create procedure runproc() "+
    " define i int; "+
    " let i = 0; "+
    " end procedure; "
    Statement stmt = conn.createStatement ();
    stmt.execute (q);
    q=" execute procedure runproc(); ";
    stmt.execute (q);
    Because maybe the driver failed to precompile your sql once, so that nothing happen.

  • JDBC Thin-Driver and Oracle Stored Procedure

    I've got a Oracle stored procedure which returns a Oracle record.
    How can I retrieve the record in java using the JDBC Thin-Driver ?
    Record:
    TYPE messagerec IS RECORD
    (log_level VARCHAR(2), timestamp VARCHAR2(19), text VARCHAR2(200));

    Using PL/SQL BOOLEAN, RECORD Types, and TABLE Types:
    Oracle SQLJ and JDBC do not support calling arguments or return values of the
    PL/SQL BOOLEAN type or RECORD types. Also, when using the Thin driver, they
    do not support calling arguments or return values of PL/SQL TABLE types (known
    as indexed-by tables). TABLE types are supported for the OCI driver.
    Check the following guide,
    http://otn.oracle.com/tech/java/sqlj_jdbc/pdf/a96655.pdf

  • Scripted JDBC and Oracle Stored Procedure with in/out Array

    The com.waveset.util.pooledconnection used by Scripted JDBC Adapter extends java.sql.connection.
    I need to pass an Varchar2 Array to the Stored Procedure. I tried using the oracle.sql.ARRAY and oracle.sql.ArrayDescriptor to pass the values, but get a casting exception,as the polledconnection implements only the java.sql.connection and not oracle.sql.connection.
    What are my options of using java.sql.Array with a PL/SQL procedure that takes a varchar2 array as in out parameter?
    Thanks
    Venki

    i ran my procedure which is very similar syndra posted
    create or replace procedure foo(p_dt in date, cv out sys_refcursor) as
    begin
    open cv for
    select e.*
    from table_xyz e
    where start_dt = p_dt;
    end;
    /Here is how is executed
    DECLARE
      P_DT DATE;
      CV SYS_REFCURSOR;
    BEGIN
      P_DT := '10-oct-2005';
      -- CV := NULL;  Modify the code to initialize this parameter
      scott.foo ( P_DT, CV );
      COMMIT;
    END;           
    -- i get PL/SQL procedure successfully complted , But i dont see the result set Or output
    - How do i see the output when i m using refcursor ?? i tried using print , but nothing didnt work
    - Any idea ??
    Thank you!!
    Edited by: user642297 on Jun 24, 2010 1:35 PM

  • SQLJ and Java Stored Procedures

    Hi,
    Am very sorry, if I am taxing you too much with Java Stored Procedures!!
    However, I have struggling with it for more than 3 days or so.So please bear with me
    I am facing a peculiar problem on the subject.
    I have deployed a Java Stored Procedure using Connection name as "JDBC" through JDev.
    My client calls the Stored procedure getDept as follows:
    int deptNo = 0;
    String deptName = null,
    deptLoc = null;
    #sql {
    call sample.getDept( :out deptNo,
    :out deptName,
    :out deptLoc)
    In my project properties , in SQLJ tab, when I select "JDBC" as my connectionName, and leave the ContextName blank(i.e. DefaultContext), I get the following error :
    Error: [26] Not Found: SAMPLE.GETDEPT There is no stored procedure with this name
    When I leave the ConnectionName as blank (which I suppose means donot do online checking!!), it compiles OK.
    Howvever, it is not able to run my SQLJ file!!
    Cannot figure out why this is happening.Please help!!
    TIA
    Sandeep
    null

    Looks like Java stored procedure don't support the return of result sets to the client. Given the complexity and non-generic 'cursor ref' approach that Oracle has always implemented, I guess it is not too surprising. I suggest throwing the select into a work table and pulling the rows from there. If you are in a COM capable environment, you can use 0040 to get back a Dynaset, but be aware, it is live!
    Good luck.
    Cal

  • EM and Java stored procedures

    Could anyone answer the following questions ?
    1. Will Enterprise Manager Version 2.2 and 9.2 tune Java Stored Procedures?
    2. If not, are there plans in EM 4.0 for Enterprise Manager to tuneJava Stored Procedures?
    cheers!
    Karthik

    Hi again,
    perhaps I didn't understand exactly what you meant with "publish", AFAIK you have to expose the java class (i.e. RowCounter) by using
    CREATE OR REPLACE FUNCTION row_count (tab_name VARCHAR2) RETURN NUMBER
    AS LANGUAGE JAVA
    NAME 'RowCounter.rowCount(java.lang.String) return int';
    (BTW this works fine)
    or else you cannot access the java class you loaded on the server, and that's where my questions arose. What if I am passing an object, let's say myObject, shouldn't I use the STRUCT mapping then or something like that?
    Or, could you clarify what do you mean by publishing to SQL, I just need to access the class from jdbc, not from PL/SQL or others, but as I understand to call the class from JDBC I need to call the function or procedure that calls the class and then I could call it from PL/SQL as well...
    Thanks,
    A.

  • Jdbc and java stored procedures

    Hi all,
    I am new to Oracle Java Stored Procedures but I am interested in knowing to which extent is object passing supported.
    Can I send any kind of object to a java stored procedure? And back from the procedure? Anybody knows any good resources online about Java Stored Procedures and JDBC?
    I also saw that to pass the string back you need to specify java.lang.string, how would I do in order to pass back a user defined object, do I have to register the class in Oracle before (and if yes, how?)or is the classpath enough?
    Many thanks,
    A.

    Hi again,
    perhaps I didn't understand exactly what you meant with "publish", AFAIK you have to expose the java class (i.e. RowCounter) by using
    CREATE OR REPLACE FUNCTION row_count (tab_name VARCHAR2) RETURN NUMBER
    AS LANGUAGE JAVA
    NAME 'RowCounter.rowCount(java.lang.String) return int';
    (BTW this works fine)
    or else you cannot access the java class you loaded on the server, and that's where my questions arose. What if I am passing an object, let's say myObject, shouldn't I use the STRUCT mapping then or something like that?
    Or, could you clarify what do you mean by publishing to SQL, I just need to access the class from jdbc, not from PL/SQL or others, but as I understand to call the class from JDBC I need to call the function or procedure that calls the class and then I could call it from PL/SQL as well...
    Thanks,
    A.

  • About BC4j and java stored procedure

    Is it possible create a java stored procedure using BC4j and deploy to Oracle9iR2 VM?
    If it is possible, how about the performance compare to PL/SQL stored procedure?

    In 9.0.3.3 it will be possible again. The ability to deploy a BC4J-based, local-mode Java Stored Procedure was broken in 9.0.3 before this upcoming maintenance release.
    PL/SQL will almost surely be faster if you are talking about just doing basic DML type of operations, when compared to Java stored procedures.

  • My iPod touch 4th generation suddenly started restarted over and over for no apparent reason...

    So, last night while I was asleep, my iPod Touch started to restart over and over. It loads with the Apple symbol, but with a little settings cog at the bottom of it, and when it get's to the password screen, it stays there for about one second, and the process starts over again. It wont respond to being turned off or on, and the password numbers are unresponsive.
    I tried pressing and holding the off button and the home button, and it turns off briefly before starting up again. It turns on without the little settings cog, but as usual, it stays at the password screen for a second, then the loop continues.
    I've tried plugging it into my computer, but all that does is make it do it's little 'I'M CONNECTED TO THE COMPUTER' beep every time it turns on! I don't fancy taking it to Apple to repair, as I use it every day and I don't really fancy spending the money and having to wait. If any one has had any success with this issue, I would be extremely grateful.
    Any suggestions would be completely welcome - even if they're not things that have proved to work. I'm pretty desperate.

    Use RecBoot to kick it into recovery mode and restore it.
    Basic troubleshooting steps  
    17" 2.2GHz i7 Quad-Core MacBook Pro  8G RAM  750G HD + OCZ Vertex 3 SSD Boot HD 
    Got problems with your Apple iDevice-like iPhone, iPad or iPod touch? Try Troubleshooting 101

Maybe you are looking for

  • How to save raw images as TIFF files on Adobe Bridge?

    I am trying to upload my raw images from my camera onto Adobe Bridge and save them as a TIFF file. But it does not give me that option and simply automatically saves them as JPEGs. Where is the option to keep them as raw, large TIFF files?

  • Utilizing Adobe Reader version 11.6.3 in Ipad running IoS 8.1

    I am unable to open Adobe Forms that have been digitally signed with PKI Certificates. Is there Guidance on Viewing the PKI Signed Files on IoS? When I Load the PDF via ITunes, Drop Box, Icloud makes no difference, the File states that : "Please Wait

  • Communication between swf

    HI, I have a communication problem between to SWF. Here is my code, SwfA is the caller : Shared interface between the 2 Swf : public interface ItfA {   // some code In the second Swf, SwfB, the document class : public class MainB extends MovieClip {

  • Event ID 4097 Hyper-V-Integration-VSS

    Hello, Trying to figure out why I'm getting Event ID 4097 Hyper-V-Integration-VSS after the backup runs. The event says: "The Virtual machine A9BCE8FC-FB7A-463A-B4F3-3A6AE83446B7 cannot be backed up since it has dynamic disks in it" These starting to

  • Calender items not showing up on my desktop

    I recently had to change some settings (tech support) and one was deleting Desktop service book.  Now my calender items won't show up on my home screen. Does anyone have any suggestions?