Exec stored proc on receipt of email in gmail in box
We have a job that each day downloads an email that meets a certain criteria based on subject and send from a gmail inbox.
This job runs at a set time daily, I would like instead to trigger the stored procedure on receipt on the email rather than at a certain time, how would I do this?
With SQL Server / T-SQL this is not possible. You have to write an application with frequently checks you E-Mail box for e-mails.
Olaf Helper
[ Blog] [ Xing] [ MVP]
Similar Messages
-
Stored Proc with SSRS multi value parameter gives " Must Declare scalar Varaiable @StateID
Hi All,
I have one stored proc with @fromDate , @Todate and multivalue input
parameter@StateID of type integer.
When I run below stored proc via SSRS by selecting multiple values thru multiValue parameter into @StateID...it gives error saying "Must Declare scalar variable @StateID"
Not sure what is wrong with the input parameters.
ID is Integer type in all the 3 tables - dbo.EastCities, dbo.WestCities , dbo.Country
I need help fixing this "Must Declare scalar variable @StateID" error
This is the UDF split() I am using..
Function:
CREATE FUNCTION dbo.SplitStateID
( @List VARCHAR(MAX))
RETURNS TABLE
AS
RETURN
( SELECT DISTINCT [Value] = CONVERT(INT, LTRIM(RTRIM(CONVERT( VARCHAR(12),SUBSTRING(@List, Number, CHARINDEX(',', @List + ',', Number) - Number))))
FROM dbo.Numbers
WHERE Number <= CONVERT(INT, LEN(@List))AND SUBSTRING(',' + @List, Number, 1) = ',' );
GO
SELECT [Value] FROM dbo.SplitStateID('10,30,50');
Also, I have created dbo.Numbers table which is used in udf..
reference url -- >
http://sqlblog.com/blogs/aaron_bertrand/archive/2009/08/01/processing-a-list-of-integers-my-approach.aspx
SET NOCOUNT ON;
DECLARE @UpperLimit INT;
SET @UpperLimit = 10000;
WITH n AS(
SELECT rn = ROW_NUMBER() OVER (ORDER BY s1.[object_id])
FROM sys.objects AS s1
CROSS JOIN sys.objects AS s2
CROSS JOIN sys.objects AS s3)
SELECT [Number] = rn - 1
INTO dbo.Numbers FROM n
WHERE rn <= @UpperLimit + 1;
CREATE UNIQUE CLUSTERED INDEX n ON dbo.Numbers([Number]);
Stored procedure:
Create Procedure dbo.CountrySelection
( @FromDate Date, @ToDate Date, @StateID Int)
AS
BEGIN
set nocount on;
SELECT * INTO #EastCities
FROM (
SELECT ID,Description from dbo.EastCities
Where ID IN (SELECT Value from dbo.SplitStateID(@StateID))
) AS A
SELECT * INTO #WestCities
FROM (
SELECT ID,Description from dbo.WestCities
Where ID IN (SELECT Value from dbo.SplitStateID(@StateID))
) AS B
SELECT * INTO #Country
FROM (
SELECT ID , Description, State,Country From dbo.Country
) AS C
SELECT EC.ID AS East, WC.ID AS West , EC.Description AS EastDesc, WC.Description AS WestDesc, CT.State, CT.Country
FROM #Country CT
LEFT JOIN #EastCities EC ON CT.ID=EC.ID
LEFT JOIN #WestCities WC ON CT.ID=WC.ID
DROP TABLE #EastCities
DROP TABLE #WestCities
DROP TABLE #Country
END
Above 3 temp tables are joined by #Country.ID key
It works fine when single value is passed in @StateID
Exec dbo.CountrySelection '01/01/2010','02/01/2010',10
It fails when multi value passed into @StateID
Exec dbo.CountrySelection '01/01/2010','02/01/2010','10,30,40'
SSRS error log shows "Must declare scalar variable @StateID"
Need help in fixing this issue.
Thanks,
RH
sqlVisakh,
I changed @StateID date type to varchar(max) and still I get this error.
System.Data.SqlClient.SqlException: Must declare the scalar variable "@StateID".
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
I am running this SO in SSRS quert Type =Text
Actually sp created on db2 database and due to some limitations I am running(via SSRS) this from different db1 database data source within the same db server. When I run this sp from SSRS query designer(edit query designer button) and pass
multivalue parameters to @StateID as 10 , 20 it works and gives expected resultset.
Thanks,
RH
sql -
Creating a java stored proc in jdev
Does anyone have a quick ref guide to creating a java stored proc in jdev? I am missing early steps to correctly setup the project.
Thanks in advance.Assuming you are using ADF BC, you can try something like the following on your Application Module:
/* our java method to call a stored procedure to send email */
public void sendEmail(String fromEmailAddress, String toEmailAddress,
String subject, String body1, String body2,
String body3, String body4, String body5) {
Object[] parms =
{ fromEmailAddress, toEmailAddress, subject, body1, body2, body3,
body4, body5 };
callStoredProcedure("MSKCC.proc_send_mail(?,?,?,?,?,?,?,?)", parms);
protected void callStoredProcedure(String stmt, Object[] bindVars) {
PreparedStatement st = null;
try {
// 1. Create a JDBC PreparedStatement for
st =
getDBTransaction().createPreparedStatement("begin " + stmt + ";end;", 0);
if (bindVars != null) {
// 2. Loop over values for the bind variables passed in, if any
for (int z = 0; z < bindVars.length; z++) {
// 3. Set the value of each bind variable in the statement
st.setObject(z + 1, bindVars[z]);
// 4. Execute the statement
st.executeUpdate();
} catch (SQLException e) {
throw new JboException(e);
} finally {
if (st != null) {
try {
// 5. Close the statement
st.close();
} catch (SQLException e) {
} -
Can't execute OS-level command from java stored proc
I've written a couple simple java stored procs, the first of which writes an file and the second attempts a chown on it. I can write the file (which is written as the oracle user) just fine. I need to chown it, but can't. Here's the first proc:
public static String writefile()
String fileName = "/joetest/test.xml";
try {
File f = new File(fileName);
FileOutputStream out = new FileOutputStream(f);
PrintStream p = new PrintStream(out);
p.println("this is only a test");
p.close();
return "create file successful!!!";
} catch (Exception e) {
return "Exception occurred writing file:"+e;
Here's the proc I've been stuggling with:
public static String chown(String inString)
String[] command = {"/bin/sh", "-c", "/usr/bin/chown notjoe /joetest/test.xml"};
if (inString != null) {
command[2] = inString;
try {
Process p = Runtime.getRuntime().exec(command);
return "Ownership change success!! "+p;
} catch (Exception e) {
return "Ownership change failure?? err="+e;
The package is created with:
CREATE OR REPLACE PACKAGE JOE.THISISATEST AS
FUNCTION writefile
return VARCHAR2
AS
LANGUAGE java
NAME 'thisisatest.writefile() return java.lang.String';
FUNCTION chown(Param1 VARCHAR2)
return VARCHAR2
AS
LANGUAGE java
NAME 'thisisatest.chown(java.lang.String) return java.lang.String';
end;
And I've granted the following privileges:
begin
dbms_java.grant_permission('JOE', 'java.io.FilePermission', '/joetest/test.xml', 'read, write, execute, delete');
end;
begin
dbms_java.grant_permission('JOE', 'java.io.FilePermission', '/usr/bin/chown', 'execute');
end;
begin
dbms_java.grant_permission('JOE', 'SYS:java.lang.RuntimePermission', 'writeFileDescriptor', '');
end;
begin
dbms_java.grant_permission('JOE', 'SYS:java.lang.RuntimePermission', 'readFileDescriptor', '');
end;
Here's the error that I'm getting:
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Coincidentally, this is the same error that I used to get when I wrote the file without having been granted write privileges. Once I granted myself the proper 'write' permissions I could perform file IO just fine. Is there some runtime permission that I need to grant myself to run chown? I'm just guessing, as I can't find any permission like that in the java documentation. I have 'execute' permission on /usr/bin/chown and the oracle user can execute the command I'm attempting from the command line. ARRRRRGH.
I am at my wits end with this. I've tried what seems like a thousand different syntaxes for the OS command and ran it from many different directories. Anyone have any thoughts at all as to why this is happening? I'm just clutching at straws now...Hmmmm. Granting 'execute' on '<<ALL FILES>>' to user JOE fixes this problem:
begin
dbms_java.grant_permission('JOE', 'java.io.FilePermission', '<<ALL FILES>>', 'execute');
end;
My security folks will not allow this when I port to production, but at least it is something.
Message was edited by:
user603023 -
Call EJB From Oracle Stored proc or Database loaded Java?
Are there any examples of calling an EJB, residing in the OC4J on a machine separate from the DB server,
from an Oracle PL/SQL stored proc.
The Stored proc can call java loaded into the DB. That java makes the intial bean context. Or another way if suggested.
The reason is that I need to use some drivers that I have so far been unable to load directly into the DB using
loadjava util. I plan on using the driver in the EJB, located on a different machine. But I'd like so know if its possible to
make the IntialContext call to the EJB container from PL/SQL. Are the OC4J drivers loadable to be
able to be called from a database loaded java class? ( I might be a little off on my terminology)
Bob
[email protected]Hi Bob,
Your question has been previously asked on this forum many times already.
You can probably find the relevant postings by doing a search of the
forum archives.
To summarize those posts, as I understand it, the latest version of OC4J
(version 9.0.3) contains a "oc4jclient.jar" file (I think that's the name
of the file), that can be loaded into the Oracle database (using the
"loadjava" utility), and which allows a java stored procedure to invoke
methods on an EJB residing in OC4J.
Please note that I have not tried any of the above -- I am only summarizing
for you what has already been posted. And like I said before, a search
of the forum archives will probably give you more details.
Good Luck,
Avi. -
Using Statement rather than CallableStatement for stored proc execution
Cleary, if you need to extract output parameters from a stored procedure, then you must use a CallableStatement to execute it. However, if your stored procedure just returns a basic ResultSet, or performs a database update, is there any penalty to using a regular Statement to execute the stored procedure?
For example -
String sql = "exec testprocedure 'param1' 'param2'";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery( sql );
vs.
CallableStatement cs = conn.prepareCall( "{call testprocedure(?,?)}" );
cs.setString( 1, "param1" );
cs.setString( 2, "param2" );
ResultSet rs = cs.executeQuery();
Any thoughts?Any thoughts?You would have to look at the actual driver code for a sure answer.
But for any real database (which a stored proc suggests) I doubt there would be any difference at all. It would resolve to the same call. -
I have a stored proc that is defined as
CREATE or REPLACE
PROCEDURE ABC
(linkid IN CHAR,
Year_in IN DATE,
Method_in IN CHAR,
Date_out OUT DATE,
average_out OUT NUMBER)
is
begin
end;
another partially completed stored proc that returns a ref
cursor defined as follows:
create or replace package zzz
as
type cursorType is ref cursor;
end;
create or replace function test return zzz.cursortype
as
date_OUT date;
Average_OUT number;
l_cursor zzz.cursorType;
CURSOR temp_cur is
SELECT l.linkid, L.routenumber, ABC(l.linkid,
to_date('01/01/2000', 'mm/dd/yyyy'),
'2',
date_OUT,
average_OUT)
FROM LINK l
WHERE l.LINKID <= '010999';
begin
open temp_cur;
end;
inside test (which I need help completing), how can I refer to
the date_out and the average_out params returned by ABC() so
that these values are in turn passed to the cursortype defined
in package zzz?
Thanks in advance.Try rewriting your abc proceudre as two functions, abc1 and
abc2, and rewriting your test function as a test procedure. See
if you can fill in the blanks prefaced by hyphens -- in the
following code:
CREATE OR REPLACE FUNCTION abc1
(linkid IN CHAR,
year_in IN DATE,
method_in IN CHAR)
RETURN DATE
IS
date_out DATE;
BEGIN
SELECT --
INTO date_out
FROM --
WHERE --;
--or
date_out := --;
RETURN date_out;
END abc1;
CREATE OR REPLACE FUNCTION abc2
(linkid IN CHAR,
year_in IN DATE,
method_in IN CHAR)
RETURN NUMBER
IS
average_out NUMBER;
BEGIN
SELECT AVG (--)
INTO average_out
FROM --
WHERE --
GROUP BY --;
--or
average_out := --;
RETURN average_out;
END abc2;
CREATE OR REPLACE PACKAGE zzz
AS
TYPE cursortype IS REF CURSOR;
PROCEDURE test
(temp_cur OUT cursortype);
END zzz;
CREATE OR REPLACE PACKAGE BODY zzz
AS
PROCEDURE test
(temp_cur OUT cursortype)
IS
BEGIN
OPEN temp_cur
FOR
SELECT l.linkid,
l.routenumber,
abc1 (l.linkid,
TO_DATE ('01/01/2000', 'mm/dd/yyyy'),
'2'),
abc2 (l.linkid,
TO_DATE ('01/01/2000', 'mm/dd/yyyy'),
'2')
FROM link l
WHERE l.linkid <= '010999';
END test;
END zzz;
SQL> VARIABLE g_ref REFCURSOR;
SQL> EXEC zzz.test (:g_ref);
SQL> PRINT g_ref -
S'one tell me how to call Oracle Stored Proc from Java
Hi,
I have a problem in calling the Stored proc using callable statement.It looks like we are doing the same thing or no..
Pl..let me know if you can correct me..Am enclosing the stored proc and java Code...
CREATE OR REPLACE PROCEDURE StoreFTPAddress (FTP in FTPTYPE) is
BEGIN
INSERT INTO DES.FTPSERVICE(
FTPID,
COMPANYID,
SERVERNAME,
DIRECTORY,
USERNAME,
PASSWORD,
INSTRUCTIONS)
VALUES( FTPID.NEXTVAL,
FTP.COMPANYID,
FTP.SERVERNAME,
FTP.DIRECTORY,
FTP.USERNAME,
FTP.PASSWORD,
FTP.INSTRUCTIONS);
END;
JAVA CODE :;
public String retrieveFormatExtension(String formatName)
OracleResultSet rs_form = null;
try
conn = ConnectionDataObjectImpl.getConnection();
Statement stmt = conn.createStatement();
String sql_retrieve = "{call retrieveFormatExtension} " ;
CallableStatement cst = conn.prepareCall(
"{call retrieveFormatExtension(?,?)}");
cst.setString(1," FName ");
cst.registerOutParameter(1, OracleTypes.VARCHAR); // OUT Parameter
cst.executeQuery();
rs_form = (OracleResultSet) cst.getObject(1);
cst.close();
catch (SQLException ex)
System.out.println("SQLException : " + ex.getMessage());
return null;
Regards
Deepauk
[email protected]
nullSyntactically it looks fine. Only thing is u r calling the proc with wrong name. Your procedure takes only one parameter and i.e
IN type. I think u need to correct ur preparecall statement.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Ayappa:
Hi,
I have a problem in calling the Stored proc using callable statement.It looks like we are doing the same thing or no..
Pl..let me know if you can correct me..Am enclosing the stored proc and java Code...
CREATE OR REPLACE PROCEDURE StoreFTPAddress (FTP in FTPTYPE) is
BEGIN
INSERT INTO DES.FTPSERVICE(
FTPID,
COMPANYID,
SERVERNAME,
DIRECTORY,
USERNAME,
PASSWORD,
INSTRUCTIONS)
VALUES( FTPID.NEXTVAL,
FTP.COMPANYID,
FTP.SERVERNAME,
FTP.DIRECTORY,
FTP.USERNAME,
FTP.PASSWORD,
FTP.INSTRUCTIONS);
END;
JAVA CODE :;
public String retrieveFormatExtension(String formatName)
OracleResultSet rs_form = null;
try
conn = ConnectionDataObjectImpl.getConnection();
Statement stmt = conn.createStatement();
String sql_retrieve = "{call retrieveFormatExtension} " ;
CallableStatement cst = conn.prepareCall(
"{call retrieveFormatExtension(?,?)}");
cst.setString(1," FName ");
cst.registerOutParameter(1, OracleTypes.VARCHAR); // OUT Parameter
cst.executeQuery();
rs_form = (OracleResultSet) cst.getObject(1);
cst.close();
catch (SQLException ex)
System.out.println("SQLException : " + ex.getMessage());
return null;
Regards
Deepauk
[email protected]
<HR></BLOCKQUOTE>
null -
Sybase stored proc, no rows in the resultset
Hi!
I have a sybase stored proc that looks more like -
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
BEGIN
DROP PROCEDURE dbo.ETC_DETAILS
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
PRINT '<<< FAILED DROPPING PROCEDURE dbo.ETC_DETAILS >>>'
ELSE
PRINT '<<< DROPPED PROCEDURE dbo.ETC_DETAILS >>>'
END
go
CREATE PROCEDURE dbo.ETC_DETAILS
@trade_id id,
@broker_cd code,
@contact_group_id int,
@product_id id,
@security_type_id smallint
AS
if(cond1)
begin
select distinct
cd=t.cd,
name=t.name,
t.trade_id,..........
from
table1 t,
table2 tt,
table3 b,.......
where t.trade_id = tt.trade_id
and t.transaction_type_id = ttt.transaction_type_id
and .....
end
else
select distinct
cd=t.cd,
name=t.name,
t.trade_id,..........
from
table4 t,
table5 tt,
table6 b,.......
where t.trade_id = tt.trade_id
and t.transaction_type_id = ttt.transaction_type_id
and .....
end
go
GRANT EXECUTE ON dbo.ETC_DETAILS TO public
go
IF OBJECT_ID('dbo.ETC_DETAILS') IS NOT NULL
PRINT '<<< CREATED PROCEDURE dbo.ETC_DETAILS >>>'
ELSE
PRINT '<<< FAILED CREATING PROCEDURE dbo.ETC_DETAILS >>>'
go
EXEC sp_procxmode 'dbo.ETC_DETAILS','unchained'
go
GRANT EXECUTE ON dbo.dbo.ETC_DETAILS TO public
go
When run through SQL Editor - runs and returns me rows. But does not return any rows when invoked from Java. "gotResultSet" is true, but the while loop does not execute. Any clues, why? Here is the Java code.
public class AllocationExtractor {
public Collection getAllocations(int tradeId, String brokerCode, int contactGroupID, int productID, int securityTypeID) throws SQLException
Connection c = null;
String query = "{ call ETC_DETAILS(?,?,?,?,?) }";
CallableStatement stmt = null;
ResultSet rs = null;
boolean gotResults = false;
try{
c = ConnectionFactory.getSybaseConnection(url, user, pwd);
stmt = c.prepareCall(query);
stmt.setInt(1, tradeId);
stmt.setString(2, brokerCode);
stmt.setInt(3, contactGroupID);
stmt.setInt(4, productID);
stmt.setInt(5, securityTypeID);
gotResults = stmt.execute();
if(gotResults)rs = (ResultSet) stmt.getResultSet();
if (rs != null){
System.out.println("Got resultSet");
while(rs.next()){
System.out.println("Iterating the resultset");
Allocation a = new Allocation();
a.setTradeID(rs.getString("trade_id"));
System.out.println(a.getTradeID());
allocations.add(a);
public static void main(String args[]){
AllocationExtractor e=new AllocationExtractor();
Collection c = null;
int tradeID = 3115;
String broker_cd = new String("327");
int product_id = 20;
int contact_group_id = 1;
int security_type_id = 1219;
e.user = "developer";
e.url = "jdbc:sybase:Tds:devbox:12344";
e.pwd = "developer";
try{
c = e.getAllocations(tradeID, broker_cd, product_id, contact_group_id, security_type_id);
catch(SQLException se){
se.printStackTrace();Silly me! had switched the parameters to the method in Java.
-
Stored proc to accept parameters at prompt
How do you create a stored proc in SQL so that when run in desk you can input parameters?
I have a simple stored proc but when I create in deski always get an error saying that it expects '@DateStart'.
here is the sproc ive used:
CREATE Procedure [dbo].[sp_redempt](@DateStart Datetime,@DateEnd Datetime) AS SELECT *
FROM redempt
WHERE planners.office = 'abc'
AND ProcessDate >= @DateStart and ProcessDate <= @DateEnd
-- running it in SQL ent mgr
exec dbo.sp_NCLredempt '01 february 2011', '28 february 2011';
can you help with the syntax I use or specify a simple stored proc using the adventure works DB that will prompt for a parameter in deski?
BO Edge XI 3.0
App server: MS Win2003 Server Standard SP2
DB server: MS Win2003 Server Standard SP2
DB on DB server: SQL 2005Hi,
this is not the best place to post this but you may try the SQL Server forums from Microsoft.
Might be an issue in your parameter type definition. What you can do is in
SQL Server Management Studio, go to the stored procedures (programability) under AdventureWorks database, and Right click -> Script Stored Procedure As -> CREATE to -> New Query Editor Window. Then there you will able to see the syntax how it's used.
You can run one sample procedure in Deski. In Designer create a secure connection to AdventureWorks database. Then create a Deski report based on the "uspGetManagerEmployees" procedure and you can use MnagerID 6 when you run it. You will get results. -
Call stored proc from inside sp
I am trying to call a stored proc from inside a stored proc and the stored proc needs to return a ref_cursor. I am trying to loop over the returned ref_cursor, but my problem is that when I compile the sp it says the ref_cursor is not a procedure or is undefined. Can anyone please tell me why I am getting this error? Refer to the code below!
create or replace
PROCEDURE TCS_GetPartReferenceData
contracts IN VARCHAR2
, showInWork IN INTEGER
, userClock IN VARCHAR2
, intMaxResults IN INTEGER
, ret_cursor OUT SYS_REFCURSOR
) AS
p_cursor SYS_REFCURSOR;
BEGIN
TCS_GETDRNSFORCONTRACTS(contracts
, showinwork
, userClock
, intmaxresults
, p_cursor);
for r in p_cursor loop
dbms_output.put_line(r.puid);
end loop;
END TCS_GetPartReferenceData;Probably you want sth. like
CREATE OR REPLACE PROCEDURE tcs_getpartreferencedata (contracts IN VARCHAR2,
showinwork IN INTEGER,
userclock IN VARCHAR2,
intmaxresults IN INTEGER,
ret_cursor OUT sys_refcursor)
AS
BEGIN
tcs_getdrnsforcontracts (contracts,
showinwork,
userclock,
intmaxresults,
ret_cursor);
END tcs_getpartreferencedata;
var cur refcursor
exec tcs_getpartreferencedata(contracts_value,showinwork_value,userclock_value,intmaxresults_value, :cur)
print curfill in appropriate values for the parameters _value .... -
System calls through Java stored Proc
Hi,
Aim: Execute host command from pl/sql thru java stored proc.
1. Created a java class to take system command that could be executed.
2. It runs fine when the class file is executed.
3. when the java file is loaded to database to access it as java stored proc, for any valid and invalid system commands it is giving out 'PL/SQL successfully completed.
Results were not seen.
4. Java source file.
import java.io.*;
import java.lang.*;
public class Util extends Object
public static int RunThis(String[] args) {
Runtime rt = Runtime.getRuntime();
int rc = -1;
String s = null;
try
Process p = rt.exec(args);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
System.exit(0);
catch (Exception e){
e.printStackTrace();
rc = -1;
finally {
return rc;
public static void main(String[] args){
Util.RunThis(args);
public static String exec(String args){
Util.RunThis(args);
return "Srini it is successful";
5. When ran from host prompt (unix),
executed successfully,
$ /opt/java1.3.1/bin/java Util /usr/bin/ls -l
Here is the standard output of the command:
total 30862
-rwxrwxrwx 1 xyz develope 1348218 Jan 2 17:47 02Jan03-2.zip
-rw-r----- 1 xyz develope 21864 Jul 9 2002 109-60_2_modified7.sql
-rw-r----- 1 xyz develope 44934 Jul 9 2002 109-60_2_modified8.sql
Here is the standard error of the command (if any):
xyz@xxxxx:abcd:/home/xyz
$
6. loadjava,
$ loadjava -user username/password Util.java
7. Create proc,
SQL> create procedure echo_input(s1 varchar2) as language java name 'Util.main(java.lang.String[])';
2 /
Procedure created.
8. Execute proc.
SQL> exec echo_input('/usr/bin/ls -l');
PL/SQL procedure successfully completed.
SQL> exec echo_input('/home/o_report/reports/rcli_ASCT &');
PL/SQL procedure successfully completed.
SQL> set serverout on
SQL> exec echo_input('/home/o_report/reports/rcli_ASCT');
PL/SQL procedure successfully completed.
SQL> exec echo_input('ddsafafasf');
PL/SQL procedure successfully completed.
TIA,
Srini.Hi Srini,
This is just a suggestion, but try entering the following commands (in your SQL*Plus session) before executing your stored procedure:
set serveroutput on size 1000000
exec dbms_java.set_output(1000000)Hope this helps.
Good Luck,
Avi. -
ORA-03113 error when running the Java stored proc demos
Hi there,
Has anyone else run into this issue. When attempting to transfer an object type from Java to Oracle - through a Java stored proc - the session crashes with:
ORA-03113: end-of-file on communication channelLooking in the trace file generated the error message looks something like:
ksedmp: internal or fatal error
ORA-07445: exception encountered: core dump [0x8fe04468] [SIGTRAP] [unknown code] [0x8FE59034] [] []
Current SQL statement for this session:
select pointruntime.jdistance(point(1, 2), point(2, 3)) from dual
----- Call Stack Trace -----
calling call entry argument values in hex
location type point (? means dubious value)
ksedmp+764 call ksedst 0 ? 2C4F4A ? 2C ? 98968000 ?
DB02C ? 27A50000 ?
ssexhd+956 call ksedmp 3 ? 0 ? 8FE5E790 ? 5905870 ?
8FE0434C ? 40895E4 ?
0x9012c860 call ssexhd 5 ? BFFEEF70 ? BFFEEFB0 ? 0 ?
0 ? 0 ?As you can see from the trace snippet above, I was attempting to run one of the Oracle Java stored procedure demos. Has anyone successfully run those demos? Specifically the ones where complex types (table objects or the Point object) are passed back to Oracle from the JVM.
I would appreciate some help with this. The code works fine in a Windows or Solaris environment but barfs on Apple. Truly annoying....
Anyone?
Thanks in advance,
AlexYes,
Apologies for not stating that information, Steve. Was a bit naughty of me! I guess the reason I didn't was because I just wanted to hear if anyone else running Oracle on Mac received such errors when executing the Java stored proc demos (specifically, the execution of PointRuntime.jDistance). Nevertheless, here's the relevant info from the trace file:
Dump file /Users/oracle/admin/sandbox/udump/sandbox_ora_1861.trc
Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
ORACLE_HOME = /Users/oracle/product/10.1.0/db
System name: Darwin
Node name: maczilla.local
Release: 8.3.0
Version: Darwin Kernel Version 8.3.0: Mon Oct 3 20:04:04 PDT 2005; root:xnu-792.6.22.obj~2/RELEASE_PPC
Machine: Power Macintosh
Instance name: sandbox
Redo thread mounted by this instance: 1
Oracle process number: 10
Unix process pid: 1861, image: [email protected] for the Java version, according to the readme file in the javavm directory, I am running 1.4.1:
1.5 Java Compatibility
This release has been thoroughly tested with Sun's Java Compatibility
Kit for the JDK 1.4.1. Oracle is committed to OracleJVM keeping pace
with Java and other Internet standards. -
ODP problem Calling Stored proc..
First here is the code (C#) Errror I am getting is
(Either wrong number of arguments or right at the execute command it just hangs..)
OracleConnection oOracleConn = new OracleConnection();
oOracleConn.ConnectionString = "Data Source=Config;USER ID=xyz;PASSWORD=xyz;";
oOracleConn.Open();
OracleCommand myCmd = new OracleCommand("Config.BillerVersionIns", oOracleConn);
myCmd.CommandType = CommandType.StoredProcedure;
OracleTimeStamp x = OracleTimeStamp.GetSysDate();
myCmd.BindByName = true;
myCmd.Parameters.Add("p_BillerID ", OracleDbType.Int32).Value = 409;
myCmd.Parameters.Add("p_BillerName", OracleDbType.Varchar2).Value = "TestBiller";
myCmd.Parameters.Add("p_BillerActiveInd", OracleDbType.Char).Value = "Y";
myCmd.Parameters.Add("p_ParentBillerID", OracleDbType.Int32);//( this can be null)
myCmd.Parameters.Add("p_PaymentAcceptanceInd", OracleDbType.Char).Value = "Y";
myCmd.Parameters.Add("p_VersionDesc", OracleDbType.Varchar2).Value = "Version Number 4";
myCmd.Parameters.Add("p_EffectiveDate", OracleDbType.TimeStamp).Value = x;
myCmd.Parameters.Add("o_BillerID", OracleDbType.Int32).Direction = ParameterDirection.Output;
myCmd.Parameters.Add("o_VersionID", OracleDbType.Int32).Direction = ParameterDirection.Output;
myCmd.Parameters.Add("o_VersionDesc", OracleDbType.Varchar2).Direction = ParameterDirection.Output;
myCmd.Parameters[3].Status = OracleParameterStatus.NullInsert;
OracleDataReader myreader = myCmd.ExecuteReader();
And now the Stored proc in Oracle 10g...( pls note I have tested this stored proc from Oracle client tool its getting executed perfectly only problem is when I try to call it from code above it throws error)..
Var v1 Number
Var v2 Number
Var v3 Varchar2(50)
Exec Config.BillerVersionIns (409,'Midwest Energy1', 'Y', NULL, 'Y', 'Version Number 1', SYSDATE, :v1, :v2, :v3)
Print v1
Print v2
Print v3
Oracle Procs
TEXT
Procedure BillerVersionIns
( p_BillerID In Number,
p_BillerName In Varchar2,
p_BillerActiveInd In Char,
p_ParentBillerID In Number,
p_PaymentAcceptanceInd In Char,
p_VersionDesc In Varchar2,
p_EffectiveDate In TimeStamp,
o_BillerID out NOCOPY Number,
o_VersionID out Number,
o_VersionDesc out NOCOPY Varchar2
) Is
v_BillerID Number;
v_VersionID Number;
v_EffectiveDate TimeStamp;
v_SysDate TimeStamp;
Begin
v_EffectiveDate := p_EffectiveDate;
v_EffectiveDate := SYSDATE;
v_SysDate := SYSDATE;
If (p_BillerID Is Null) Then
v_VersionID := 1;
Insert Into Config.Biller(BillerID, BillerName, BillerActiveInd, ParentBillerID, PaymentAcceptanceInd, CreatedDate, UpdatedDate)
Values (Config.Biller_Seq.NextVal, p_BillerName, p_BillerActiveInd, p_ParentBillerID, p_PaymentAcceptanceInd, v_SysDate, v_SysDate);
Select BillerID Into v_BillerID From Config.Biller Where BillerName = p_BillerName;
Insert Into Config.BillerVersion (BillerID, VersionID, BillerName, VersionDesc, BillerVersionActiveInd, EffectiveDate, RetireDate, ParentBillerID, PaymentAcceptanceInd, CreatedDate)
Values (v_BillerID, v_VersionID, p_BillerName, p_VersionDesc, 'Y', v_EffectiveDate, NULL, p_ParentBillerID, p_PaymentAcceptanceInd, v_SysDate);
o_BillerID := v_BillerID;
o_VersionID := v_VersionID;
Select VersionDesc Into o_VersionDesc From Config.BillerVersion Where BillerID = v_BillerID And VersionID = v_VersionID;
Else
Select Max(VersionID) Into v_VersionID From Config.BillerVersion Where BillerID = p_BillerID;
Update Config.BillerVersion
Set BillerVersionActiveInd = 'N',
RetireDate = v_SysDate
Where BillerID = p_BillerID
And VersionID = v_VersionID;
v_VersionID := v_VersionID + 1;
Update Config.Biller
Set BillerName = p_BillerName,
BillerActiveInd = p_BillerActiveInd,
ParentBillerID = p_ParentBillerID,
PaymentAcceptanceInd = p_PaymentAcceptanceInd,
UpdatedDate = v_SysDate
Where BillerID = p_BillerID;
Insert Into Config.BillerVersion (BillerID, VersionID, BillerName, VersionDesc, BillerVersionActiveInd, EffectiveDate, RetireDate, ParentBillerID, PaymentAcceptanceInd, CreatedDate)
Values (p_BillerID, v_VersionID, p_BillerName, p_VersionDesc, 'Y', v_EffectiveDate, NULL, p_ParentBillerID, p_PaymentAcceptanceInd, v_SysDate);
o_BillerID := p_BillerID;
o_VersionID := v_VersionID;
Select VersionDesc Into o_VersionDesc From Config.BillerVersion Where BillerID = p_BillerID And VersionID = v_VersionID;
End If;
End;
69 rows selected
TEXT
Message was edited by:
user588434One additional point I would make on the Spring integration side is that you should probably cast to ClientSession below rather than SpringClientSession. Or, in this case, even to oracle.toplink.publicinterface.Session.
java.sql.Connection conn = ((ClientSession) session).getAccessor().getConnection();
Or probably even better would be to refactor the code so that you can execute a DatabaseQuery with a stored procedure Callable. Although I know you already said that you inherited this code from somewhere else, so maybe there's nothing you can do.
But in general, I try to do whatever I can to avoid having to extract the Connection from a TopLink Session. -
Hi Guys ,
To Execute Packages deployed in Catalog , I have created a wrapper SP which internally calls catalog SP ( below is the code )
ALTER PROCEDURE [Publish].[usp_ExecutePackages]
@PackageName NVARCHAR(255)
, @ProjectFolder NVARCHAR(255)
, @ProjectName NVARCHAR(255)
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Execution_id BIGINT ;
EXEC [SSISDB].[catalog].[create_execution] @package_name
= @PackageName
, @execution_id
= @Execution_id OUTPUT
, @folder_name
= @ProjectFolder
, @project_name
= @ProjectName
, @use32bitruntime=
True;
EXEC [SSISDB].[catalog].[set_execution_parameter_value]
@execution_id,
@object_type=50,
@parameter_name=N'SYNCHRONIZED',
@parameter_value=1
EXEC [SSISDB].[catalog].[start_execution] @Execution_id
Since i have multiple Packages , I am looping through list of PackageName and trying to pass package names to this SP by ExecureSQLTask inside ForLoop Container . But it errors out saying
"Cannot access the package or the package does not exist. Verify that the package exists and that the user has permissions to it.
BUt same Execute SQL task , if i keep it outside the ForLoop Container it works perfectly fine .
I am clueless , Please Please HELP me ASAP :(
Question :
How is that possible to execute same SP with same parameter outside Container , But not in SEQUENCE or FORLOOP or FOREACH Container ?
Also
How to make a master package to execute SSIS deployed packages via TSQL using catalog stored proc ?
Please help me out .
Thanks
Prasanna SelvarajuHi ,
After debugging i am getting parameter values as
{Extract - ARTL.dtsx\r\n} Unable to evaluate the expression.
Why do i get \r\n which i dont want in parameters .
Actually i pick the values of package name from a custom table . I check it there are no spaces in the cell.
Any IDEA WHY ? Please help
Finally it worked to call Wrapper Class for EXEC [SSISDB].[catalog].[create_execution]
stored procedure .
Basically , ERROR MESSAGE is culprit
"Cannot access the package or the package does
not exist. Verify that the package exists and that the user has permissions to it.
Above Message : causing us to think
its an Access issue , But actually when you pass parameter incorrectly even a " " space or "\n" extra to value, you will get that error .
Nothing related to access problem .
Actually , In the parameter which i was passing :
{Extract - ARTL.dtsx\r\n} --> String with Enter / Carriage Return and Break line was there
I have removed the Enter in that variable value .
Now its WORKING FINE ! Hurry :D :)
Maybe you are looking for
-
How can I send a jpg of a photograph to someone so that they can download the file and use it to put into an article? I can send it in an Email, but there doesn't seem to be a way for the recipient to extract the jpg from the Email
-
I have a Laserjet Pro 200 color MFP M276nw & Macbook Pro running OSX 10.9.5. I can print wirelessly and scan from the document feeder to my desktop using System Preferences, however, when I try and scan from the flatbed and save to desktop, it appear
-
Hi, Could any one help me to understand exactly the use of reverse posting of a request in an infocube. kumar
-
When I want to update my adobe reader it says to close internet explorer-what should I do?
My computer will not download the updated adobe reader until I close internet explorer. I am a computer novice and am unsure what to do.
-
Run Variable values out of the "variable values window" in a excel workbook
Dear experts, I am working on BI 7.10. Our workbooks are made of several data providers based on the same query and require many different variable values, which give us a long and unconvenient (for the users) "select values for variables" window (ex