Executing sql script from file, with multiple queries

Hello,
I am trying to load an SQL script from a file, parse the script into separate SQL statements, and execute each of them. The final statement will always be a query, and thus will return a result.
Three problems arise:
1. I don't know what TYPE of statement each one is (i.e. whether it is an UPDATE or a QUERY), which seems to be required in order to execute it in java (via executeQuery and executeUpdate).
2. I am not sure of the best way to execute a series of statements (the Statement object has some "batch" functionality, but I'm not sure if there is a better way, or even of the proper way to use this).
3. I need to be able to make sure the final statement is a QUERY, and thus will return a ResultSet. Otherwise I need to be able to throw an exception.
This has been causing me a lot of trouble. Any help would be much appreciated.
Thanks,
Kevin

Hi Kevin,
Have you got any solution for your mentioned problem????
I am facing almost the same kind of problem like I have some sql files containg simple sql statements as well as code for writting Procs , triggeres, index...functions..and so on. I need to execute this XYZ.sql file from Java side.
Can you guide me about my problem?????
Thanks in advance.............
Mak

Similar Messages

  • How to execute sql scripts from Powershell across multiple databases

    Re: How to execute sql scripts from Powershell across multiple databases
    I have an tsql script that I want to run across a list of databases. How is the best way to do this in Powershell? Thanks.

    My example below, using just the SMO and not breaking up the batches, the ExecuteWithResults give the following error when the .sql file contains a GO. My script files are as simple as a DECLARE and then a GO.
    WARNING: SQL Script Failed
    The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or not in the correct sequence. This is likely caused by a user-specified "format-list" comm
    and which is conflicting with the default formatting.
        + CategoryInfo          : InvalidData: (:) [out-lineoutput], InvalidOperationException
        + FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
    Also, when executing from the ISE, is there a way to force the ISE to release the files. I am having to close the ISE and reopen my script every time I want to make a testing change to the .sql file.
    [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
    $scriptspath = "C:\temp\psExecuteSQLScripts\scripts"
    $SQLServer = "fidevc10"
    $SQLDB = "Bank03"
    # Create SMO Server Object
    $Server = New-Object ('Microsoft.SQLServer.Management.Smo.Server') $SQLServer
    # Get SMO DB Object
    $db = $Server.Databases[$SQLDB]
    # Load All SQL Scripts in Directory
    $scripts = Get-ChildItem -Path (Join-Path $scriptspath "*") -Include "*.sql" -Recurse
    # Loop through each script and execute
    foreach ($SQLScript in $scripts)
    $fullpath = $SQLScript.FullName
    # Read the Script File into Powershell Memory
    $reader = New-Object System.IO.StreamReader($fullpath)
    $script = $reader.ReadToEnd()
    # Execute SQL
    Write-Host "Executing $SQLScript on $SQLDB...."
    try
    $ds = $db.ExecuteWithResults($script)
    Foreach ($t in $ds.Tables)
    Foreach ($r in $t.Rows)
    Foreach ($c in $t.Columns)
    Write-Host $c.ColumnName "=" $r.Item($c)
    Write-Host "Complete"
    catch [Exception]
    Write-Warning "SQL Script Failed"
    echo $_.Exception|format-list -force
    Write-Host " " -BackgroundColor DarkCyan

  • How to execute sql script from linux command line

    Hello everyone !
    Just short question. On my server I must install script in crontab which will eexecute some sql statements.
    How can I write command which will execute script from file without asking about password ?
    sqlplus user/pass ... and then what ?
    thanks
    dlugasx

    user10064952 wrote:
    Just short question. On my server I must install script in crontab which will eexecute some sql statements.
    How can I write command which will execute script from file without asking about password ?Crontab does not run your local shell profile - which means no valid Oracle environment for SQL*Plus to execute in.
    On newer cron versions, you can add an environment to the crontab file itself that needs to be set before executing the scheduled command.
    Whatever method - make sure you have ORACLE_HOME set, that the path includes ORACLE_HOME/bin, that ORACLE_SID is set (if not using a TNS alias) and so on.
    But I agree with Sybrand... crontab is not the best place for running SQL or PL/SQL code. That should reside in the database as named code (e.g. stored procs) and be executed via DBMS_JOB or DBMS_SCHEDULE.
    Less moving parts that way. No external dependancies. And will work on any Oracle server, irrespective of the o/s used and whether or not the relevant o/s user has batch/cron/etc privs to do the deed.

  • Executing sql scripts from url

    A nice feature of isqlplus was that we could execute a sql script stored on a
    server from a browser on a client, using dynamic. Is ther any comparable
    facility in APEX for executing a sql script from a browser?

    Hi!
    Here are some other threads to look at. Make sure to also look at the blog at the bottom of the 2nd thread. In the forum search set the date range to "all" and search on "run_cmd". You might have to look thru a few pages but there are several threads.
    How to execute sqlplus command in html_db
    Re: Returning dbms_output.putline type output to apex page
    Re: RUN A DOS BATCH FILE FROM PLSQL...
    Also go to ASKTOM (Tom Kyte) and search on "run_cmd":
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3361193268672
    This will give you several ideas!
    Let us know if you can't get it working.
    Dave Venus

  • Execute .sql scripts from a remote login

    Hello,
    1) How do I execute a remote sql script from sqlplus?
    SQL>@remote_server:$HOME/test_sql.sql ...this did not work, which would work?
    2) Another question, in sqlplus I can do...! echo testing123>$HOME/test123.txt.
    How do I do this within a store procedure?
    This does not work, which would work?
    declare
    v_test varchar2(300) := '! echo testing123>$HOME/test123.txt';
    begin
    execute immediate v_test;
    end;
    /

    Re Q2.
    I take it that's an sqlplus feature on unix as it doesn't work on windows:
    SQL> ! echo testing123>$HOME/test123.txt
    SP2-0734: unknown command beginning "! echo tes..." - rest of line ignored.
    SQL>Also the reason this isn't working from within PL/SQL is that the execute immediate statement is used to send SQL statements to the SQL engine. What you are attempting to do is to send sqlplus commands to the SQL engine which obviously knows nothing about sqlplus commands. Those commands are very specific to the sqlplus executable and will only work in that environment.
    ;)

  • File Ownership while executing sql script from stored procedure

    We have a test_command.sql script which is spooling the result into a file. From database we have one Store Procedure(run_sql) which is
    calling and executing the .sql script.
    When we are calling the sql script directly from the database, i e SQL > @/dccops/test_command.sql it is creating the
    file under the Ownership of OS user which is connected to the system.
    The problem we are facing is when we are executing the stored procedure i e exec run_sql(), the file is creating under
    Oracle User.
    Could u please suggest me a solution inorder to create the output file under the user who is logged to the OS.

    First of all, your usage of IM speak is NOT appreciated. Please do not address anyone as if they were a 12-year old.
    'Our Applcation is in C. So we have to call the procedure to run the sql script.'
    This is just utter nonsense!
    Oracle has Pro*C which allows Embedded SQL in C. There is also OCI (Oracle Call Interface) to call Oracle directly in C, and there is OCCI, to do the same in C++.
    Apart from that, Oracle has Ole DB for Windows platforms, to allow for a .NET compatible interface to Oracle.
    There is NO NEED AT ALL to call PL/SQL to run a SQL script.
    Sybrand Bakker
    Senior Oracle DBA

  • Execute sql script from apex

    hi all
    i have dir /usr/tmp which there i have script in sql that creats a report
    in the command line i'm running the script like this :
    sqlplus user/passwd@db @name_of_script
    my goal is to run this script thru the apex
    i tried to create some process
    before header like this
    :p116 := sqlplus user/passwd@db @/usr/tmp/name_of_script ;
    doesn't work!!
    i even try to put this action in table but then i don't know how to run this ?
    can it executed in apex ? if yes then how ?
    thanks a lot

    I checked the link and it did not work, so I am reposting my original reply below.
    had a requirement to run a Fortran program against some data that woudl be extracted from the database after the user set up their filtering criteria and made some additional input. SInce the program was to complex to conver to PL/SQL, we decided to try and invoke it from Apex. This is how I did it.
    1. I followed the steps in Tim Archer's excellent article "Oracle External Procedure to Run Host Commands" (http://www.timarcher.com/?q=node/9). If the link does nto work, google the article's title.
    Using this steps I created a function which accepts any OS command, including calling my own shell scripts, and runs them. I called my PL/SQL function "shell" instead of "USF_RUN_HOST_CMD " as Tim did in his example (step 9).
    2. In Apex,
    a. I created a button to run my shell command. (I named it P2_RUN_SHELL)
    b. I created a PL/SQL process whose source looks as follows:
    shell('/home/ackness/scripts/cr_xcf_file.sh > /tmp/cr_scfp_file.log');
    and which was conditioned on the the button P2_RUN_SHELL.
    It works like a charm.
    Note: since you can run your own scripts using this method, you can encapsulate a series of commands in a UNIX shell script and invoke that script from Apex. This allows you to be able to test or run you commands from the command line as well as Apex and makes it easier to develop/debug/enhance the scripts in the future.
    Ackness

  • Executing sql scripts from command line

    Hi!
    We setted the environment and navigated to the directory where the scripts are, but the instance is idle.
    [oracle@at1srv0080 preparation]$ export ORACLE_SID=OMDEMO01
    [oracle@at1srv0080 preparation]$ sqlplus / as sysdba
    SQL*Plus: Release 10.2.0.5.0 - Production on Tue Feb 28 10:07:13 2012
    Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
    Connected to an idle instance.and a startup resulted in:
    Error 6 initializing SQL*Plus
    Message file sp1<lang>.msb not found
    SP2-0750: You may need to set ORACLE_HOME to your Oracle software directoryWhat could the cause be?
    Thanks!

    It is a new and clean installation of a RAC database and we already created some tablespaces.
    Here is the environment:
    _=/bin/env
    CVS_RSH=ssh
    DISPLAY=localhost:10.0
    G_BROKEN_FILENAMES=1
    HISTSIZE=1000
    HOME=/home/oracle
    HOSTNAME=at1srv0080.xxx.net
    INPUTRC=/etc/inputrc
    LANG=en_US.UTF-8
    LD_LIBRARY_PATH=oracle/app/oracle/product/10.2.0/db_1/lib
    LESSOPEN=|/usr/bin/lesspipe.sh %s
    LOGNAME=oracle
    LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
    MAIL=/var/spool/mail/oracle
    OLDPWD=/tmp/OMCore
    ORACLE_BASE=/oracle/app/oracle
    ORACLE_HOME=oracle/app/oracle/product/10.2.0/db_1
    ORACLE_SID=OMDEMO01
    PATH=/oracle/app/oracle/product/10.2.0/db_1/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin
    PWD=/tmp/OMCore/preparation
    SHELL=/bin/bash
    SHLVL=1
    SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
    TERM=xterm
    USER=oracle

  • Export scheduler job but chain step and chain rule failed with ORA-24150 ORA-06512 during executed sql script.

    Hi Folks,
    I used expdp utility to export all Oracle scheduler jobs and chains with below method, after that generate sql script by impdp, later on executing sql script encountered some errors.
    Only chain step and chain rule for executing script. Does anyone bright me some light? Thanks!
    My env: Oracle 11g + Oracle Linux 5.5
    My steps as below:
    1. export(expdp) oracle scheduler job(chain)
    2. generate sql script by impdp.
    3. remove orginal scheduler job(chain)
    4. execute sql script
    5. job with no chain well but job with chain failed
    [oracle@linux1 ~]$ expdp scott/tiger directory=db_dump_dir dumpfile=scott_job.dmp include=procobj:\" in \(select \
    > name from sys.obj$ where type\# in \(46,59,66,67,68,69,72,74,79\)\)\"  schemas=scott
    Export: Release 11.2.0.1.0 - Production on Tue Dec 3 17:42:31 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, Real Application Clusters, OLAP, Data Mining
    and Real Application Testing options
    Starting "SCOTT"."SYS_EXPORT_SCHEMA_01":  scott/******** directory=db_dump_dir dumpfile=scott_job.dmp include=procobj:" in (select name from sys.obj$ where type# in (46,59,66,67,68,69,72,74,79))" schemas=scott
    Estimate in progress using BLOCKS method...
    Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
    Total estimation using BLOCKS method: 0 KB
    Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCOBJ
    Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
    Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
      /u03/database/usbo/BNR/dump/scott_job.dmp
    Job "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully completed at 17:42:54
    [oracle@linux1 ~]$ impdp scott/tiger sqlfile=scott_job.sql directory=db_dump_dir dumpfile=scott_job.dmp logfile=imp_scott_job.log
    Import: Release 11.2.0.1.0 - Production on Tue Dec 3 17:43:04 2013
    Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, Real Application Clusters, OLAP, Data Mining
    and Real Application Testing options
    Master table "SCOTT"."SYS_SQL_FILE_FULL_01" successfully loaded/unloaded
    Starting "SCOTT"."SYS_SQL_FILE_FULL_01":  scott/******** sqlfile=scott_job.sql directory=db_dump_dir dumpfile=scott_job.dmp logfile=imp_scott_job.log
    Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCOBJ
    Job "SCOTT"."SYS_SQL_FILE_FULL_01" successfully completed at 17:43:07
    [oracle@linux1 ~]$ more /u03/database/usbo/BNR/dump/scott_job.
    scott_job.dmp  scott_job.sql 
    [oracle@linux1 ~]$ more /u03/database/usbo/BNR/dump/scott_job.sql
    -- CONNECT SCOTT
    ALTER SESSION SET EVENTS '10150 TRACE NAME CONTEXT FOREVER, LEVEL 1';
    ALTER SESSION SET EVENTS '10904 TRACE NAME CONTEXT FOREVER, LEVEL 1';
    ALTER SESSION SET EVENTS '25475 TRACE NAME CONTEXT FOREVER, LEVEL 1';
    ALTER SESSION SET EVENTS '10407 TRACE NAME CONTEXT FOREVER, LEVEL 1';
    ALTER SESSION SET EVENTS '10851 TRACE NAME CONTEXT FOREVER, LEVEL 1';
    ALTER SESSION SET EVENTS '22830 TRACE NAME CONTEXT FOREVER, LEVEL 192 ';
    -- new object type path: SCHEMA_EXPORT/POST_SCHEMA/PROCOBJ
    BEGIN
    BEGIN
    dbms_rule_imp_obj.import_rule('"SCOTT"','"CHAIN_RULE_1"','1=1',NULL, 'First link in the chain.',0,NULL);
    END;
    COMMIT;
    END;
    BEGIN
    BEGIN
    dbms_rule_imp_obj.import_rule('"SCOTT"','"CHAIN_RULE_2"',':"CHAIN_STEP_1".COMPLETED = ''TRUE''',NULL, 'Second link in the chain.',0,NULL);
    END;
    COMMIT;
    END;
    BEGIN
    BEGIN
    dbms_rule_imp_obj.import_rule('"SCOTT"','"CHAIN_RULE_3"',':"CHAIN_STEP_2".COMPLETED = ''TRUE''',NULL, 'Third link in the chain.',0,NULL);
    END;
    COMMIT;
    END;
    BEGIN
    BEGIN
    dbms_rule_imp_obj.import_rule('"SCOTT"','"CHAIN_RULE_4"',':"CHAIN_STEP_3".COMPLETED = ''TRUE''',NULL, 'End of the chain.',0,NULL);
    END;
    COMMIT;
    END;
    BEGIN
    BEGIN
    dbms_rule_imp_obj.import_rule_set('"SCHED_RULESET$1"','"SCHED_EV_CTX$1"',NULL, 0);
    END;
    COMMIT;
    END;
    BEGIN
    dbms_scheduler.create_program('"TEST_PROC_1"','PLSQL_BLOCK',
    'BEGIN
                             INSERT INTO tb_schduler (id, descr, cr_date)
                             VALUES (tb_schduler_seq.NEXTVAL, ''test_proc_1'', SYSDATE);
                             COMMIT;
                           END;'
    ,0, TRUE,
    'Program for first link in the chain.'
    COMMIT;
    END;
    BEGIN
    dbms_scheduler.create_program('"TEST_PROC_3"','PLSQL_BLOCK',
    'BEGIN
                             INSERT INTO tb_schduler (id, descr, cr_date)
                             VALUES (tb_schduler_seq.NEXTVAL, ''test_proc_3'', SYSDATE);
                             COMMIT;
                           END;'
    ,0, TRUE,
    'Program for last link in the chain.'
    COMMIT;
    END;
    BEGIN
    dbms_scheduler.create_program('"TEST_PROC_2"','PLSQL_BLOCK',
    'BEGIN
                             INSERT INTO tb_schduler (id, descr, cr_date)
                             VALUES (tb_schduler_seq.NEXTVAL, ''test_proc_2'', SYSDATE);
                             COMMIT;
                           END;'
    ,0, TRUE,
    'Program for second link in the chain.'
    COMMIT;
    END;
    BEGIN
    dbms_scheduler.create_chain('"TEST_CHAIN_1"', evaluation_interval=>NULL, comments=>'A test chain.'
    , rule_set_name=>'"SCHED_RULESET$1"   '
    dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_1"', program_name=>'"TEST_PROC_1"');
    dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_2"', program_name=>'"TEST_PROC_2"');
    dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_3"', program_name=>'"TEST_PROC_3"');
    COMMIT;
    END;
    BEGIN
    dbms_scheduler.create_job('"TEST_CHAIN_1_JOB"',
    job_type=>'CHAIN', job_action=>
    'test_chain_1'
    , number_of_arguments=>0,
    start_date=>TO_TIMESTAMP_TZ('03-DEC-2013 05.38.56.718161000 PM +08:00','DD-MON-RRRR HH.MI.SSXFF AM TZR','NLS_DATE_LANGUAGE=english'), repeat_interval=>
    'freq=minutely; interval=2'
    , end_date=>TO_TIMESTAMP_TZ('03-DEC-2013 06.08.56.000000000 PM +08:00','DD-MON-RRRR HH.MI.SSXFF AM TZR','NLS_DATE_LANGUAGE=english'),
    job_class=>'"DEFAULT_JOB_CLASS"', enabled=>FALSE, auto_drop=>TRUE,comments=>
    NULL
    COMMIT;
    END;
    [oracle@linux1 ~]$ export ORACLE_SID=usbo
    [oracle@linux1 ~]$ sqlplus / as sysdba
    SQL*Plus: Release 11.2.0.1.0 Production on Tue Dec 3 17:44:43 2013
    Copyright (c) 1982, 2009, Oracle.  All rights reserved.
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    With the Partitioning, Real Application Clusters, OLAP, Data Mining
    and Real Application Testing options
    sys@USBO> show parameter db_name
    NAME                                 TYPE                              VALUE
    db_name                              string                            usbo
    sys@USBO> conn scott/tiger;
    Connected.
    --remove job and chain.
    scott@USBO> EXEC DBMS_SCHEDULER.drop_job(job_name => 'test_chain_1_job');
    EXEC DBMS_SCHEDULER.drop_chain (chain_name  => 'test_chain_1');
    EXEC DBMS_SCHEDULER.drop_program (program_name  => 'test_proc_1');
    EXEC DBMS_SCHEDULER.drop_program (program_name  => 'test_proc_2');
    EXEC DBMS_SCHEDULER.drop_program (program_name  => 'test_proc_3');
    PL/SQL procedure successfully completed.
    scott@USBO> @/u03/database/usbo/BNR/dump/scott_job.sql
    Session altered.
    Session altered.
    Session altered.
    Session altered.
    Session altered.
    Session altered.
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    BEGIN
    ERROR at line 1:
    ORA-24150: evaluation context SCOTT.SCHED_EV_CTX$1 does not exist
    ORA-06512: at "SYS.DBMS_RULEADM_INTERNAL", line 28
    ORA-06512: at "SYS.DBMS_RULE_IMP_OBJ", line 40
    ORA-06512: at line 3
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    PL/SQL procedure successfully completed.
    BEGIN
    ERROR at line 1:
    ORA-24141: rule set SCOTT.SCHED_RULESET$1 does not exist
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
    ORA-06512: at "SYS.DBMS_ISCHED", line 1694
    ORA-01403: no data found
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1638
    ORA-06512: at line 5
    PL/SQL procedure successfully completed.

    Thanks all of you!
    Hi DK2010,
    I took some test that the data dict(dba_rule_sets/dba_evaluation_contexts) no any data returned after I had removed the job.
    So I tried to create evaluation context and re-executed script(only exception setion.) the first error has gone. For the second still have some issue.
    ---->no any returned
    scott@USBO> select * from dba_rule_sets where rule_set_owner='SCOTT';       
    no rows selected
    scott@USBO> select * from dba_evaluation_contexts WHERE evaluation_context_owner='SCOTT';
    no rows selected
    -->add new EVALUATION CONTEXT
    scott@USBO> exec DBMS_RULE_ADM.CREATE_EVALUATION_CONTEXT('SCOTT.SCHED_EV_CTX$1');
    PL/SQL procedure successfully completed.
    --->now it looks fine
    scott@USBO> BEGIN
      2  BEGIN
      3  dbms_rule_imp_obj.import_rule_set('"SCHED_RULESET$1"','"SCHED_EV_CTX$1"',NULL, 0);
      4  END;
      5 
      6  COMMIT;
      7  END;
      8  /
    PL/SQL procedure successfully completed.
    --->add new rule set, it prompt aleady exists
    scott@USBO> exec DBMS_RULE_ADM.CREATE_RULE_SET('SCOTT.SCHED_RULESET$1') 
    BEGIN DBMS_RULE_ADM.CREATE_RULE_SET('SCOTT.SCHED_RULESET$1'); END;
    ERROR at line 1:
    ORA-24153: rule set SCOTT.SCHED_RULESET$1 already exists
    ORA-06512: at "SYS.DBMS_RULEADM_INTERNAL", line 28
    ORA-06512: at "SYS.DBMS_RULE_ADM", line 138
    ORA-06512: at line 1
    -->chain rule still could not find.
    scott@USBO> @job_chain_rules.sql
    no rows selected
    -->rerun
    scott@USBO> BEGIN
      2  dbms_scheduler.create_chain('"TEST_CHAIN_1"', evaluation_interval=>NULL, comments=>'A test chain.'
      3  , rule_set_name=>'"SCHED_RULESET$1"   '
      4  );
      5  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_1"', program_name=>'"TEST_PROC_1"');
      6  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_2"', program_name=>'"TEST_PROC_2"');
      7  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_3"', program_name=>'"TEST_PROC_3"');
      8  COMMIT;
      9  END;
    10  /
    BEGIN
    ERROR at line 1:
    ORA-27477: "SCOTT.TEST_CHAIN_1" already exists 
    ORA-06512: at "SYS.DBMS_ISCHED", line 1148
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1598
    ORA-06512: at line 2
    -->drop chain
    scott@USBO> exec dbms_scheduler.drop_chain('TEST_CHAIN_1');
    BEGIN dbms_scheduler.drop_chain('TEST_CHAIN_1'); END;
    ERROR at line 1:
    ORA-27479: Cannot drop "SCOTT.TEST_CHAIN_1" because other objects depend on it
    ORA-06512: at "SYS.DBMS_ISCHED", line 1319
    ORA-06512: at "SYS.DBMS_ISCHED", line 1222
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1854
    ORA-06512: at line 1
    scott@USBO> exec dbms_scheduler.drop_chain('TEST_CHAIN_1',force=>TRUE);
    PL/SQL procedure successfully completed.
    scott@USBO> BEGIN
      2  dbms_scheduler.create_chain('"TEST_CHAIN_1"', evaluation_interval=>NULL, comments=>'A test chain.'
      3  , rule_set_name=>'"SCHED_RULESET$1"   '
      4  );
      5  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_1"', program_name=>'"TEST_PROC_1"');
      6  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_2"', program_name=>'"TEST_PROC_2"');
      7  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_3"', program_name=>'"TEST_PROC_3"');
      8  COMMIT;
      9  END;
    10  /
    BEGIN
    ERROR at line 1:
    ORA-24141: rule set SCOTT.SCHED_RULESET$1 does not exist   --->still returned no rule set
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
    ORA-06512: at "SYS.DBMS_ISCHED", line 1694
    ORA-01403: no data found
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1638
    ORA-06512: at line 5
    scott@USBO> exec DBMS_RULE_ADM.CREATE_RULE_SET('SCOTT.SCHED_RULESET$1')
    PL/SQL procedure successfully completed.
    scott@USBO> BEGIN
      2  dbms_scheduler.create_chain('"TEST_CHAIN_1"', evaluation_interval=>NULL, comments=>'A test chain.'
      3  , rule_set_name=>'"SCHED_RULESET$1"   '
      4  );
      5  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_1"', program_name=>'"TEST_PROC_1"');
      6  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_2"', program_name=>'"TEST_PROC_2"');
      7  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_3"', program_name=>'"TEST_PROC_3"');
      8  COMMIT;
      9  END;
    10  /
    BEGIN
    ERROR at line 1:
    ORA-27477: "SCOTT.TEST_CHAIN_1" already exists
    ORA-06512: at "SYS.DBMS_ISCHED", line 1148
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1598
    ORA-06512: at line 2
    scott@USBO> exec dbms_scheduler.drop_chain('TEST_CHAIN_1',force=>TRUE);
    PL/SQL procedure successfully completed.
    scott@USBO> BEGIN
      2  dbms_scheduler.create_chain('"TEST_CHAIN_1"', evaluation_interval=>NULL, comments=>'A test chain.'
      3  , rule_set_name=>'"SCHED_RULESET$1"   '
      4  );
      5  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_1"', program_name=>'"TEST_PROC_1"');
      6  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_2"', program_name=>'"TEST_PROC_2"');
      7  dbms_scheduler.define_chain_step('"TEST_CHAIN_1"', step_name=>'"CHAIN_STEP_3"', program_name=>'"TEST_PROC_3"');
      8  COMMIT;
      9  END;
    10  /
    BEGIN
    ERROR at line 1:
    ORA-24141: rule set SCOTT.SCHED_RULESET$1 does not exist
    ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
    ORA-06512: at "SYS.DBMS_ISCHED", line 1694
    ORA-01403: no data found
    ORA-06512: at "SYS.DBMS_SCHEDULER", line 1638
    ORA-06512: at line 5
    Would you like to give me more clue?
    Thanks again.

  • How to load SQL scripts from a text file.

    Hi, i tried several time to load a text file/SQL script with 10 different tables and data, but 10g Express doesen't allows me to do that, any one can direct me or point out to me what i should do or do i need to adopt any special method to to get this done. i am sure there must be some thing where you can upload SQL scripts from a text file (in SQL command editor!). thanks

    Hi,
    see my other answer here:
    SQL command editor doesn't take more than 1 insert command
    This seems to be a duplicate question, right? Or am I missing something?
    Regards,
    ~Dietmar.

  • Copying SQL Script from Oracle SQL Developer into Excel with formatting

    I need to copy a SQL Script into Excel in order to develop some VBA code. Is there any nice way that I can copy SQL Script from Oracle SQL Developer into Excel and retain its formatting? I am a stickler for having legible, readable SQL and like to have all my columns lined up and aliases lined up. When we used to use SQL Navigator, the tab formatting seemed to copy and paste just fine. Now that we have migrated to Oracle SQL Developer, the formatting seems to get all messed up.
    And suggestions are greatly appreciated and Thanks in advance for your review and am hopeful for an answer.
    Thanks.
    PSULionRP

    I suppose you want a real tabulator instead of spaces. You can configure this in the preferences (SQL Formatter - Oracle). You have to apply it then to your existing code (e.g. CTRL-F7), but new code should get it right from the start.
    Hope that helps,
    K.

  • Report with Multiple queries too slow in BI Publisher 11g

    Hi, I have a report in 11g where i need to create multiple queries to show them in report. I tried to combine everything in one query, but i found that the query is too huge and hard to understand and maintain. I created 3 data sets and linked them together. In SQL dev, the main query is returning about 315 records and first detail query returns less than 100 records and second detail query is returning one record which is BLOB. Each query returns data within a couple of seconds from SQL Developer. The entire report from BI Publisher should be just 21 page PDF output. Did anyone face performance issues while running reports with multiple queries in 11g? I ran reports that have single query which returned 10K pages PDF and never had an issue while everthing is in one query. This is the first time Iam attempting to create multiple queries. Can someone help me understand what i might be doing wrong or missing here. Thank you.

    Isn't there a way for you to do this via a Package/Procedure versus having multiple queries?
    Per the BI Publisher guide,
    Following are recommended guidelines for building data models:
    Reduce the number of data sets or queries in your data model as much as possible. In general, the fewer data sets and queries you have, the faster your data model will run. While multiquery data models are often easier to understand, single-query data models tend to execute more quickly. It is important to understand that in parent-child queries, for every parent, the child query is executed.
    You should only use multiquery data models in the following scenarios:
    To perform functions that the query type, such as a SQL query, does not support directly.
    To support complex views (for example, distributed queries or GROUP BY queries).
    To simulate a view when you do not have or want to use a view.
    Thanks,
    Bipuser

  • How to execute SQL Script using windows powershell(using invoke-sqlcmd or any if)

    OS : Windows server 2008
    SQL Server : SQL Server 2012
    Script: Test.sql (T-SQL)  example : "select name from sys.databases"
    Batch script: windows  MyBatchscript.bat ( here connects to sql server using sqlcmd  and output c:\Testput.txt) 
     (sqlcmd.exe -S DBserverName -U username -P p@ssword -i C:\test.sql -o "c:\Testoutput.txt)  ---it working without any issues.....
    This can execute if i double click MyBatchscript.bat file and can see the output in c:\testput.txt.
    Powershell: Similarly, How can i do in powershell 2.0 or higher versions?  can any one give full details with each step?
    I found some of them online, but nowhere seen clear details or examples and it not executing through cmd line (or batch script).
    example: invoke-sqlcmd -Servernameinstance Servername -inputfile "c:\test.sql" | out-File -filepath "c:\psOutput.txt"  --(call this file name MyTest.ps1)
    (The above script working if i run manually. I want to run automatic like double click (or schedule with 3rd party tool/scheduler ) in Batch file and see the output in C drive(c:\psOutput.txt))
    Can anyone Powershell experts give/suggest full details/steps for this. How to proceed? Is there any configurations required to run automatic?
    Thanks in advance.

    Testeted the following code and it's working.....thanks all.
    Execute sql script using invoke-sqlcmd with batch script and without batch script.
    Option1: using Import sqlps
    1.Save sql script as "C:\scripts\Test.sql"  script in side Test.sql: select name from sys.databases
    2.Save Batch script as "C:\scripts\MyTest.bat" Script inside Batch script:
    powershell.exe C:\scripts\mypowershell.ps1
    3.Save powershell script as "C:\scripts\mypowershell.ps1"
    import-module "sqlps" -DisableNameChecking
    invoke-sqlcmd -Servername ServerName -inputFile "C:\scripts\Test.sql" | out-File -filepath "C:\scripts\TestOutput.txt"
    4.Run the Batch script commandline or double click then can able to see the output "C:\scripts\TestOutput.txt" file.
    5.Connect to current scripts location  cd C:\scripts (enter)
    C:\scripts\dir (enter )
    C:\scripts\MyTest.bat (enter)
    Note: can able to see the output in "C:\scripts" location as file name "TestOutput.txt".
    Option2: Otherway, import sqlps and execution
    1.Save sql script as "C:\scripts\Test.sql"  script in side Test.sql: select name from sys.databases
    2.Save powershell script as "C:\scripts\mypowershell.ps1"
    # import-module "sqlps" -DisableNameChecking #...Here it not required.
    invoke-sqlcmd -Servername ServerName -inputFile "C:\scripts\Test.sql" | out-File -filepath "C:\scripts\TestOutput.txt"
    3.Connect to current scripts location
    cd C:\scripts (enter)
    C:\scripts\dir (enter )
    C:\scripts\powershell.exe sqlps C:\scripts\mypowershell.ps1 (enter)
    Note: can able to see the output in "C:\scripts" location as file name "TestOutput.txt".

  • How to call SQL script from PL/SQL block

    Hi All,
    I have a pl/sql block from which i need to call a *.sql script file.
    Please tell me that how can i do this?
    Thanks and Regards.

    > Though just for knowledge sake, would you please tell if there is a way
    to call a sql script from a pl/sql block.
    This question stems usually from a confusion about client-server and which is which in Oracle.
    SQL*Plus is a client. PL/SQL is a server side language. SQL is a server side language.
    When entering either one of these two languages in SQL*Plus (or TOAD, SQL-Developer, etc), the content is shipped to an Oracle server process, is parsed there, and is executed there.
    The Oracle server process servicing the client can accept a single SQL statement or PL/SQL block at a time.
    It cannot accept a block of SQL statements delimited with a semicolon. That is a client concept where the client will read each delimited statement and send that, one after the other (in synchronous call mode) to the Oracle server for execution.
    The Oracle server does not have a "script parser". It understands SQL. It understands PL/SQL. And that is what it expects from the client.
    Whether the client supports the SET command, the HOST command, SPOOL command, ability to run scripts, and so... have no bearing on what the server itself is capable of doing. The server does not care what feature set the client has. It is tasked with servicing the client via SQL and PL/SQL.
    It is not tasked to support or emulate client features like running SQL scripts.
    Nor confuse PL/SQL with the very limited command set of SQL*Plus. The two has nothing in common. And just as PL/SQL cannot understand C# or Delphi commands, it cannot understand SQL*Plus commands.

  • Creating IPA file with Multiple SWF files using ADT

    Iam successfully able to create ipa files using the ADT package but my next requirement is to create an IPA file with multiple swf files.I think it might be easy if your SWF files are regular the tough part is my swf file has lot of action script in it so the only option is to through the command prompt and using the ADT package of Adobe AIR.So now i have 10 SWF files like this and iam creating ipa file for each swf seperatly but now I want to put all of the swf files into one ipa file.Please let me know if i was not clear in my description

    I think you are trying to explain how to load two swf's one with action
    script and loading an other swf file which should be non action script.If
    you read my requirement carefully.I have all the same type of swf's and
    these swf are automatically created as a form of output for xcelsius dash
    board software.Iam capable of creating individialu ipa files from these swf
    files.So when I try to combine the same kind of swf files the first error
    its giving is the file name which I have used in the xml.in the main file
    name for the swf file its not considering the two swf file name in the
    initial window.so the adt package in the command line is not understanding
    the file name from the xml and the command prompt and giving error this swf
    file does not exist.So please consider how to combine two swf files with AS3
    into one ipa file.These swf files are not editable,Let me know if you find
    any idea to achieve this

Maybe you are looking for

  • Purchase order number for each postings with FBL3N

    Hello With tcode FBL3N, I need to get all the postings on expenses accounts. Additionally it is possible to get more information on the postings from the orginal paper invoice. It shall be also more convenient to get the purchase order number walk tr

  • My printer is stating it's off line and won't print, how do i fix this?

    My printer states it's off line ( which I did not request this) now I can't print anything. How do I fix this?

  • [MBA 2013] Choppy Scrolling in Safari and Adobe Reader

    Hey guys just got my baby from the local Apple store a few days ago. This is my first ever Apple product and I am loving it in many ways... except for an issue with scrolling and animations. Despite having installed the latest drivers I am still gett

  • LWAPP Discovery, Microsoft DHCP and failure!

    Fellow Netpro's, Interesting case here maybe, which is buggering me since a couple of days. We have an environment with hundreds of LAPs over multiple sites throughout the globe. We have main controllers in datacenter for remote LAP (H-REAP mode) and

  • How do i get permission to connect to my iphone

    i just got a new macbook air.  i transfered everything from my previous macbook pro.  when i plug in my iphone (4s, v6.1.3), it tells me that i don't have permission to connect to the iphone because it's password protected.  when i put in the passwor