Scheduling a plsql procedure

I have a Pl/sQL procedure ex_proc which inturn calls a ex_function to generate a CSV file(test.csv) in the unix box in the location specified by creating a directory in the database as below
CREATE DIRECTORY dmpdir AS '/export/home'
directory created
CREATE OR REPLACE PROCEDURE ex_proc AS
l_rows number;
begin
l_rows := ex_function_('select *
from table1 where rownum < 45
'MYDIR1',
test.csv');
I would like to schedule this procedure via a UNIX job to run every 15 Minutes
Pls suggest me how can i be achieved? In which location a Pl.sQL procedure be scheduled in unix box..
Many Thanks in advance

I see that the procedure is incomplete and wont compile as there is no END statement in it.
Please look for CRON jobs in unix around google, you can figure out how it can be achieved, but prior to that please validate the package....

Similar Messages

  • Calling sql script in plsql procedure

    Hello,
    I have a sql script named mytest.sql and i want to execute this from a stored procedure.
    following is the contents of this script
    spool d:\mytestsql.txt
    select * from tab;
    spool off
    Actually i want my sql script to run daily to export some tables data.
    I can execute this script from a sql prompt but i want to run it from enterprise manager.
    I am using oracle 10gR2 on windows2000 system.
    Any idea about scheduling the sql script to run automatically??
    How to execute this sql script from a plsql procedure??
    Thanks

    Hi all,
    Thanks for all the replies. I have found the solution with external procedures.
    Following is the complete step by step guide.
    1. Create the OSCommand Java Class using the following statement:
    connect as any user:
    create or replace and compile java source named oscommand as
    import java.io.*;
    public class OSCommand{
    public static String Run(String Command){
    try{
    Runtime.getRuntime().exec(Command);
    return("0");
    catch (Exception e){
    System.out.println("Error running command: " + Command +
    "\n" + e.getMessage());
    return(e.getMessage());
    2. Create the following Wrapper Function using the following statement:
    CREATE or REPLACE FUNCTION OSCommand_Run(Command IN STRING)
    RETURN VARCHAR2 IS
    LANGUAGE JAVA
    NAME 'OSCommand.Run(java.lang.String) return int';
    3. connect as sys
    Execute dbms_java.grant_permission( 'FKHALID','SYS:java.io.FilePermission', '<<ALL FILES>>','execute');
    execute dbms_java.grant_permission( 'FKHALID','SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '*' );
    execute dbms_java.grant_permission( 'FKHALID','SYS:java.lang.RuntimePermission', 'readFileDescriptor', '*' );
    commit;
    note: here fkhalid is the oracle user.
    connect as fkhalid user:
    Declare
    expdp_cmd Varchar2(2000);
    Begin
    expdp_cmd := OSCommand_Run('cmd /c sqlplus fkhalid@mtcedwt/pwd @d:\ORA_DUMPS\mydbexp.sql');
    DBMS_OUTPUT.Put_Line(expdp_cmd);
    End;
    In Unix
    Set Serverout On
    Declare
    x Varchar2(2000);
    Begin
    x := OSCommand_Run('/home/test/myoscommand.sh')
    DBMS_OUTPUT.Put_Line(x);
    End;
    I will check the dbms_scheduler also and will let you know the results.
    Thanks

  • Calling Batch files in PLSQL Procedure

    Hi all,
    I am working on a PLSQL procedure and having issues when I am trying to call a batch file.
    Issue:-
    I have a procedure which have to kick off a batch file. And that batch file needs to run in Windows not in Unix box. 
    Can someone please help me out in providing some samples or anything?
    Thanks a lot in advance.

    Thank you rp0428 and sb92075,
    I have tried to create a sample of what I am trying to get and so I have created the following code in a batch file and named as Check.bat:-
    @set a=3
    @set b=4
    @set /a c=%a%+%b%
    echo %c%
    So based on those links you guys provided I have created an
    Scheduler Job:-
    BEGIN
    DBMS_SCHEDULER.create_job (job_name        => 'MYJOB1',
                               job_type        => 'EXECUTABLE', JOB_ACTION      => 'c:\Check.bat', enabled         => TRUE,comments        => 'runs Check.bat' );
    END;
    And the following Procedure :-
    CREATE OR REPLACE PROCEDURE execute_bat_file
    IS
    BEGIN
       DBMS_SCHEDULER.RUN_JOB ('MYJOB1', TRUE);
    END execute_bat_file;
    And used the following exec command:-
    exec execute_bat_file;
    I am getting the following error:-
    Error starting at line 1 in command:
    exec execute_bat_file
    Error report:
    ORA-27475: "ACTUATE.MYJOB1" must be a job
    ORA-06512: at "SYS.DBMS_ISCHED", line 150
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
    ORA-06512: at "ACTUATE.EXECUTE_BAT_FILE", line 4
    ORA-06512: at line 1
    27475. 00000 -  "\"%s.%s\" must be a %s"
    *Cause:    An object of the wrong type was specified. For example, a table
               could have been passed to the drop_job() procedure.
    *Action:   Reissue a different command applicable to this object type or
               reissue the same command using an object of the valid type.
    Can you guys please help with this?
    Thank you once again

  • Using PLSQL procedure with parameter in AQ

    hi,
    we need to run a PLSQL procedure(asynchronously) with in parameters using oracle AQ.
    can someone give me simple example/hint?
    Many thanks

    Since you mention dbms_job, can you use dbms_scheduler since you can pass in parms? You can schedule the job to run "now" and while it may have a slight delay starting up due to available processes for the scheduler and system load, it will run as soon as it can.
    What are you trying to accomplish in your environment? I'm not following why you want to allow a user to schedule any DB procedure. A certain set yes, all, no.
    You could create a generic AQ structure where it is passed some information regarding what procedure needs to run and what/where the parms are. This driver procedure would then be responsible for calling a random procedure via dynamic SQL. I've never tried passing parms to a procedure via dynamic SQL but recall reading you could do it. I wouldn't recommend this approach unless you have no better options though.

  • Running Plsql procedure using shell script

    Dear All,
    Dear All,
    I have to generate reports weekly by using a plsql procedure.
    For Exapmle : My Proc name is Weekly_report(i number).
    Here i is the argument for which i need to run the proc 7 times as follows
    exec weekly_report(1)
    exec weekly_report(2)
    exec weekly_report(3)
    exec weekly_report(4)
    exec weekly_report(5)
    exec weekly_report(6)
    exec weekly_report(7)
    I need to run them parallely at a time so that time taken will be less. Is there any way doing this through shell script.
    Thanks in asdvance.

    damorgan wrote:
    I can't think of anything in the Oracle world left in the dustbin of history I miss less than shell scripts.
    Why work in another language, why work in a tool that is non-portable, why have to deal with SysAdmins when dbms_scheduler is many times more capable?
    Definitely DBMS_SCHEDULER. Shell scripting is obsolete with perhaps only a few very rare exceptions.+1: shell scripts suck.
    DBMS_Scheduler allows you to setup the report procedures as programs that are executed at the same time in a single job (as steps in a scheduler chain). you can also setup email confirmation based on them successfully completing. All good stuff and not difficult to do.

  • The simplest way for plsql procedure to return multiple rows

    Hi,
    What is the simplest way for plsql procedure to return multiple rows (records). There are many combination of ways to do it but I am looking for a solution that is appropriate for plsql beginners. Many solutions use cursors, cursor variables, collections and more that kind of things that are complex on the face of it. Is it somehow possible to achieve the same with less effort?
    Sample query would be: SELECT * FROM EMPLOYEES;
    I want to use returned rows in APEX to compose APEX SQL(in that context plsql) report.
    It is enough to use just SELECT * FROM EMPLOYEES query in APEX but I want to use plsql procedure for that.
    Thank you!

    Hi,
    It depends :-).
    With +...that is appropriate for plsql beginners...+ in mind... it still depends!
    The list of techniques (ref cursors, cursor variables, collections, arrays, using explict SQL) you have referenced in your post can be made to work. but...
    +Is it somehow possible to achieve the same with less effort?+ Less effort : That needs to be defined (measured). Especially in the context of pl/sql beginners (who is a beginner?) .
    What is the level of "programming experience" ?
    What is the level of understanding of "Relational Result set" as processible in Oracle?
    If you are looking for
    Process_the_set_of rows_in APEX () kind of capabilitywhich "abstracts/hides" relation database from developers when working on relation database, it may not be the best approach (at least strategically). Because I believe it already is abstracted enough.
    I find REF CUROSOR most effective for such use, when the "begginer" has basic understanding of processing SQL result set .
    So in a nut shell, the techniques (that you already are familiar with) are the tools available. I am not aware of any alternative tools (in pure Oracle) that will simplify / hide basics from develpers.
    vr,
    Sudhakar B.

  • Business Event not triggering the PLSQL procedure.. What to do?

    We need to call a plsql procedure when the GL Approval workflow has ended with approval. I thought i could do this by customizing the relevant business event.
    We are on EBS 12.1.3 with RDBMS : 11.2.0.3.0.
    I saw that the business event oracle.apps.gl.Journals.journal.approve was disabled currently. I enabled it and created a subscription for it. Subscription was a PLSQL procedure. Currently, for test purpose only thing it is doing is to insert a row into a table.
    Business Event Subscription settings:
    System: ORDEBS.SYSTEM.COM
    Triggering Event
    Source Type:Local
    Event Filter: oracle.apps.gl.Journals.journal.approve
    Execution Condition
    Phase: 100
    Status: Enabled
    Rule Data: Message
    Action Type:Custom
    On Error: Stop and Rollback
    Action
    PL/SQL Rule Function: XX_GL_APPROVE_BE_PKG.Get_Attributes
    Priority: Normal
    Documentation (Not sure what value to be given for these. I went with the below values.)
    Owner: Company Name
    Owner Tag: Custom Schema
    Using the below query i can see that the business event is getting called when the approval happens (One row added each time approval happened). But I cant see any rows in the table where it should insert a row. What could be going wrong? How can i verify that the procedure has been called?
    select * from WF_DEFERRED where corrid ='APPS:oracle.apps.gl.Journals.journal.approve'
    Procedure:
    CREATE OR REPLACE PACKAGE BODY APPS.XX_GL_APPROVE_BE_PKG
    AS
    PROCEDURE Get_Attributes
    IS
    BEGIN
    INSERT INTO xx.xx_test_table VALUES ('From BE');
    COMMIT;
    END Get_Attributes;
    END XX_GL_APPROVE_BE_PKG;

    Thanks Alejandro. Now this is working.
    Changes i made:
    1. Added the WFERROR workflow as a subscription to this event. So i could see that the function i am calling from the event did not have proper signature.
    2. Changed the function signature to have standard parameters like:
    CREATE OR REPLACE PACKAGE BODY XX_GL_APPROVE_BE_PKG
    AS
    function subscription(p_subscription_guid in raw,
    p_event in out nocopy wf_event_t) return varchar2 is
    l_result varchar2(20);
    begin
    insert into xxvtv.xxvtv_test_table values ('From BE');
    commit;
    exception
    when others then
    wf_core.context('XX_GL_APPROVE_BE_PKG','function subscription', p_event.getEventName(), p_event.getEventKey());
    wf_event.setErrorInfo(p_event, 'ERROR');
    return 'ERROR';
    end subscription;
    END XX_GL_APPROVE_BE_PKG;
    3. Changed the owner name and owner tag both to the custom schema name (XX)

  • Passing values to between Pages from a PLSQL Procedure in third Page

    Hello,
    I have a form divided into 3 pages. The first Page is used to select Template which is used to call a screen Page 54 and Page 55 (Wizard Based screen).
    From Page 55 (third page) of my application, When I click on Finish Button (Submit Button), a PLSQL Procedure is called which inserts values in 5 to 6 tables on a schema. The Success message include Article &DOCID. successfully Added.
    When I return to the first Page which is Page 24, it displays no value for DOCID.
    Sample Example =
    DECLARE
    DOCID VARCHAR2(30);
    BEGIN
    INSERT INTO SURE_DOCUMENT
    DOCUMENT_ID
    , DOCUMENT_TYPE
    , TITLE
    , STATUS
    , DISTRIBUTION
    , ARCHIVE_REVIEW_DATE
    , CONTENT_TYPE
    , IMPACT
    , SKILL_LEVEL
    , SOURCE
    , SERVER_MIN_VERSION
    , SERVER_MAX_VERSION
    , REFRESH_INTERVAL
    , LAST_REFRESH
    , FOLDER_ID
    , TOPIC_ID
    , NOTE_POSITION
    , OWNING_SITE
    , MODIFY_NUMBER
    , VERSION_STRING
    , ALIAS
    , EXTKEY
    , FORMAT_MODIFIER
    , DELETED
    , CREATED_BY
    , CREATED_DATE
    , CREATED_SITE
    , UPDATED_BY
    , UPDATED_DATE
    , UPDATED_SITE
    VALUES
    ( SURE_DOCUMENT_SEQ.NEXTVAL || '.1'
    , :ARTICLE_TYPE
    , :TITLE
    , :STATUS
    , :DISTRIBUTION
    , SYSDATE
    , 'TEXT/PLAIN'
    , 'LOW'
    , 'NOVICE'
    , 'ADHOC'
    , :RDBMS_MIN_VERSION
    , :RDBMS_MAX_VERSION
    , NULL
    , NULL
    , :FOLDER
    , :TOPIC
    , NULL
    , 1
    , 1
    , NULL
    , NULL
    , NULL
    , NULL
    , 'N'
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    COMMIT;
    SELECT SURE_DOCUMENT_SEQ.CURRVAL INTO DOCID FROM DUAL;
    INSERT INTO SURE_DOCUMENT_CONTRIBUTORS
    DOCUMENT_ID
    , SURE_SEQUENCE
    , USER_ID
    , CONTRIBUTION_DATE
    , CONTRIBUTION_ROLE
    , MODIFY_NUMBER
    , REASON
    , DELETED
    , CREATED_BY
    , CREATED_DATE
    , CREATED_SITE
    , UPDATED_BY
    , UPDATED_DATE
    , UPDATED_SITE
    VALUES
    ( DOCID
    , 1
    , 'SKOPPALK.UK'
    , SYSDATE
    , 'Contributing Author'
    , 1
    , 'Contributing Author'
    , 'N'
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    INSERT INTO SURE_DOCUMENT_LANGUAGES
    DOCUMENT_ID
    , SURE_SEQUENCE
    , LANGUAGE
    , DELETED
    , CREATED_BY
    , CREATED_DATE
    , CREATED_SITE
    , UPDATED_BY
    , UPDATED_DATE
    , UPDATED_SITE
    VALUES
    ( DOCID
    , 1
    , 'USAENG'
    , 'N'
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    INSERT INTO KREW_WORKFLOW
    DOCUMENT_ID
    , PRIORITY
    , OWNER
    , REVIEWER
    , MODERATOR
    , ASSIGNED_DATE
    , DUE_DATE
    , CHECKED_OUT_BY
    , CHECKED_OUT_DATE
    , VERSION_STRING
    , DESCRIPTION
    , AUTHORS
    , COMMENTS
    , UPD_DATE
    , COPYSTATUS
    , COPYDISTRIBUTION
    , COPYFOLDERID
    VALUES
    DOCID
    , 3
    , DECODE(:OWNERS, NULL, 'UNASSIGNED',:OWNERS)
    , DECODE(:REVIEWER, NULL, 'UNASSIGNED',:REVIEWER)
    , DECODE(:MODERATOR, NULL, 'UNASSIGNED',:MODERATOR)
    , SYSDATE
    , SYSDATE + 7
    , NULL
    , NULL
    , 'SKOPPALK.UK'
    , :TITLE
    , :AUTHORS
    , :COMMENTS
    , SYSDATE
    , :STATUS
    , :DISTRIBUTION
    , :FOLDER
    INSERT INTO SURE_DOCUMENT_KEYWORDS
    DOCUMENT_ID
    , SURE_SEQUENCE
    , KEYWORD_TYPE
    , KEYWORD
    , DELETED
    , CREATED_BY
    , CREATED_DATE
    , CREATED_SITE
    , UPDATED_BY
    , UPDATED_DATE
    , UPDATED_SITE
    VALUES
    ( DOCID
    , 1
    , 'NOTE'
    , :KEYWORDS
    , 'N'
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    INSERT INTO SURE_DOCUMENT_REFERENCES
    DOCUMENT_ID
    , SURE_SEQUENCE
    , REFERENCE_SOURCE
    , REFERENCE_DOCUMENT_ID
    , REFERENCE_TYPE
    , REFERENCE_DESCRIPTION
    , DELETED
    , CREATED_BY
    , CREATED_DATE
    , CREATED_SITE
    , UPDATED_BY
    , UPDATED_DATE
    , UPDATED_SITE
    VALUES
    ( DOCID
    , 1
    , 'NOTE'
    , DOCID || '.1'
    , 'NOTE'
    , :REFERENCES
    , 'N'
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    INSERT INTO SURE_DOCUMENT_PLATFORMS
    DOCUMENT_ID
    , SURE_SEQUENCE
    , PLATFORM_ID
    , MIN_VERSION
    , MAX_VERSION
    , DELETED
    , CREATED_BY
    , CREATED_DATE
    , CREATED_SITE
    , UPDATED_BY
    , UPDATED_DATE
    , UPDATED_SITE
    VALUES
    ( DOCID
    , 1
    , :PLATFORMS
    , NULL
    , NULL
    , 'N'
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    INSERT INTO SURE_DOCUMENT_PRODUCTS
    DOCUMENT_ID
    , SURE_SEQUENCE
    , PRODUCT_ID
    , COMPONENT_ID
    , MIN_VERSION
    , MAX_VERSION
    , DELETED
    , CREATED_BY
    , CREATED_DATE
    , CREATED_SITE
    , UPDATED_BY
    , UPDATED_DATE
    , UPDATED_SITE
    VALUES
    ( DOCID
    , 1
    , :PRODUCTS
    , NULL
    , NULL
    , NULL
    , 'N'
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    , HTMLDB_CUSTOM_AUTH.GET_USER
    , SYSDATE
    , 1
    COMMIT;
    END;
    The Success message is as follows:
    Article &DOCID. Created/Updated Successfully

    Shivanand,
    There's no need to post that much code when you could create a very short test case that demonstrates only the problem you are having.
    You're using &NAME. notation on something that isn't a page or application item. You can't reference PL/SQL variables that way (or any other way) outside the PL/SQL scope. For your situation, you could create a page item named P55_DOCID and assign it a value in the PL/SQL process (:P55_DOCID := DOCID;), then reference &P55_DOCID. in HTML areas like the success message.
    Scott

  • How Can i get PLSQL Procedure out values in Shell Script?

    Hi,
    I need to use PLSQL Procedure out values in shell script by using that parameter i need to check and call the other procedure. Please can you guide me how can i?
    #!/bin/ksh
    # Function to call validation program
    SQL_PKG_CALL()
    echo "Inside SQL_PKG_CALL for $file"
    sqlplus -s /nolog << EOF
         whenever sqlerror exit failure
         connect ${APPS_LOGIN}
         variable exit_value NUMBER
         set serveroutput on size 100000
         DECLARE
              l_errbuf VARCHAR2(10000) := NULL; l_retcode NUMBER := NULL;lv_test VARCHAR2(4000) := NULL;
         BEGIN
              fnd_global.apps_initialize ( USER_ID => ${USER_ID}, RESP_ID => ${RESP_ID}, RESP_APPL_ID => ${RESP_APPL_ID}
                             , SECURITY_GROUP_ID => ${SECURITY_GROUP_ID}
              #Calling PLSQL procedure for create and attache document
              XXAFPEEP_SO_DOC_ATTACH_INT.DOCUMENT_ATTACH (p_errbuf => l_errbuf, p_retcode => :RETMSG, p_fileName => $file
                                       , p_debug => 'Y', p_rettest => lv_test);
              # to print the procedure return values
              DBMS_OUT.PUT_LINE('Return Message: '|| lv_test);
              #${RETCODE}=l_retcode;
              print :RETMSG;
         END;
    EXIT 0
    EOF
    # Program starts here
    echo "+---------------------------------------------------------------------------+"
    echo "Program Start"
    APPS_LOGIN=${1} # Apps Login
    USER_ID=${2} # User ID
    RESP_ID=${5} # Responsiblity ID
    RESP_APPL_ID=${6} # Responsiblity Application ID
    SECURITY_GROUP_ID=${7} # Security Group ID
    DIRECTORY_PATH=${8} # Directory --Attached file locations
    DIRECTORY_NAME=${9} # Directory Name for plsql
    echo "User ID : $USER_ID"
    echo "Responsibility ID : $RESP_ID"
    echo "Responsibilith Application ID : $RESP_APPL_ID"
    echo "Security Goup ID : $SECURITY_GROUP_ID"
    echo "Directory Path : $DIRECTORY_PATH"
    echo "Direcotry Name : $DIRECTORY_NAME"
    echo
    #files direcotry
    cd $DIRECTORY_PATH
    echo Present Working Directory: `pwd`
    echo
    #for all file names
    ALL_FILES=`ls *.pdf`
    for file in $ALL_FILES
    do
         if [ -f $file ]
         then
              #log "Processing $file" # future
              echo Processing: $file
              # Calling the PL/SQL Program
              SQL_PKG_CALL;
              #echo "Retcode : $RETCODE"
              echo "RetMessage : $RETMSG"
         else
              log "Skipped $file: invalid file"
              echo "Skipping current file $file: not a valid file."
         fi
    done
    Thanks
    Sudheer

    Saubhik's provided the solution, but just for fun:
    Test procedure:
    create or replace procedure get_ename
       ( p_empno in emp.empno%type
       , p_ename_out out emp.ename%type )
    is
    begin
       select ename into p_ename_out
       from   emp
       where  empno = p_empno;
    end get_ename;Test data:
    SQL> select empno, ename from emp order by 1;
    EMPNO ENAME
    7369 SMITH
    7499 ALLEN
    7521 WARD
    7566 JONES
    7654 MARTIN
    7698 BLAKE
    7782 CLARK
    7788 SCOTT
    7839 KING
    7844 TURNER
    7876 ADAMS
    7900 JAMES
    7902 FORD
    7934 MILLER
    14 rows selectedTest call from SQL*Plus to show it working:
    SQL> declare
      2     v_ename emp.ename%type;
      3  begin
      4     get_ename(7844,v_ename);
      5     dbms_output.put_line(v_ename);
      6  end;
      7  /
    TURNER
    PL/SQL procedure successfully completed.Demo shellscript (borrowing the function idea from Saubhik):
    #!/bin/ksh
    empno=${1:-NULL}
    exec_sql() {
        sqlplus -s william/w@//vm.starbase.local:1521/eleven <<END_SQL
        spool get_out_value.sh.log
        set serverout on size 2000 feedback off
        declare
           v_name emp.ename%type;
        begin
           get_ename(${empno},v_name);        
           dbms_output.put_line('# ' || v_name);
        end;
        spool off
        exit
    END_SQL
    ename=$(exec_sql ${empno} | awk '/^# / {print $2}')
    print Employee ${empno} = ${ename}Demo:
    /Users/williamr: get_out_value.sh 7844
    Employee 7844 = TURNER
    /Users/williamr: get_out_value.sh    
    Employee NULL =Note this substitutes the word NULL if no empno is passed, and it ignores error output or anything else by only looking for lines beginning '# ' and then taking the following word. Error messages will appear in the logfile. (In this example it probably doesn't need the NULL substitution because a missing parameter would cause a syntax error which the script will handle anyway, but it could be useful in more complex examples.)
    For a production script you should probably use an OS authenticated account so you don't have to deal with password strings.

  • Executing sql from table with in plsql procedure

    I wonder if anyone can help.
    I have a table that stores sql statements. They are actually a set of rules that I want to apply to my application. My intention is to execute the statement in plsql.
    EG a sql statment held in the table might be:
    'select count(id) from item where item_id = ' || constants_pkg.c_test_item || ' and client_id = ' || client_id_in
    I am trying to call this from a plsql procedure, I’ve CUT OUT some of the procedure task_rec.rule holds the statement above. The procedure is failing “invalid SQL statement”, I think the client_id_in may not be evaluating as the variable, passed into the procedure and constants_pkg.c_test_item not being taken from the constants pkg.
    EG.
    PROCEDURE create_additional_info_list(
    client_id_in IN client.id%TYPE,
    IS
    result VARCHAR2(100);
    BEGIN
    EXECUTE IMMEDIATE
    task_rec.rule
    INTO result;
    END;
    If I was to do below the code would work ok. However I require the rule to come from the table.
    EXECUTE IMMEDIATE
    'select count(id) from item where item_id = ' || constants_pkg.c_test_item || ' and client_id = ' || client_id_in
    INTO result;
    Is there anyway constants_pkg.c_test_item and client_id_in can be evaluated as variables?

    Not that I've tried this but, if possible, change the SQL in the table to have bind variable; e.g.,
    'select count(id) from item where item_id = :1 and client_id = :2 ';
    Then in the procedure
    execute immediate task
    INTO result
    USING constants_pkg.c_test_item ,
    client_id_in ;

  • Help Required :Excel Upload Into Oracle Table Using PLSQL Procedure/Package

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    I also Tried to Use This
    But How can i Use SQLLDR Command In Stored Procedure.
    Well IN SQL*PlUS it is successfull but in Stored Procedure /Package ,PL/SQL does not recognise the OS commands.
    So now my Question How can I recognise the SQLLDR Commnad in Stored Procedure.

  • Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
    If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
    If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
    Justin

  • Problem with database adapter on plsql procedure with in/out parameters

    running BPEL 10.1.3.1 and using the database adapter on a plsql procedure with in/out parameters I get errors
    the plsql procedure:
    create or replace procedure proc_with_clob_inout_parameter(
    p_string in varchar2,
    p_clob in out clob)
    is
    begin
    p_clob := p_string;
    end proc_with_clob_inout_parameter;
    In BPEL I call this procedure. When I only assign a value to the p_string parameters (in a BPEL assign) all is well. When I also assign a value to the p_clob parameter the error occurs:
    <part name="summary">
    <summary>
    file:/ora1/app/oracle/as101.3/bpel/domains/digitaaldossier/tmp/.bpel_janb_inout_1.0_f6908ccf864581b7265c362444e88075.tmp/twee.wsdl
    [ twee_ptt::twee(InputParameters,OutputParameters) ] - WSIF JCA Execute of
    operation 'twee' failed due to: Error while trying to prepare and execute
    an API.
    An error occurred while preparing and executing the
    JANB.PROC_WITH_CLOB_PARAMETER2 API. Cause: java.sql.SQLException: Parameter
    Type Conflict [Caused by: Parameter Type Conflict]
    ; nested exception is:
    ORABPEL-11811
    Error while trying to prepare and execute an API.
    An error occurred while preparing and executing the
    JANB.PROC_WITH_CLOB_INOUT_PARAMETER API. Cause: java.sql.SQLException: Parameter
    Type Conflict [Caused by: Parameter Type Conflict]
    Check to ensure that the API is defined in the database and that the
    parameters match the signature of the API. Contact oracle support if error
    is not fixable.
    </summary>
    </part>
    In BPEL 10.1.2.0 this isn't a problem. I tested it against a 10.2.0.1 and a 10.2.0.2 database and in both situations I get the error with BPEL 10.1.3.1 and no error with BPEL 10.1.2.0
    it appears to be a problem in the database adapter...
    anyone with the same problems and/or a solution?

    Not of any use to you, but we had exactly the same problem on Friday when we applied AS 10.1.2.2 Patchset on top of BPEL 10.1.2.0.2.
    The clob in our pl/sql proc wan't declared as in/out but for some reasons JDeveloper had created a clob on the Output Parameter type in the db partner link xsd. I removed this and it worked. This code had been untouched , and working fine, for months.
    I'll be raising an SR today.
    Rob J

  • Help with truncating a table using plsql procedure in different schema

    I have a plsql procedure in schema A that truncates a table that is given in as parameter.
    create or replace procedure truncate_table(schema, table_name)
    EXECUTE IMMEDIATE 'TRUNCATE TABLE '||schema||'.'||table_name;
    end;
    The above procedure has public execute grant.
    I need to truncate a table in schema B. I have a plsql procedure in schema B that calls the truncate_table procedure and passes in the schema B table name.
    Since the table is in schema B, should the delete grant on the table be given to user A or user B to truncate the table in schema B?
    Thanks in advance.

    Procedure created in schema A
    create or replace
    procedure truncate_table(l_schema varchar2, table_name varchar2) authid current_user
    as
    begin
    EXECUTE IMMEDIATE 'TRUNCATE TABLE '||l_schema||'.'||table_name;
    end;from schema B
    grant delete on table1 to Schema_A
    from schema A
    exec truncate_table('Schema_B','Table1');
    Hope this helps.
    Alvinder

  • Calling PLSQL Procedure with CLOB input parameter from JDBC

    Hi..
    I've got a PLSQL procedure with a CLOB object as input parameter:
    function saveProject (xmldoc CLOB) RETURN varchar IS
    I want to call that procedure from my JDBC Application as...
    String data = "..."
    CallableStatement proc = conn.prepareCall
              ("begin ? := saveProject (?); end;");
    neither
    proc.setCharacterStream(2, new StringReader(data, data.length());
    nor
    proc.setString(2, data);
    will work.
    The Application throws java.sql.Exception: ... PLS-00306 wrong
    number or types of arguments in call 'SAVEPROJECT'
    How can I use set setClob method?
    The Problem is: with Oracles CLOB implementation I can't create
    an Instance, and from the CallableStatement a can't get a
    Locator for a CLOB-Object.
    This CLOB stuff makes me really nuts!
    please somebody help me.. thanks
    Alex

    Hi All,
    You can not make it like that.
    You can not make clob as input parameter.
    Do you want an easy way?
    This is the easy way.
    sample:
    function myFunction(S varchar2(40))
    return integer as
    begin
    insert into TableAAA values(S)
    --TableAAA only contains 1 column of clob type
    end;
    This will work the problem with this is the parameter is in
    varchar2 right? so there will be limited length for it.
    You can do this to call that function:
    nyFunction('My String that will be input into clob field');
    There's another slight difficult way, I understand that you have
    installed Oracle client/server in your system, try to look at
    jdbc folder and try to find demo.zip in that folder, you can
    find several ways of doing thing with jdbc.
    Have a nice day,
    Evan

Maybe you are looking for

  • IPhone 3G(S) wont show up in iTunes after installing Snow Leopard

    I just installed Snow Leopard 10.6.3 yesterday and now when I plug in my iPhone 3G(S) it wont launch iTunes and wont show up in iTunes when I open it. It launches and shows up in iPhoto with no problem? Any hints on what to do?

  • SQLException: Transaction is no longer active (status = Committed).

    I am using TopLink 9.0.3 with a set of stateless session beans running in Weblogic 6.1 hitting an Oracle 8.x database. I am using the recommended approach for using the external trancaction controller but I am seeing the following errors when calling

  • Latest Update slows down all activity

    My recent automatic software update included an update to Safari. I can now have favorite sites show on screen among other things. What I really like is that my Safari browser is as slow as any PC product I have used in the past few years. Of course

  • Keynote 6 is down to 3-stars at the Mac App Store

    As of this post, the 1-star reviews of Keynote 6 are approaching the 5-star reviews in quantity at the Mac App Store. The overall average is down to 3-stars. So... progress.

  • Transfering from an IMac 4.1 to new IMac?

    I have an early 2006 intel iMac (4.1) with OSX 10.6.8 and am thinking about buying the newest iMac. I back up my computer with a G-Drive. Will there be an issue transferring the back-up to the new computer? My main concern is iTunes and iPhoto librar