Executing oracle procedure using cronjob
Hi,
Below is the code to execute the procedure "dbms_job.broken" from the shell script.
on executing manually, it works properly without any error.
but it is not working when scheduled using the cronjob.
Code:
#!/usr/bin/bash
user_name="oracdb"
password="ora123"
tns="localdb"
ORACLE_BASE="/oracle"
ORACLE_HOME="/oracle/v9.0.1"
ORACLE_SID="mydb"
PATH="/oracle/v9.0.1/bin:/usr/bin:"
set `sqlplus -s $user_name/$password@$tns<<EOS
exec dbms_job.broken(118,TRUE);
exit;
EOS`
Why the above script is not working when executed using the cronjob ?
Regards
user640001 wrote:
Hi,
under 'root' user
when script executed manually either from 'root' user or 'oracle' user, it is working properly.
It dosent not work properly when we scheduled the same script using the cronjob.
RegardsI don't know if it's the approximate source of your problem, but in any event you should NOT be doing this as root. You should not do any oracle work as root. If you find yourself tempted to use root, ask yourself why. You need to solve the problem instead of just saying "root can do anything so I'll become root."
Similar Messages
-
Execute oracle procedure from SSIS
is it possible to execute Oracle procedure from within SSIS?
thanksHi,
I used
begin
test1;
end;
and it is giving - SSIS package "Package.dtsx" finished: Success, but it is not doing anything.
"test1" procedure has couple of insert statements and a commit statements but the package is not inserting anything.
Also when I use "exec test1;" it is failing with the error mentinoed here in the forum.
Any idea what is wrong here? -
How to get resultset from oracle procedure use ejb3
how to get resultset from oracle procedure use ejb3
i know oracle procedure should like this
Create or replace PROCEDURE resultset_test(
aaa IN NUMBER,
bbb OUT sys_refcursor) ....
but what s the ejb3 scripts looks like? please give me an example or link~
ths- there are no EJB3 scripts, only compiled application code
- the part of the EJB spec that deals with databases is called the Java Persistence API, but likely you are just looking for the JDBC API.
Now you should know what to Google to get your "example script": "java jdbc oracle procedure" -
How to pass a array of object to oracle procedure using callable
Hi,
I am calling a oracle stored procedure using callable statement which has IN and OUT parameter of same type.
IN and OUT are array of objects. (ie) IN parameter as Array of Objects and OUT parameter as Array of Objects
here are the steps i have done as advised from oracle forum. correct me if i am in wrong direction
ORACLE types and Stored Procedure
CREATE OR REPLACE
TYPE APPS.DEPARTMENT_TYPE AS OBJECT (
DNO NUMBER (10),
NAME VARCHAR2 (50),
LOCATION VARCHAR2 (50)
CREATE OR REPLACE
TYPE APPS.DEPT_ARRAY AS TABLE OF department_type;
CREATE OR REPLACE package body APPS.insert_object
IS
PROCEDURE insert_object_prc (d IN dept_array, d2 OUT dept_array)
IS
BEGIN
d2 := dept_array ();
FOR j IN 1 .. d.COUNT
LOOP
d2.EXTEND;
d2 (j) := department_type (d (j).dno, d (j).name, d(j).location);
END LOOP;
END insert_object_prc;
END insert_object;
JAVA CODE
Value Object
package com.custom.vo;
public class Dep {
public int empNo;
public String depName;
public String location;
public int getEmpNo() {
return empNo;
public void setEmpNo(int empNo) {
this.empNo = empNo;
public String getDepName() {
return depName;
public void setDepName(String depName) {
this.depName = depName;
public String getLocation() {
return location;
public void setLocation(String location) {
this.location = location;
to call stored procedure
package com.custom.callable;
import com.custom.vo.Dep;
import oracle.jdbc.OracleCallableStatement;
import oracle.jdbc.OracleConnection;
import oracle.jdbc.OracleTypes;
import oracle.jdbc.pool.OracleDataSource;
import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;
import oracle.sql.Datum;
import oracle.sql.STRUCT;
import oracle.sql.StructDescriptor;
public class CallableArrayTryOut {
private static OracleDataSource odcDataSource = null;
public static void main(String[] args) {
OracleCallableStatement callStatement = null;
OracleConnection connection = null;
try {
odcDataSource = new OracleDataSource();
odcDataSource
.setURL("......");
odcDataSource.setUser("....");
odcDataSource.setPassword("....");
connection = (OracleConnection) odcDataSource.getConnection();
} catch (Exception e) {
System.out.println("DB connection Exception");
e.printStackTrace();
Dep[] dep = new Dep[2];
dep[0] = new Dep();
dep[0].setEmpNo(100);
dep[0].setDepName("aaa");
dep[0].setLocation("xxx");
dep[1] = new Dep();
dep[1].setEmpNo(200);
dep[1].setDepName("bbb");
dep[1].setLocation("yyy");
try {
StructDescriptor structDescriptor = new StructDescriptor(
"APPS.DEPARTMENT_TYPE", connection);
STRUCT priceStruct = new STRUCT(structDescriptor, connection, dep);
STRUCT[] priceArray = { priceStruct };
ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(
"APPS.DEPT_ARRAY", connection);
ARRAY array = new ARRAY(arrayDescriptor, connection, priceArray);
callStatement = (OracleCallableStatement) connection
.prepareCall("{call insert_object.insert_object_prc(?,?)}");
((OracleCallableStatement) callStatement).setArray(1, array);
callStatement.registerOutParameter(2, OracleTypes.ARRAY,
"APPS.DEPT_ARRAY");
callStatement.execute();
ARRAY outArray = callStatement.getARRAY(2);
Datum[] datum = outArray.getOracleArray();
for (int i = 0; i < datum.length; i++) {
oracle.sql.STRUCT os = (oracle.sql.STRUCT) datum[0];
Object[] a = os.getAttributes();
for (int j = 0; j < a.length; j++) {
System.out.print("Java Data Type :"
+ a[j].getClass().getName() + "Value :" + a[j]
+ "\n");
connection.commit();
callStatement.close();
} catch (Exception e) {
System.out.println("Mapping Error");
e.printStackTrace();
THE ERROR
Mapping Errorjava.sql.SQLException: Inconsistent java and sql object types
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1130)
at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:823)
at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:1735)
at oracle.sql.STRUCT.<init>(STRUCT.java:136)
at com.custom.callable.CallableArrayTryOut.main(CallableArrayTryOut.java:48)You posted this question in the wrong forum section. There is one dedicated to Java that was more appropriate.
Anyway here is a link that describes what you should do.
http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/oraarr.htm#i1049179
Bye Alessandro -
Error while Executing stored procedure using ant
Hi,
I am trying to execute a stored procedure using ant ..
My build.xml is like this...
<project name="myproject" default="db.build">
<target name="db.build">
<sql driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@idm.orademo.com:1521:orcl"
userid="test"
password="oracle11g"
print="yes"
classpath="E:\\ojdbc14.jar"
src="E:\\upg_9102BP07.sql" />
<!--
<classpath>
<pathelement path=""\\>
<\\classpath> -->
</target>
</project>
I have my stored procedure in upg_9102BP07.sql as shown in above src..
When im executing ant cmd I got the following exception
E:\>ant -f test.xml
Buildfile: test.xml
db.build:
*[sql] Executing resource: E:\upg_9102BP07.sql*
*[sql] Failed to execute: declare cnt int*
BUILD FAILED
E:\test.xml:12: java.sql.SQLException: ORA-06550: line 1, column 15:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
*:= . ( @ % ; not null range default character*
Total time: 44 seconds
I have no clue.. But this sql ran successfully when did manually..
Please help me in solving the issue...
-- MariasHere is my script bit lengthy...
Rem
Rem $Header: oim/server/Database/Oracle/Upgrade/Release91x/910x/List/9102_ddl_AddcolumnToRCE_Oracle.sql st_oim_devjain_bug-9003841/1 2009/10/09 02:24:19 devjain Exp $
Rem
Rem 9102_ddl_AddcolumnToRCE_Oracle.sql
Rem
Rem Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
Rem
Rem NAME
Rem 9102_ddl_AddcolumnToRCE_Oracle.sql - <one-line expansion of the name>
Rem
Rem DESCRIPTION
Rem Create a new column 'RCE_DELETE' in RCE table
Rem
Rem MODIFIED (MM/DD/YY)
Rem blaksham 09/30/09 - Created
Rem
declare cnt int;
Begin
Select Count(1) into cnt From User_Tab_Columns Where TABLE_NAME='RCM' And COLUMN_NAME='RCM_DELETE';
IF cnt=0 Then
Begin
Execute Immediate 'ALTER TABLE RCM ADD RCM_DELETE VARCHAR2(1)';
End;
Else
DBMS_OUTPUT.PUT_LINE('Column already exists in the DB');
End IF;
End;
Rem
Rem $Header: oim/server/Database/Oracle/Upgrade/Release91x/910x/List/9102_dml_odf_source_name.sql st_oim_devjain_bug-9003841/1 2009/10/09 02:44:45 devjain Exp $
Rem
Rem 9103_dml_odf_source_name.sql
Rem
Rem Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
Rem
Rem NAME
Rem 9103_dml_odf_source_name.sql - <one-line expansion of the name>
Rem
Rem DESCRIPTION
Rem <short description of component this file declares/defines>
Rem
Rem NOTES
Rem <other useful comments, qualifications, etc.>
Rem
Rem MODIFIED (MM/DD/YY)
Rem vpotukuc 09/17/09 - Bug8796435: Increase the size of odf_source-name
Rem vpotukuc 09/17/09 - Created
Rem
SET ECHO ON
SET FEEDBACK 1
SET NUMWIDTH 10
SET LINESIZE 80
SET TRIMSPOOL ON
SET TAB OFF
SET PAGESIZE 100
declare
collen NUMBER := 0;
begin
select char_length into collen from user_tab_columns where table_name = 'ODF' and column_name = 'ODF_SOURCE_NAME';
IF (collen < 400) then
execute immediate 'alter table ODF modify ODF_SOURCE_NAME varchar2(400)';
END IF;
END;
File name: 91_dml_update_reviewers_With_NoEmail_attestation.sql
Purpose: Modify the email template to replace the 'Delegated By Last Name' with 'Reviewer Last Name' and 'Delegated By User Id' to 'Reviewer User Id'.
Author: Babu Lakshamanaiah
Description: Modify the email template 'Attestation Reviewers With No E-mail Addresses Defined'
declare
cnt int;
begin
Select Count(1) into cnt From emd Where emd_name='Attestation Reviewers With No E-mail Addresses Defined' and emd_language='en' and emd_country='US';
IF cnt=0 Then
Begin
DBMS_OUTPUT.PUT_LINE('There is no record with emd_name Attestation Reviewers With No E-mail Addresses Defined ');
End;
Else
update emd set emd_body='The following attestation reviewers do not have email addresses defined. Attestation requests have been generated for these reviewers and can be accessed by loging in to Oracle Identity Manager. However, notification emails were not sent.' ||chr(10) || chr(10) ||
'Attestation process: <Attestation Definition.Process Name>' || chr(10) ||
'Attestation Request ID: request <Attestation Request.Request Id>' || chr(10) ||
'Request date: <Attestation Request.Request Creation Date>' || chr(10) || chr(10) ||
'Reviewers Without E-mail Address: <reviewers> ' || chr(10) ||
'<Attestation Task.Reviewer First Name> <Attestation Task.Reviewer Last Name> [<Attestation Task.Reviewer User Id>]' Where emd_name='Attestation Reviewers With No E-mail Addresses Defined' and emd_language='en' and emd_country='US';
End IF;
commit;
end;
Please help me out.....
--Marias -
Execute Oracle procedure via Linked server takes very long
Exec ('Begin [procedurename]; End;') at OracleLinkedServer
I used this statement to execute store procedure on Oracle database via linked server. It keeps running and never ends.
However, if I run this procedure Begin [procedurename]; End; in TOAD, it completes in 10s.
This procedure is just simply to merge data between two tables.
Is there any bug or limit on SQL Server Oracle linked server? I am using SQL SERVER 2012 and Oracle 11g client.See if this link helps you
http://markmal.blogspot.co.il/2008/01/it-is-really-pain-if-you-need-to-call.html
select * from openquery(MYORADB, '{CALL SCOTT.PROC4MS({resultset 25, OUTPUT})}');
SELECT * FROM OPENQUERY(<linked server name>, '{CALL <oracle sp>}')
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Advice executing oracle package using shell script.
Hi,
I am writing one shell script that accepts several parameters as an input. These parameters are then passed while executing Oracle package procedure. However this procedure has an OUT parameter and I am not aware of how to receive that parameter in shell script.
Any advice /suggestion is really appreciated.
Below is the part of code I am using ... (P_OUT is suppose to be an out parameter for package)
sqlplus -s apps/apps <<endsql
whenever sqlerror exit failure
set serveroutput on size 10000
execute TEST_PKG.GET_COC_REQ ('$P_FROM_DATE','$P_TO_DATE','$P_MONTH_YY', '$P_OUT');
endsqlThere is more than one way. Here an example :
SQL> select ename,sal from emp where empno=7902;
ENAME SAL
FORD 3000
SQL> create or replace procedure extsal (
2 empnum in number,
3 salout out number)
4 is
5 begin
6 select sal into salout
7 from emp
8 where empno = empnum;
9* end;
SQL> /
Procedure created.
SQL> exit
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.4.0 - Production
$ EMP=7902
$ SAL=`sqlplus -s scott/tiger << EOF
set head off
var salout number;
exec extsal ($EMP, :salout);
print salout
exit
EOF
`$ echo $SAL | awk -F. '{print $2}'
3000
$ -
How to customize events, execute stored procedures using JSF and ADF BC
As a java beginner, I started with developing simple web application using JSF and ADF business component through visual and declarative approach. I need to know how to customize events, execute stored procedures, invoke functions on triggering events associated with rich controls. for eg. how to write customized functions on button click or checkbox click events to achieve business requirement and can be modified whenever required.
Edited by: 792068 on Aug 31, 2010 9:40 PMWhich business layer is prefered to create interactive data model: 1. ADF business components or 2. Enterprise JavaBeans using Java persistance API (JPA) or 3. Toplink 4. Portlets
which minimizes writing low level codes and how much OOPS knowledge is required for creating above business layer binding data to viewcontroller layer? -
Invalid arguments error while executing oracle procedure
Dear all,
we have a table hr_emp with fields ecode, ename, edoj.
the following procedure we created to return the table data to our .net app.
CREATE OR REPLACE
PACKAGE pname AS
TYPE T_hr_cursor IS REF CURSOR;
PROCEDURE get_hr_list (P_hrlist OUT T_hr_cursor);
END HRPACK;
create or replace PACKAGE BODY pname AS
PROCEDURE get_hr_list (P_hrlist OUT T_hr_cursor)
IS
BEGIN
OPEN P_hrlist FOR
SELECT *
FROM Hr_Emp WHERE edoj>='01-jan-2009';
END get_hr_list;
END;
these code edited in a single file [both package and package body] and created successfully.
but, while executing, by typing execute get_hr_list, ORA-00304 error, invalid arguments, is coming. How to resolve this, please help.
also, in sql developer 1.5.3, when we create this, another error is ciming like 'source doesnot have a runnable target'.
Where is the issue? please helpYes, its great dear...
sqlplus>
declare
hr_cursor hrmain.t_hr_cursor;
begin
pname.get_hr_list(hr_cursor);
end;
Its worked as i got 'pl/sql procedure successfully executed'.
Also, then how i can call this get_hr_list procedure from .net? im using c# and i want to get the result of hr_emp to c#. how i can call the same from c#? any help please -
Receiving Email Messages through Oracle procedure using forms.
Hi,
First of all best wishes for the people who are delivering their knowledge in that forum.
I would like to have a procedure that connect to pop servers and receive email messages with attachments. We want to do this through oracle forms.
What type of routine, I need that browses through the pop servers and receives email messages with attachments into database tables, through forms.
Can I have an example that how we do that?
Your valuable information will help me lot.
Woolmer
Databases 8i/9i
forms 6iI exactly don't know the code, but I can tell you the steps how to do it. If u find it useful
Oracle built-ins like UTL_TCP exist that could make it possible to receive email completely inside a stored procedure
1) Create a special email address on a convenient mail server.
2) If the mail server isn't the same machine as the database server, use a program like GNU fetchmail that will pull the mail down to the local machine.
3) Now that the mail data is available in a mail file on the local machine, use one of a variety of techniques to load the email data from the file into the database. -
Error in executing stored procedure using DAAB
Hi
i am calling a stored proc which returns me a record set as follows
Database db = DatabaseFactory.CreateDatabase();
try
DataSet ds;
ds = db.ExecuteDataSet("GetDropDownCodes",null);
return ds;
My stored proc is as follows:
create or replace procedure GetDropDownCodes(record_set out sys_refcursor) is
begin
open record_set for
select defect_code ,defect_code_definition from Defect_Table;
end GetDropDownCodes;
when i execute i am getting an error saying Object refernce not set to an instance of an object.But if i modify the stored proc to add any dummy input parameter
theni am able to get the code working. ie if i add like this
create or replace procedure GetDropDownCodes(abc int,record_set out sys_refcursor) is
begin
open record_set for
select defect_code ,defect_code_definition from Defect_Table;
end GetDropDownCodes;
i will call like this .if works fine .
Database db = DatabaseFactory.CreateDatabase();
try
DataSet ds;
ds = db.ExecuteDataSet("GetDropDownCodes",1,null);
return ds;
Please help me on thisHi
i am calling a stored proc which returns me a record set as follows
Database db = DatabaseFactory.CreateDatabase();
try
DataSet ds;
ds = db.ExecuteDataSet("GetDropDownCodes",null);
return ds;
My stored proc is as follows:
create or replace procedure GetDropDownCodes(record_set out sys_refcursor) is
begin
open record_set for
select defect_code ,defect_code_definition from Defect_Table;
end GetDropDownCodes;
when i execute i am getting an error saying Object refernce not set to an instance of an object.But if i modify the stored proc to add any dummy input parameter
theni am able to get the code working. ie if i add like this
create or replace procedure GetDropDownCodes(abc int,record_set out sys_refcursor) is
begin
open record_set for
select defect_code ,defect_code_definition from Defect_Table;
end GetDropDownCodes;
i will call like this .if works fine .
Database db = DatabaseFactory.CreateDatabase();
try
DataSet ds;
ds = db.ExecuteDataSet("GetDropDownCodes",1,null);
return ds;
Please help me on this -
How to execute oracle procedure from Unix
Hi All,
Could you please help me in Unix commands.
we have different databases i want to run one procedure from unix for one database.
How can i run pls give me the flow.
Thanks,Oracle wrote:
Hi All,
Could you please help me in Unix commands.
we have different databases i want to run one procedure from unix for one database.
How can i run pls give me the flow.
Thanks,you give the command to launch sqlplus, and pass it the appropriate sql or sqlplus commands.
Like this:
oracle> sqlplus /nolog <<EOF
conn / as sysdba
exec mystoredprocedure
exit
EOFor this
oracle> sqlplus /nolog @somefile.sqlwhere 'somefile.sql' has the sqlplus commands needed. -
Executing oracle form using .BAT file
I have written one batch file to run oracle form
FILE START.BAT :
ifrun60 D:\DEPLOY\USER_INPUT.fmx scott/tiger@HOSTDB
when I give command on DOS prompt.
D:\deploy>start and press ENTER
it doesn't work. Would you please suggest any solution to this?
Thanks in advance.
Shaileshhi dear
user this code ur batch file
@echo off
:: COMPILE_FRM.BAT
cls
ECHO Compiling forms
FOR %%f IN (*.fmb) DO ifcmp60 userid=scott/tiger@db module=%%f
ECHO Finished compiling
M Rizwan -
Printing messages through ODI procedure using Javashell bean
I am new to this ODI procedure using Javashell bean.
As i know some basics in Java ,i am trying this following code through ODI.
I wanted to print messages using the code System.out.println("Welcome");
But where we can see the output for this code in ODI?
If any on knows ,kindly let me how do i can go about this?if you run an agent from the command line and you are executing your procedure using this agent then the output will be reported in the dos/cmd window.
-
Entity Framework - Execute Stored Procedures
I want to execute stored procedure using entity framework.
I am using entity framework 6.
The stored procedure has SELECT and RETURN statement.
How can I read the output from SELECT and RETURN statements using
dbContext.Database.ExecuteSqlCommand or dbContext.Database.SqlQuery statement ?Hello Sumit Kadam,
>> The stored procedure has SELECT and RETURN statement.
For the select statement, Entity Framework would support natively:
http://www.entityframeworktutorial.net/stored-procedure-in-entity-framework.aspx
For the return statement, we could use the dbContext.Database.SqlQuery statement as below to fetch the value:
var returnCode = new SqlParameter();
returnCode.ParameterName = "@ReturnCode";
returnCode.SqlDbType = SqlDbType.Int;
returnCode.Direction = ParameterDirection.Output;
// assign the return code to the new output parameter and pass it to the sp
var data = db.Database.SqlQuery<Order>("exec @ReturnCode = ProGetOrder", returnCode);
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Maybe you are looking for
-
How do i download ringers from the iphone store and get em on my phone
how do i download music ringers and get them on my phone as ringers
-
RFC connection problem during SRM - R/3 integration
Hi, Our environment is SRM 5.5 server with 2 R/3 backend systems. One of the R/3 systems is in another country. We happen to have RFC problems during the communication between the SRM and R/3 server. Below you can find the SM21 log related to an oper
-
Still no joy re: headsets & speech?
2 years ago, this post http://discussions.apple.com/click.jspa?searchID=3706388&messageID=1442744 mentioned that "1.5 Bluetooth firmware states clearly that Bluetooth headsets may not be used with...Speech" so now i have Apple Bluetooth Software Vers
-
Regarding planned delivery time for Subcontracting process
1.Factory calender is maintained and assigned to the plant,SUNDAY is not working day for Client,so the system is not planning any internal activities for SUNDAY,up to here it is fine. 2.One semi finished material is produced by vendor.i.e.Sub contra
-
Please help with transparancy fade.
Hello, I have a script that I am using but cannot figure out how to make the bottom reflection fade to transparancy. The image on the left is what comes out from the script & the image on the right shows how I want the reflection to fade into transpa