DBMS_DATAPUMP; how to get the log file of a job?

Hi
I want the user to be able to see the logfile of his job from another session.
this is my procedure
create or replace procedure get_job_log (p_job_name IN varchar2 )
is
hdl_job  number;
l_job_state     VARCHAR2 (20);
l_status        sys.ku$_Status1010;
l_job_status    sys.ku$_JobStatus1010;
l_job_logentry sys.ku$_LogEntry1010;
l_job_logline  sys.ku$_LogLine1010;
begin
hdl_job := DBMS_DATAPUMP.ATTACH(
                                     job_name   => p_job_name
                                    ,job_owner  => 'CLONE_USER'
DBMS_DATAPUMP.GET_STATUS(
   handle  => hdl_job
   ,mask   => dbms_datapump.ku$_status_job_error + dbms_datapump.ku$_status_job_status + dbms_datapump.ku$_status_wip
   --,timeout   => 15
   ,job_state =>l_job_state
   ,status    =>l_status);
l_job_logentry:=l_status.wip ;
for x in l_job_logentry.first .. l_job_logentry.last loop
   dbms_output.put_line (l_job_logentry(x).LogText) ;
end loop;
dbms_datapump.detach(hdl_job);
end;
/when I run it for the first time, it works... kindof...
but my problem is that if I try running it again I get:
ORA-31626: job does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79
ORA-06512: at "SYS.DBMS_DATAPUMP", line 902
ORA-06512: at "SYS.DBMS_DATAPUMP", line 3407
if I close sqlplus session , open new one and run - it works. So what is the issue here? Is detach not enough? What else should I do?
my version is 11.1.0.6
UPDATE.
Looks like the above is not true. It doesn't error if it runs to the end of code... The problem seems to happen only when exception occures and .detach is not called. So this is not an issue anymore.
But I still don't get a decent performance from the .get_status function. Sometimes it just hangs and errors on timeout.
Still the question is: How can I get the LOG of the session using DBMS_DATAPUMP from another session and output it on the screen?...
Edited by: Andrei Kübar on Dec 23, 2011 12:44 PM
Edited by: Andrei Kübar on Dec 23, 2011 12:57 PM

I believe I found a solution
I am now running the above code only 1 time but in a loop and inserting output into a table, so that user can query the table and see where the job is
here's the code I'm using (partially copied from http://psoug.org/reference/dbms_datapump.html)
l_job_state:='UNDEFINED';
while (l_job_state != 'COMPLETED') and (l_job_state != 'STOPPED') loop
     DBMS_DATAPUMP.GET_STATUS(
        handle  => hdl_job
       ,mask   => dbms_datapump.ku$_status_job_error + dbms_datapump.ku$_status_job_status + dbms_datapump.ku$_status_wip
     --,timeout   => 15
       ,job_state =>l_job_state
       ,status    =>l_status);
     if (bitand(l_status.mask,dbms_datapump.ku$_status_wip) != 0) then
       l_job_logentry:=l_status.wip ;
       if (l_job_logentry is not null) then
            for x in l_job_logentry.first .. l_job_logentry.last loop
                --dbms_output.put_line (l_job_logentry(x).LogText ) ;
                writelog (l_job_logentry(x).LogText );
            end loop;
       end if;
     end if;
     if (bitand(l_status.mask,dbms_datapump.ku$_status_job_error) != 0) then
        l_job_error :=l_status.error ;
        if  (l_job_error is not null) then
            for x in l_job_error.first .. l_job_error.last loop
                dbms_output.put_line (l_job_error(x).LogText) ;
                writelog('Error: '|| l_job_error(x).LogText) ;
            end loop;
        end if;
     end if;
     --dbms_output.put_line ('Current job state: '||l_job_state);
     writelog ('Current job state: '||l_job_state);
end loop;thanks all for your help

Similar Messages

  • How to create the log file in remote system using log4j.

    Hi,
    How to create the log file in remote system using log4j. please give me a sample code or related links.The below example i used for create the log file in remote system but it return the below exception.Is there any authandication parameter for accessing the remote path? Please help.
    public class Logging
    Logger log=null;
    FileAppender fileapp=null;
    public Logging(String classname)
    try
    log = Logger.getLogger(classname);
    String path=" [\\192.168.0.14\\c$\\LOG\\d9\\May_08_2008_log.txt|file://\\192.168.0.14\\c$\\LOG\\d9\\May_08_2008_log.txt]";
    fileapp = new FileAppender(new PatternLayout("%r [%t] %-5p %c %x - %m%n"),path, true);
    log.addAppender(fileapp);
    log.info("Logger initilized");
    }catch(Exception ex)
    ex.printStackTrace();
    java.io.FileNotFoundException: \\192.168.0.14\c$\LOG\d9\May_08_2008_log.txt (The network path was not found)
    at java.io.FileOutputStream.openAppend(Native Method)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at org.apache.log4j.FileAppender.setFile(FileAppender.java:290)
    at org.apache.log4j.FileAppender.<init>(FileAppender.java:109)
    at annwyn.logger.BioCapLogger.<init>(Logging.java:23)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Please help.
    Thanks in advance.
    Saravanan.K

    Sorry path is missing for the above request.
    path="\\192.168.0.14\c$\LOG\d9\May_08_2008_log.txt ";
    please help.
    Saravanan.K

  • How to get the logged in userId value in adf task flow OIM11g R2

    Hi,
    I have created an adf task flow. Now I want to run some query in that based on the logged in userId.
    Could you please help me in knowing how to get the logged in userID value in adf TaskFlow so that I can run a parameterized query.
    Thanks

    3 different ways to retrieve the username (not sure what you mean by user ID) :
    http://mahmoudoracle.blogspot.be/2012/06/adf-get-current-logged-user-name.html#.USI_c-h8zIo
    Also provide your JDev version.
    Basicly, you should use the groovy expression in a view criteria (it's the fastest and easiest way) and call that view criteria whenever you need it.
    That's if you are using ADF BC of course.

  • How to get the ard file of crystal reports

    Hi all,
    I have downloaded crystal reports from sap market place but i dont have .ard file for that how to transfer that reports into sap. How to get the ard file please help me out.
    Thanks & Regards,
    Murtuza Ahmed.

    When you click on your SAPCrystalSetup.exe and select the path to your add-on folder it will install the files and your ard file will be situated in your add-on folder.  Then you can start SAP up and install it from SAP. 
    So if your SAP install is in your local drive your ard file for crystal reports should be here C:\Program Files\SAP\SAP Business One\AddOns\SAP_CR
    Hope this helps.

  • How to get the wsdl file

    hi all,
    here java people have given wsdl file to me, how to do the scenario,
    and how to get the wsdl file from the java people.
    regards,
    priya

    Hello Priya,
    Go to http://<hostname>:50000/wsnavigator or any other UDDI server and search for the web service to be invoked
    There you can find the Webservice Definition (WSDL) file.
    Check this weblog:
    Invoke Webservices using SAPXI
    regards
    Gangaprasad

  • VISA: How to get the CSV file through C/C++ code?

    How to get the CSV file through C/C++ code?
    I'm communicating with a USB oscilloscope using VISA.

    Thank you for your reply.
    I am using Apache Commons File Upload. Here is the code where I got the "fi".
         DiskFileUpload fu = new DiskFileUpload();
              fu.setSizeMax(1000000000);
              List fileItems = fu.parseRequest(request);
             Iterator itr = fileItems.iterator();
              FileItem fi = (FileItem)itr.next();
              if(!fi.isFormField())
                File tempFileRef  = new File(fi.getName());
         System.out.println("Field = "+tempFileRef.getAbsolutePath());
         }

  • Getting the log files from client using java program

    hi
    this is lalita...and i am doing a project in networking.... i am new to socket programming....i have established the socket connection between the client and server...with this site members' help....now i have to get the log files of the client system from the server.... via the created socket....i need it by tomorrow...i.e apr 12th ....as i have to show it to my guide...
    i just need a core java program that will get the log information of the client from the server......
    Can anybody please help me in this regard..... it would be of great help to me and my group....
    Anxiously awaiting for the replies....
    Thanking you and regards...
    Lalita.

    Simple.
    Server is listening on a specific port for the connection from the clients.
    Connect the client with the server on the above mentioned port.
    Open the streams on both side for the connection and run in separate thread.
    Define a protocol for communication between client and server.
    e.g after connection with the server the server send a text message to the client (send log) now the client first should the log file name and size to the sever and then send the file. the server should save the file.
    then disconnect the client or want to get another file or for other tasks define the other commands

  • How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"

    How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"?
    I have an install SQL scripts that creates a Linked Server. I want to put some security on the Linked Server and only grant the Agent Job Signon (the "Run As" or "Executed as User") access to the linked server. I need to retrieve the
    Agent Job Signon (something like "NT SERVICE\SQLAgent$FIDEV360BI02").
    I could query certain jobs and SUBSTRING the Message column - using some form of the query below, which would return "Executed as user: NT SERVICE\SQLAgent$SSDEVBI02. The step succeeded." But that is pretty imprecise.
    use msdb
    SELECT [JobName] = JOB.name,
    [Step] = HIST.step_id,
    [StepName] = HIST.step_name,
    [Message] = HIST.message,
    [Status] = CASE WHEN HIST.run_status = 0 THEN 'Failed'
    WHEN HIST.run_status = 1 THEN 'Succeeded'
    WHEN HIST.run_status = 2 THEN 'Retry'
    WHEN HIST.run_status = 3 THEN 'Canceled'
    END,
    [RunDate] = HIST.run_date,
    [RunTime] = HIST.run_time,
    [Duration] = HIST.run_duration,
    [Retries] = HIST.retries_attempted
    FROM sysjobs JOB
    INNER JOIN sysjobhistory HIST ON HIST.job_id = JOB.job_id
    -- CHANGE THIS
    -- WHERE JOB.name like '%GroupMaster%' or Job.name like '%etlv%'
    ORDER BY HIST.run_date, HIST.run_time

    by default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
    you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
    so, if it is null, it ran as sql server agent account.
    so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
    accurate information as the new account will show up though the job really ran as old account, to get this information, you need to  get this from the logmessage column as you mentioned above.
     try this code...
    /*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
    declare @sqlserveragentaccount varchar(2000)
    select @sqlserveragentaccount= service_account
    from sys.dm_server_services
    where servicename like '%sql%server%agent%'
    select message,isnull(name,@sqlserveragentaccount) as AccountName
    from sysjobhistory a inner join sysjobsteps b
    on a.step_id=b.step_id and a.job_id=b.job_id
    left outer join sysproxies c on c.proxy_id=b.proxy_id
    Hope it Helps!!

  • Urgent:How to get the Sqltext for Oracle Sumbitted Jobs in 10g

    Dear All,
    Could you help me out in sorting the below problem.
    I use to get the current running sql's with following below query in 9i.
    SELECT A.SID,B.HASH_VALUE, OSUSER, USERNAME, SQL_TEXT
    FROM V$SESSION A, V$SQLTEXT B
    WHERE B.HASH_VALUE = A.SQL_HASH_VALUE
    AND USERNAME LIKE upper('%SCHEMA%')
    ORDER BY B.HASH_VALUE, B.PIECE;
    This is will work in 10g also for user-triggered sqls,stored procedures etc.
    But when oracle submits job i'm not able find which qurery is running.
    Seems For oracle jobs in 10g for V$session contain column SQL_HASH_VALUE as Zero and hence i'm not able find the any sql's running.
    Could you please any of you help me out how to get the Sqltext for Orcle submited Jobs in 10g.
    Please revert asap as this is very urgent for me.
    Thanks in Advance
    Anil.

    Have you tried to query WF_ITEMS? -- http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=WF_ITEMS&c_owner=APPLSYS&c_type=TABLE
    bde_wf_item.sql - Runtime Data of a Single Workflow Item [ID 187071.1]
    Thanks,
    Hussein

  • How to get the log information when using a class?

    Hi All,
    I have a simple question, which I don't know how to solve. I am using org.apache.commons.logging.Log and LogFactory to do some logging. A typical situation is exemplified in the following code snippet.
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    class LogClass {
        private static final Log LOG = LogFactory.getLog(AClass.class);
        public void logit(){
            LOG.debug("This is the debugging log.");
    public class AClass{
        public static void main(String[] args) {
            LogClass l=new LogClass();
            l.logit();
    }But this way, I do not get the log information from the class LogClass. Could anybody please help?
    Many thanks.

    jschell wrote:
    jverd wrote:
    ...configuration in log4j.xml or log4j.properties.And far as I recall you need one of those two also. If there is no config then there is no output.I thought it used some default config if no file is present, but I could be mistaken. Either way, it adds to the possible problems that the OP could be having, any of which are consistent with his rather vague question.
    1) He's passing the wrong class to the LogFactory, and hence getting a logger with the wrong name, so he's seeing a different name than he expects in the output that's being produced.
    2) His config file does not contain the proper format to include the actual classname, independent of the logger's name, so he's missing a piece of desired information in each line of the output that's being produced.
    3) His config file indicates a threshold that's less verbose than the level at which his code is logging, so no output is present when he wants it.
    4) His config file is missing (or not where it's expected to be), so no output is being produced at all.
    5) His config file is missing (or not where it's expected to be), so a default level or format is being produced, effectively the equivalent of one of the misconfigurations described in #2 and #3.
    Since the OP seems to have vanished, we may never know.

  • How to get the local file system path of an image that loaded into the image component in cq5?

    Hi,
    I'm having hard time uploading image from filesystem where as drag and drop works.
    I'm not getting a path of image selected from filesystem.
    here is my code..
    private String populateImage() throws Exception {
                        if (currentNode != null && currentNode.isNode()) {
                                       Node ImageNode = JcrResourceUtil.createPath(currentNode, "image",
                                                                          null, "nt:unstructured", true);
                                       imageUrl = ImageNode.hasProperty("fileReference") ? ImageNode.getProperty("fileReference").getValue().getString() : "";
           imageUrl = imageUrl.trim();
            log.info("MANAGE PROFILE BEAN IMAGE URL INSIDE IF IS: " + imageUrl);
                        } else {
                                            imageUrl = properties.get("fileReference", "");
                                            imageUrl = imageUrl.trim();
                                            log.info("MANAGE PROFILE BEAN IMAGE URL INSIDE ELSE IS: " + imageUrl);
                        return imageUrl;
    So if I drag and drop..
    ImageNode.hasProperty("fileReference") is returning a valid path
    but if I upload an image  it is returning Null.
    So how to get the path? any suggestions around would be appreciated...

    When you say path you mean you want the path to print out in your HTML? Is that accurate? If so you generally need to constructe that path based on the path to the current component. So if you component is located at /content/mysite/en/about/mypage/jcr:content/parsys/image then the path to the image would generally be something like /content/mysite/en/about/mypage/jcr:content/parsys/image.img.jpg/1283829292873.jpg. The .img. selector triggers the servlet associated with the foundation parbase - /libs/foundation/components/parbase/img.GET.java. The reason you reference it this way is that there is no filesystem path to the image - it is stored in the repository not on the file system, and it requires a servlet or script to ge the binary from the repository and steam it.
    Normally the way you'd construct this is to use the out of the box Image class - so look at /libs/foundation/components/image/image.jsp. Now this example assumes that your component where you loaded the image extends /libs/foundation/components/parbase. If it doesn't then you either have to change your sling:superResourceType to /libs/foundation/components/parbase or some other component that does exten /libs/foundation/components/parbase.

  • How to get the upload file from a html form ?

    I have a <input type=file ...> control in my form, and the user use that
              control to submit a file
              to my web server. The porblem is the getParameter() function of
              HttpServletRequest only return the
              filename. Does anyone know how to get the file body ?
              Frances
              

    http://www.servlets.com/jsp/examples/ch04/index.html#ex04_17
              Frances Fan <[email protected]> wrote:
              > I have a <input type=file ...> control in my form, and the user use that
              > control to submit a file
              > to my web server. The porblem is the getParameter() function of
              > HttpServletRequest only return the
              > filename. Does anyone know how to get the file body ?
              > Frances
              Dimitri
              

  • How to Get the Source File Path in the Receiver Side

    Hi Experts,
    Here We are Trying to Do How to Get the Sender Information ( File Name & Path ) on the Receiver Side .
    According to the Michal Blog
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    Here we Are Able to Get only the File Name.
    But If I Want to get the Total File  Path Also means What Should I Do Here ????
    Please Let Me Know
    Regards
    Khanna

    Khanna,
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey fkey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    DynamicConfigurationKey dkey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","Directory");
    String fname = conf.get(fkey);
    Sring path = conf.get(dkey);
    String final=fname""path;
    return ""final"";
    Best regards,
    raj.

  • How to get the EXCEL file from web site (b2b) into SAP system?

    Hi Guys,
    I have a requirement of saving the excel file that has been send to SAP system from a B2B site.
    Currently there is a call to the SAP system from the B2B site via an RFC function ,this RFC functions gets the excel file as an input to the SAP system,i need to store this Excel file in the SAP  (as an excel file itself).
    How can i acheive this?
    Please suggest.
    Thanks ,
    Swati

    You can extract a date portion and  assign to the variable and then compare with GETDATE()
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to get the .class file for the extended Controller .java file

    Hi,
    I did the below steps.
    1. Created New OAWorkspace
    2. Created New project
    3. Imported the page .xml file
    4. Added new .java file by extending the controller class
    5. Added code in the .java file.
    6. Ran the .xml file
    As I copied all the folders from Unix box, the page was opened.
    But My question was where can I see the .class file the extended controller. It's a .java file. How to compile and get the .class file for this .java file. If I get this .class file, I can go to the page and click the personlize page. and change the Controller name to the new path by ftp ing the new class to the cust.oracle.apps.pos.changeorder.webiui.
    Please let me know how to create the .class file.
    Thanks,
    HP

    All are Java files are stored in JDEV_INSTALL_DIR:\jdevhome\jdev\myprojects\
    In your case the path java would be
    JDEV_INSTALL_DIR:\jdevhome\jdev\ myprojects \cust\oracle\apps\pos\changeorder\webui\
    AND
    Once you compile the java file in Jdeveloper, Class files get generated @ below path
    In your case the path of class would be
    JDEV_INSTALL_DIR:\jdevhome\jdev\ myclasses \cust\oracle\apps\pos\changeorder\webui\
    Duplicate Thread-
    Thanks
    --Anil
    http://oracleanil.blogspot.com/

Maybe you are looking for