How to execute SQL scripts with MaxDB ..?
Hi all,
i got some clue from another thread and i observed the command is like
sqlcli -d DBNAME -u SQLUSER,SQLPASS -i filename.sql -c <delimiter> is there,
when i use this the only first query is successfully executing,
this might be problem with delimiter.
can any body help how to use delimiter in the script file with an example.
thanks in advance.
--Hari
Hi,
Sample Script
CREATE TABLE city
(zip CHAR (5) KEY CONSTRAINT zip BETWEEN '10000' AND '99999',
name CHAR(20) NOT NULL,
state CHAR(2) NOT NULL)
CREATE TABLE customer
(cno FIXED (4) KEY CONSTRAINT cno BETWEEN 1 AND 9999,
title CHAR (7) CONSTRAINT title IN ('Mr', 'Mrs', 'Company'),
firstname CHAR (10) ,
name CHAR (10) NOT NULL,
zip CHAR (5) CONSTRAINT zip BETWEEN '10000' AND '99999',
address CHAR (25) NOT NULL,
FOREIGN KEY (zip) REFERENCES city ON DELETE RESTRICT)
\dt customer
COMMIT
Regards
Ayyapparaj
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 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". -
Executing sql scripts with command line Sql plus
Hello
Well I will be gradefull if I have an answer to the follow questions
a) How can I connect to a remote XE using sqlplus (command line)?
for example I'm trying to connect like this : sqlplus sys/syspassw@//remoteserver:1521/xe
and I get responce from server that I have to connect as SYSDBA or SYSOPER, so what is the proper syntax in this case?
b) I want to execute a script file with DDL commands from Windows conscole using sqlplus. Inside this script I have the connect command and others. Is there a way to pass the name of script file as parameter to the sqlplus and execute it ? If yes what is the proper syntac from command line of Windows?
Thank youThere are two ways to do that...
Either use the spool command in sqlplus, or on your command line calling sqlplus use a >> to direct the output to a file. Usually the spool is cleaner.
It goes like this:
spool C:\logfile.txt
{sql commands here}
spool off
or
sqlplus /nolog @sqlfile.sql >> C:\logfile.txt
The output will be formatted slightly differently, and if you use the DOS method you won't be able to see the output as it's running.
~Jer -
How to execute SQL scripts using OWB Process flows ?
Hi,
I have some SQL Scripts. I have to execute them using OWB Process flows.
Can i get any document or link which helps me in achieving this?
Thanks in Advance,
SriGPSutirtha,
Thank you very much. I really appreciate all of your responses.
I have one more question ( Sorry for flooding you with lot of questions :) )
How to capture the errors which occured inside the SQL Scripts.
My scenario is like this. I have two sql scripts Script_1.sql and Script2.sql namely. I would like to put dependency on the execution of the scripts.
If Script_1.sql executes succesfully without any errors, then EXECUTE Script_2.sql
else if Script_1.sql execution contains errors then DON'T EXECUTE Script_2.sql
As of now, i observed that the Process flow shows Success State even if there is an error in the sql script execution. Because of which i was not able to put dependency on the execution of the scripts.
I think i can do it by tweaking(changing) the code inside the SQL Scripts, like logging the errors in some log table and reading it before the next script execution.
But the restriction is, I Should not touch/change the existing SQL Scripts.
Do we have any mechanism in the ProcessFlows to identify the SQL Errors that occurred during execution of SQL Scripts ?
Please suggest any idea on this. It will be great if you can help in this.
Thanks in advance,
SriGP. -
How to execute sql files with windows path ?
Hi , here's my stupid question :
I have my parent SQL script say A.sql in directory C:\program files\my files\A.sql
A.sql has calls to multiple sql files like this
@@1.sql;
@@2.sql;
When I call A.sql using sqlplus as:
sqlplus <username> <connection_string> @"C:\program files\my files\A.sql"
A.sql gets executed but then while calling "1.sql" it fails with the error
SP2-0310: unable to open file "C:\program.sql"
This is happening because of the space, how can this be handled. thx in advance :)
Regards,
Neuronmy A.sql is:
@@1.sql
@@2.sql
1.sql and 2.sql are in the same directory as A.sql.
sqlplus <username> <connection_string> @"C:\program files\my files\A.sql"
VG2,
Yes. Specify the entire path/filename and put double quotes around itA.sql has the double quotes around it, however what additional things can be done so that 1.sql and 2.sql which are present in same directory as A.sql also runs.
Ashish,
Yes the assumption is correct. Although when I cd to this directory then this issue won't come for sure.
But the requirement is you can't 'cd' to the directory and want to execute with complete path.
There is no issues in Solaris as the space is not allowed. -
How to execute SQL scripts in batch
Hi,
I have separate scripts for Creation of Tables, Stored Procedures, Views, Triggers in different .sql files.
I have to execute thses scripts in batch in different servers and different databases without opening SSMS.
All .sql files to be executed in single command.
Please suggest how to achieve?
Appreciate your help.
Regards,
Balayou can use sqlcmd
https://msdn.microsoft.com/en-us/library/ms162773.aspx
other options are osql,isql
https://technet.microsoft.com/en-us/library/aa214012%28v=sql.80%29.aspx
https://technet.microsoft.com/en-us/library/aa214007%28v=sql.80%29.aspx
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
How to execute vb script with out using Remote manager in oim 11g r2
Hi Currently,
i have a requirement to execute vb script (present on a remote machine in which connector server is installed) from oim machine while using Exchange connector (11.1.1.6).
This can be achieved by using remote manager,but i dont want to use remote manager.
Hence decided to use Action scripts.
As per connector configuration,
i have configured Action scripts in Lookup.Exchange.UM.Configuration lookup definition, by means of three entries
After Create Action Language Shell
After Create Action Target Resource
After Create Action File /home/scripts/Disable.bat
Disable.bat has the following ,
Powershell.exe -File C:\scripts\Setup.vbs
-%Log on Name%
Exit
As Setup.vbs is expecting a parameter of log on name, i was providing the same.
But while creating the user,as this script gets called, getting the following error and hence 'create User' is getting failed.
Problem while PowerShell execution System.Management.Automation.RemoteException: This task does not support recipients of this type. The specified recipient XXXXXXXXXXX...XXXXX is of type UserMailbox. Please make sure that this recipient matches the required recipient type for this task.
While provisioning the user to Exchange , i have selected 'Recepient type' as 'User Mail box' explicitly, but still getting the error.
Please provide any pointers to resolve the issue.
Thanks in advance
KumarAs far as I know Oracle and MySQL are two different products.
Why do you clutter an Oracle forum with MySQL questions?
If MySQL is such a tremendous RDBMS, like many people state (as 'free' means per definition better),
why don't you visit a MySQL forum where fellow MySQL aficionados can answer you MySQL questions?
In short, why don't you stop abusing Oracle forums?
Sybrand Bakker
Senior Oracle DBA -
How to execute SQL statement with oracle jdev
Please I'm a beginner in oracle jdeveloper. I want to know how to use and execute sql statememt within oracle Jdeveloper 10 g release 3 to manipulate objects in oracle database. I want for e.g. to Enable/disable trigger using sql statement "ALTER TRIGGER trigername DISABLE" explicitly. Please tell me how to proceed.
i am sure you can help me
Sincerly yours.Hi,
Using following tutorial http://www.oracle.com/technology/obe/ADF_tutorial_1013/10131/index.htm
you will found how to connect from Jdev to a database (chapter 1 or 2 ?). Then you just have to go under Tool>SQL*Plus or Tools>SQL Worksheet depending on what you need.
Luck,
Tif -
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
dlugasxuser10064952 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. -
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 execute sql-queries through shell scripting in linux?
How to execute sql-queries through shell scripting in linux?
http://www.oracle.com/technology/pub/articles/saternos_scripting.html
Two simple examples:
#!/usr/bin/env bash
set_orafra () {
orafra=`echo 'set heading off
select name from v$recovery_file_dest;
exit' | sqlplus -s / as sysdba`
set_orafra
echo $orafra
#!/usr/bin/env bash
export ORACLE_SID=instance_name
export ORACLE_HOME=/path_to_oracle_home_directory
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=/$ORACLE_HOME/bin/$PATH
$ORACLE_HOME/bin/sqlplus -s <<EOF
connect scott/tiger@my_instance_name
INSERT INTO table VALUES (sysdate);
exit
EOFEdited by: Markus Waldorf on Sep 17, 2010 12:19 AM -
Execute SQL Task with Parameter - from DB2 to SQL Server
I am pulling data from DB2 to SQL Server.
1st Execute SQL task runs the following against DB2:
SELECT TIMESTAMP(CHAR(CURRENT_DATE - (DAY(CURRENT_DATE)-1) DAYS - 1 MONTH)) as START_MONTH
FROM SYSIBM.SYSDUMMY1;
I'm storing it as a Result Set.
Next I have a Data Flow Task. This pulls data from DB2 where the date matches the parameter.
FROM SCHEMA.TABLE t
WHERE DATE_TIME_COLUMN= ?
This works fine. Guessing, because the parameter source is DB2 and the Data Flow source is DB2.
The problem is, I want to remove existing data for the same date in the SQL table. IE, if I'm pulling March 2014 data from DB2, I want to be sure there is no March 2014 data in the SQL table. The main use is for re-runs.
So, I added another Execute SQL task after the first one that assigns the variable, and before the Data Flow Task. This runs the following statement against SQL Server:
DELETE FROM
database.dbo.table
WHERE DATE_TIME_FIELD >= ?
The package fails at the new Execute SQL Task with the following error message:
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "DELETE FROM
SBO.dbo.tblHE_MSP_FEE_BUCKETS
WHERE T..." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
correctly.
Task failed: Execute SQL Task
SSIS package "Load_MSP_Fee_Buckets_SQL.dtsx" finished: Success.
The program '[14240] Load_MSP_Fee_Buckets_SQL.dtsx: DTS' has exited with code 0 (0x0).
I am assuming this is something to do with the Parameter source being DB2, and trying to use against SQL?
Any suggestions on how to make this work??
Thanks,
-Al HParameter name is unrecognized
is the key, how come DB2 is related if it runs against SQL Server
What I think is happening you do not use the OLEDB connection to SQL Server.
Likewise, if it is ADO then the query needs to be
DELETE FROM
database.dbo.table
WHERE DATE_TIME_FIELD >= @MyDate
Arthur My Blog -
Hi,
How to Validate SQL scripts?
I am having set of sql files i wish to run one by one if there is any error at one file i need to notify to the user.I have created Bat file in-order to execute in a sequence.how to validate in bat file
say
01.sql ---Sucess
02.sql --- Fail -- intimate and not to execute rest of sql files
03.sql
04.sql
Thanks!933663 wrote:
I am going to create the database
cloneDBCreation.sql
CloneRmanRestore.sql
init.ora
initEDIDBTemp.ora
lockAccount.sql
postDBCreation.sql
postScripts.sql
rmanRestoreDatafiles.sql
dbname.bat
dbname.sqlSo i need to validate each and every .sql whether it succeed or not. if there is failure then needs to notify the user. Use the SQL*Plus macro/command, WHENEVER SQLERROR EXIT <n>, to terminate a sql script when it hits an error - and have it return a specific exit code to the caller (o/s command line in this case). Note that exit codes are typically defined as a single byte in shells - which means it can only returns 0 to 255.
In the command line shell, check the exit code of the previous command - which would be command than ran sqlplus and the sql script. If the exit code is for example 255, then you know the WHENEVER SQLERROR command was executed. And then you cease processing sql scripts.
Simplistically (I do not do Windows), it will look as follows:
--// sql script
whenever sqlerror exit 255
... rest of the script
@echo off
rem command shell script
prompt executing script 1
sqlplus -s /nolog @sqlscript1.sql
if ERRORLEVEL 255 goto :ScriptFailed
prompt executing script 2
sqlplus -s /nolog @sqlscript2.sql
if ERRORLEVEL 255 goto :ScriptFailed
goto :Success
:ScriptFailed
echo ...
goto :End
:Sucess
echo ..
goto :End
:End -
Hi All,
I am very new user of Oracle JDeveloper and BPEL. I am trying to develop a process flow in JDeveloper using BPEL and get stuck when I was trying to execute a SQL quiry in the flow.
How to execute SQL quiries using JDeveloper and BPEL?????????????
Possibilities might be..
1.Configring Database Adapter
2.Using Java Embedded activities of BPEL
However, any of the above mentioned way is not clear with me how to implement it to get the query run in the process flow.
It will be great if anyone could help me with this concept....
Thanks in advance
-Prabha
Edited by: user10259700 on Sep 15, 2008 3:48 AMHi,
though BPEL has its development environment in JDeveloper, it has its own forum
BPEL
Frank
Maybe you are looking for
-
How to invoke secure web service from BPEL in SOA 11g
In SOA 11g I have a simple bpel process in which I am invoking a secured webservice as partnerlink. The webservice which is used in bpel process is deployed in weblogic and the SSL port is enabled on weblogic server. The wsdl url starts with "https:\
-
HU create and attache to Inbound delivery through z programm
Hello, I am trying to create Handling units from a excel file (article and quantity) and then to assign HU to Inbound delivery (inbound delivery is created for purchase order),HU's are getting created by BAPI_HU_CREATE but how to attache HU to inboun
-
Problem Macbook Retina (13"): Battery shows 100%
I have a Macbook Pro Retina 13" (10.8.5), I've bought it about a year ago. Yesterday I was using my Macbook (Word, Safari), without a charger, and everything was pretty normal. When I started my Macbook this morning, I noticed something strange. The
-
Publishing Reports Sets in ADI
We have traditionally relied for ADI to help us distribute monthly financial reports, i.e. spreadsheets to the company intranet site. Unfortunately the process crashes at about 20% of Excel output, i.e. Excel cannot complete this task with available
-
How to Switch Desktop with fadein(fadeout) effect
I create a desktop and the call SwitchDesktop to show the new desktop that i created.But i want the old desktop fades out and the new one fades in.or slide in(out).i can't endure the effect of blink.thank you!