Calling ORACLE Store Procedure with parameters in user define function
Hi everybody,
We have a scenario connecting Oracle DB thru JDBC adapter.
We have to call store procedure with input parameter and output parameter to retrieve data from DB. The implementation was made using JDBC adapter by building the correct XML message with EXECUTE action, and it works fine.
Now we need to use DB lookup within mapping. I wrote users define function with SELECT statement (using the JDBC adapter) and it works fine but I need to call store procedure in ORACLE instead of SELECT statement.
I found lot of examples concerning DB lookup but none of them explained how to write UDF calling store procedure in ORACLE with input and output parameters.
I am looking for an example.
Thanks in advance,
Gigi
I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
If you think you are going to get existing MS Stored Procedures or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
You could use the EF backdoor, call Oracle Command object and use the Packages, if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
That's about your best shot.
http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx
Similar Messages
-
Call Oracle Stored Procedure with Parameters from Windows Batch File
Hi,
I have an oracle procedure that requires two parameters to execute, start date and end date as such:
CREATE OR REPLACE PROCEDURE insert_orders(
pSTART_DT IN varchar2
, pEND_DT IN varchar2
I want to create a windows batch file to execute the procedure but want to be able to specify the parameters (ie start and end dates) in the batch file as opposed to changing the sql file that the batch file uses to execute the procedure but I don't know what the syntax is. I tried the following but it still doesn't work.
Sql File: call_insert_orders.sql
execute insert_orders('&1','&2');
exit
Batch File:
sqlplus username/password @call_insert_orders.sql %01-jan-2010% %01-jan-2011%
When I execute the batch file, my DOS window still prompts me to enter value 1 so I think it recognizes that there is a variable being used but is not able to fill in the actual value I specify. I'm not an experienced DOS/Windows Batch File person so I'm guessing it's my syntax that's screwed up. There is not a lot of documentation on this subject matter hence my post on this forum. Any helps would be appreciated.
ThanksHello,
Just try the same DOS command without all the % sign.
In MS-DOS, the % at the beginning and at the end of a string are for variables. Which means your batch is looking for a variable called 01-jan-2010 and a variable called 01-jan-2011, but those are the values you want to pass, not the name of variables.
As they are not defined, nothing is passed to the sqlplus script, and that is why you are prompted for values.
Hope it will help.
Regards,
Sylvie -
Getting error while Calling Oracle Stored Procedure with output Parameter
HI All,
From long days i am working on this but i unable to solve it.
Even i have studied so many forums in SAP but i didn't find the solution.
I am calling Oracle Store procedure with 3 inputs and 1 output without cursor.
Store Procedure:-
CREATE OR REPLACE PROCEDURE PDS.send_rm
IS
proc_name VARCHAR2(64) := 'send_rm';
destination_system VARCHAR2(32) := 'RAWMAT';
xml_message VARCHAR2(4000);
status_code INTEGER;
status_message VARCHAR2(128);
debug_message VARCHAR2(128);
p_ret INTEGER;
BEGIN
DBMS_OUTPUT.PUT_LINE( proc_name || ' started' );
xml_message := '<RAW_MATERIAL>'||
'<BAR_CODE>10000764601</BAR_CODE>'||
'<MATERIAL>1101448</MATERIAL>'||
'<VENDOR_CODE/>'||
'<PRODUCTION_DATE>0000-00-00</PRODUCTION_DATE>'||
'<EXPIRE_DATE>0000-00-00</EXPIRE_DATE>'||
'<BATCH/>'||
'<PO_NUM/>'||
'<MATERIAL_DESCRIPTION>POWER SUPPLY</MATERIAL_DESCRIPTION>'||
'<SPEC_NAME/>'||
'<STOCK_CODE>BSW-JH</STOCK_CODE>'||
'<INSPECTION_LOT>00</INSPECTION_LOT>'||
'<USAGE_DECISION_CODE/>'||
'<MATERIAL_GROUP>031</MATERIAL_GROUP>'||
'</RAW_MATERIAL>';
dbms_output.put_line('XML '||xml_message);
-- vp_interface.load_rawmat@cnprpt1_pds(SYSDATE, destination_system,
-- xml_message, p_ret);
vp_interface.load_rawmat(SYSDATE, destination_system,
xml_message, p_ret);
dbms_output.put_line('Return Code '||p_ret);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
status_code := SQLCODE;
status_message := SUBSTR(SQLERRM, 1, 64);
-- Extract_Error_Logger(proc_name, 'LOCAL', SYSDATE, -999,
-- status_message, 0, debug_message);
ROLLBACK;
END send_rm;
And while i am calling this Store procedure in MII, I am facing error.
I have tried different ways but didnt solved
In SQL Query, i kept mode as: FixedQueryOutput
Can anyone tell me or send code for calling above store procedure
And onemore thing, While creating store procedure in Oracle for MII. Do we need to Create output parameter as cursor or normal.
Thanks,
Kind Regards,
Praveen Reddy MHi Praveen
Our wrapper was created because we could not modify the procedure we call (it was not returning a cursor).
CREATE OR REPLACE PROCEDURE CHECK_PUT_IN_USE
(STRCMPNAME in varchar2,
STRSCANLABEL in varchar2,
RCT1 out SYS_REFCURSOR
AS
charDispo Char(1);
charStatus Char(1);
intCatNo Integer;
charCatDispo Char(1);
strCatQual VarChar2(2);
strCatDesc VarChar2(30);
strMsg VarChar2(128);
BEGIN
qa.check_put_in_use@AR(STRCMPNAME,
STRSCANLABEL,
charDispo,
charStatus,
intCatNo,
charCatDispo,
strCatQual,
strCatDesc,
strMsg);
OPEN RCT1
FOR Select charDispo,charStatus,charDispo,charStatus,intCatNo,charCatDispo,strCatQual,strCatDesc,strMsg from Dual;
END;
Hope this helps
Regards
Amrik
then with a FixedQueryWithOutput
call mixar.qasap.wrapper_update_put_in_use('[Param.1]','[Param.2]',[Param.3],?)
Hope this helps. -
How to call a Store Procedure with IN PARAMETER
Hi, im new using Oracle 10G with Oracle SQL Developer, my cuestion is how to call a Store Procedure with IN PARAMETER, I tried the following without results
SELECT * FROM procedure_name(parameter);
PROCEDURE procedure_name(parameter);
EXEC procedure_name(parameter);
CALL procedure_name(parameter);
Please help me....Hi,
As Beijing said,
EXEC procedure_name(parameter);
CALL procedure_name(parameter);work for me.
So does
BEGIN
procedure_name(parameter);
END;Can you be more specific about what you're doing? That is, are you testing it in SQL Developer? Where are you entering the commands? Where are you looking for output? Do you get error messages? Does anything else (like "SELECT SYSDATE FROM dual;") work? -
Calling Oracle store procedure from Crystal 11 command
I need to call Oracle store procedure from Crystal Command. The Store proc has ref cursor. Is it possible. Can you post few examples?
Also, is it possible to have multiple sql statements in a Crystal Command, when working with Oracle 10g?
It is working for SQL server.Please re-post if this is still an issue to the Data Connectivity - Crystal Reports Forum or purchase a case and have a dedicated support engineer work with you directly.
-
T-sql 2008 r2 place results from calling a stored procedure with parameters into a temp table
I would like to know if the following sql can be used to obtain specific columns from calling a stored procedure with parameters:
/* Create TempTable */
CREATE TABLE #tempTable
(MyDate SMALLDATETIME,
IntValue INT)
GO
/* Run SP and Insert Value in TempTable */
INSERT INTO #tempTable
(MyDate,
IntValue)
EXEC TestSP @parm1, @parm2
If the above does not work or there is a better way to accomplish this goal, please let me know how to change the sql?declare @result varchar(100), @dSQL nvarchar(MAX)
set @dSQL = 'exec @res = TestSP '''+@parm1+''','' '''+@parm2+' '' '
print @dSQL
EXECUTE sp_executesql @dSQL, N'@res varchar(100) OUTPUT', @res = @result OUTPUT
select @result
A complicated way of saying
EXEC @ret = TestSP @parm1, @parm2
SELECT @ret
And not only compliacated, it introduces a window for SQL injection.
Erland Sommarskog, SQL Server MVP, [email protected] -
Calling Oracle Stored procedure with OUT parameter from ODI
Hi,
I called an oracle stored procedure with following anonymous block in the ODI procedure.
Declare
Status varchar2(10);
Begin
OTM.DeleteTarget('E_KPI_TARGET_VALUE', Status);
End;
I want to capture the OUT parameter STATUS value in a project level variable.
And based on its va;lue I would like to choose between 2 interfaces in my package.
Please help me in doing this.Hi,
For that kind of situation I commoly use:
1) one step with:
create or replace package <%=odiRef.getSchemaName("W")%>.pck_var
Status varchar2(10);
end;
* transaction 9, for instance
2) step
Begin
OTM.DeleteTarget('E_KPI_TARGET_VALUE', <%=odiRef.getSchemaName("W")%>.pck_var.Status);
End;
* transaction 9
3) then, at an ODI variable, use a refresh like:
select <%=odiRef.getSchemaName("W")%>.pck_var.Status from dual
at same logical shema where the package was created.
Does it make sense to you? -
Reporting off oracle stored procedure with parameters error
Erorr message: Error in File xxx.rpt: Failed to retrieve data from the database. Details: [Database Vendor Code: 907 ]
Asp.net 2.0 web application.
CR XI R2 sp2 in BOE XI R2 sp2 on Solaris 10.
Database: Oracle 10g on Solaris 10. Oracle stored procedure defined in package.
Happens with reports reporting off stored procedure with parameters.
The sp is used in the crystal report.
The web application passes parameters to crystal report, which then passes the parameters to stored procedure.
Encountered error if:
r.PromptOnDemandViewing = false;
r.UseOriginalDataSource = false;
r.CustomServerType = CeReportServerType.ceServerTypeOracle;
Report can retrieves data if:
r.PromptOnDemandViewing = false;
r.UseOriginalDataSource = true;
r.CustomServerType = CeReportServerType.ceServerTypeOracle;
In addition
The steps are:
1) Create oracle package and stored proc.
2) In CR Designer, select the stored proc as datasource.
3) The parameters names were "generated" by the CR Designer.
4) Rename the parameter names.
5) Drag the fields onto report.
We noticed the following with different setting of database logon info:
When previewing from BOE, get error when "Use custom database logon information specified here"
However, no error when "Use original database logon information from the report".
Am i missing something?Please re-post if this is still an issue to the Data Connectivity - Crystal Reports Forum or purchase a case and have a dedicated support engineer work with you directly
-
Guys i am using Entity Framework 5 code first (I am not using edmx) with Oracle and all works good, Now i am trying to get data from stored procedure which is under package but stored procedure have out param which is user define type, Now my question is
how i will call stored procedure from entity framework
Thanks in advance.I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
If you think you are going to get existing MS Stored Procedures or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
You could use the EF backdoor, call Oracle Command object and use the Packages, if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
That's about your best shot.
http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx -
How to call oracle stored procedure with OUT parameter?
I create oracle stored procedure in eclipse oepe
PROCEDURE SP_SELECT_ORA (
ID_INPUT IN VARCHAR2,
ID_OUTPUT OUT VARCHAR2,
PASSWD_OUTPUT OUT VARCHAR2,
NAME_OUTPUT OUT VARCHAR2) IS
BEGIN
SELECT EMP_ID, EMP_Passwd, EMP_Name
INTO ID_OUTPUT, PASSWD_OUTPUT, NAME_OUTPUT
FROM family
WHERE EMP_ID = ID_INPUT;
END;
and I try to call the sp in jpa like below,
@NamedNativeQueries({
@NamedNativeQuery(name = "callSelectSP", query = "call SP_SELECT_ORA(?,?,?,?)", resultClass = Members.class)
@Entity
@Table(name="family")
public class Members implements Serializable {
@Id
@Column(name = "EMP_ID")
private String ID;
@Column(name = "EMP_Passwd")
private String Passwd;
@Column(name = "EMP_Name")
private String Name;
==============
@PersistenceContext(unitName="MyFamily")
EntityManager em;
query = em.createNamedQuery("callSelectSP");
query.setParameter(1, ID);
String id_output = null;
String passwd_output = null;
String name_output = null;
query.setParameter(2,id_output);
query.setParameter(3,passwd_output);
query.setParameter(4,name_output);
query.executeUpdate();
member = (Members)query.getSingleResult();
But this query throws exception,
19:55:35,500 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 1465, SQLState: 72000
19:55:35,500 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) ORA-01465: invalid hex number
I don't know how. Pls, give me your advice. Thanks in advnace.
Best regardsThank you for your reply, Chris!
I tried this one.
@NamedNativeQueries({
@NamedNativeQuery(name = "callSelectSP", query = "exec SP_SELECT_ORA( ?, :id_output, :passwd_output, :name_output) " , resultClass = Members.class)
@Entity
@Table(name="family")
public class Members implements Serializable
===================
query = em.createNamedQuery("callSelectSP");
query.setParameter(1, ID);
String id_output = null;
String passwd_output = null;
String name_output = null;
query.setParameter("id_output", id_output);
query.setParameter("passwd_output", passwd_output);
query.setParameter("name_output",name_output);
query.executeUpdate();
On Console hibernate shew the sql and ora # like below,
19:59:25,160 INFO [stdout] (http--127.0.0.1-8080-1) Hibernate: exec SP_SELECT_ORA( ?, ?, ?, ?)
19:59:25,192 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 900, SQLState: 42000
19:59:25,192 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) ORA-00900: Invalid SQL statement
Pls, inform me your advice. Thanks in advance.
Best regards. -
Calling DB2 Stored procedure(with parameters) from powershell
Hi
I am trying to call a DB2 stored procedure that has parameters from Powershell scrip and I am not able to can some one help me here?
$ServerName = 'XXXX'
$dbalias='XXXXX'
$conn_string = "Provider=IBMDADB2;DBALIAS=$dbalias;Uid=;Pwd=;"
$conn = new-Object system.data.Oledb.OleDbconnection
$conn.ConnectionString = $conn_string
$conn.open()
$query="CALL DBID_CONTROL.GET_TABLE_MAINT_CTL(?,?,?,'MSAS','DATABASE_CONNECTIONS_CUBE','CUBE_PARTITION');"
$cmd = new-Object system.data.Oledb.OleDbcommand($query,$conn)
$ds=New-Object system.Data.DataSet
$da=New-Object System.Data.OleDb.OleDbDataAdapter($cmd)
$da.Fill($ds) [int]$cur_utc_date_key = $ds.Tables[0].Rows[0][0]
$cur_utc_date = $ds.Tables[0].Rows[0][1]
###list current date key & current date values
write-output "current date key value is $cur_utc_date_key"
write-output "current date value is $cur_utc_date"
write-output " "
ThanksHi
This is the error message i get when i run the script
Exception calling "Fill" with "1" argument(s): " CLI0100E Wrong number of parameters. SQLSTATE=07001"
At line:45 char:10
+ $da.Fill <<<< ($ds)
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : DotNetMethodException -
JDevoloper Team - How do you call a plsql procedure with parameters
how can i call a backend pl/sql procedure from a java form in the front end using the same database session as the business project?
How can i pass parameters from a front end ajava form to an entity's EntytiImpl objectKusan,
It's not an exact match to your question, but I believe this HOWTO contains a sample of what you are trying to achieve.
Look for handleStoredProcSelect() or one of the other handleStoredProcXxxxx() methods in:
HOWTO: Basing BC4J Entity on Stored Procedure
http://technet.oracle.com:89/ubb/Forum2/HTML/006400.html
We are maintaining an archive of these HOWTO postings on the JDeveloper Documentation page here on OTN.
http://technet.oracle.com/docs/products/jdev/listing.htm -
Oracle stored procedure with parameters for IN clause
I create this procedure to accepts a variable number of parameter values used to feed a IN clause? and I am getting this error message.
PL/SQL: ORA-00932: inconsistent datatypes: expected NUMBER got STRING_TABLE
please help
step 1
CREATE TYPE string_table AS TABLE OF varchar2(100);
step 2
CREATE OR REPLACE PROCEDURE planholderslist (
p_lettingdate IN string_table,
p_results OUT sys_refcursor
AS
BEGIN
OPEN p_results FOR
SELECT DISTINCT DECODE (TRIM (MIN (j.route)),
NULL, 'N/A',
TRIM (MIN (j.route))
) routenumber,
l.lcontid contractid, (q.cdescr) jobdescription,
INITCAP (q.clocat1 || q.clocat2) LOCATION,
SUBSTR (q.cprojnum, 1, 10) projectnumber,
SUBSTR (l.letting, 3, 2)
|| '-'
|| SUBSTR (l.letting, 5, 2)
|| '-'
|| SUBSTR (l.letting, 1, 2) lettingdate
FROM vendor v,
vendaddr r,
letprop l,
planhold p,
proposal q,
project j,
propproj k,
bidlet bd
WHERE v.vendor = r.vendor
AND k.contid = q.contid
AND k.pcn = j.pcn
AND l.lcontid = k.contid
AND p.vendor = v.vendor
AND l.letting = p.letting
AND TO_CHAR (bd.datelet, 'MM/DD/YYYY') IN p_lettingdate
AND l.CALL = p.CALL
AND r.addrnum = p.billto
AND bd.letting = l.letting
GROUP BY q.cdescr,
q.clocat1,
q.clocat2,
bd.letting,
l.letting,
l.lcontid,
q.cprojnum;
END planholderslist;
/Ok the procedure compiled without any error message. my next question is how can I execute this procedure in my asp.net application. I can I pass multiple values to the parameter.
CREATE OR REPLACE PROCEDURE planholderslist (
p_letting_date IN string_table,
p_results OUT sys_refcursor
AS
BEGIN
OPEN p_results FOR
SELECT DISTINCT DECODE (TRIM (MIN (j.route)),
NULL, 'N/A',
TRIM (MIN (j.route))
) routenumber,
l.lcontid contractid, (q.cdescr) jobdescription,
INITCAP (q.clocat1 || q.clocat2) LOCATION,
SUBSTR (q.cprojnum, 1, 10) projectnumber,
SUBSTR (l.letting, 3, 2)
|| '-'
|| SUBSTR (l.letting, 5, 2)
|| '-'
|| SUBSTR (l.letting, 1, 2) lettingdate
FROM vendor v,
vendaddr r,
letprop l,
planhold p,
proposal q,
project j,
propproj k,
bidlet bd
WHERE v.vendor = r.vendor
AND k.contid = q.contid
AND k.pcn = j.pcn
AND l.lcontid = k.contid
AND p.vendor = v.vendor
AND l.letting = p.letting
AND (TO_CHAR (bd.datelet, 'MM/DD/YYYY') IN (
SELECT COLUMN_VALUE
FROM TABLE
(p_letting_date))
AND l.CALL = p.CALL
AND r.addrnum = p.billto
AND bd.letting = l.letting
GROUP BY q.cdescr,
q.clocat1,
q.clocat2,
bd.letting,
l.letting,
l.lcontid,
q.cprojnum;
END planholderslist; -
Calling Stored procedure with Parameters in PowerPivot DataModel
Hi All,
I wanted to call a SQL stored procedure from PowerPivot(Excel) on based on changing slicer's value.
Currently, we can call stored procedure wihtout any parameter from Data Model tab using
Exec stored_proc_name in Table Properties window.
What if I want to call the same procedure with a parameter whouse value will come by changing slicer's value. I meant, changing slicer value will act as a parameter to that stored procedure & it should return updated results.
Is this possible in PowerPivot?Hi Rameshwar,
According to your description, you call a SQL Server stored procedure in PowerPivot data model, now the problem is that you need to pass a parameter to the stored procedure, right?
Based on my research, it seems that we cannot achieve this requirement directly in current version of PowerPivot data model. Here is a similar thread for you reference.
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/5350228d-bc62-4a3b-a1a6-e847483e2858/powerpivot-for-excel-2013-call-execute-stored-procedure-with-parameters?forum=sqlkjpowerpivotforexcel
If you have any concern about this behavior, you can submit a feedback at
http://connect.microsoft.com/SQLServer/Feedback and hope it is resolved in the next release of service pack or product. Your feedback enables Microsoft to make software and services the best that they can be, Microsoft might consider to add this feature
in the following release after official confirmation.
Regards,
Charlie Liao
TechNet Community Support -
Hi there,
I'm very new to this jdeveloper for bpel and I would like to know how do you call a stored procedure with parameters.
I've been using dbadapters to insert and update database with a transform function but I don't know if you need to do transformation do a stored procedure.Hi,
have you read:
http://download-east.oracle.com/docs/cd/B31017_01/integrate.1013/b28994/adptr_db.htm#CHDFBBCD
Maybe you are looking for
-
Drilling is not working properly in Webi Report
Hi Experts, I have created a webi Report using webi ritch client, in which i has linked two tables using link Element and its working fine but i want to enable the Drill Functionality on the child table only so that what ever selection is made from p
-
How to run the PioneerCyclingJSP and MotorPriseJSP modules at a time
Guys, I would like to run the PioneerCyclingJSP and MotorPriseJSP modules at a time. Could you please suggest me the steps to run both servers at same time on JBOSS 5.0 with ORACLE. How to run a more that one server instance... Thank you
-
Route multiple 6602 counter inputs to one counter output...
Hi! I´d like to route 4 different ttl signals, that are read by 4 different counter inputs to one single output channel (e.g. the output of one of the counters used) using pulse train generation with a divider of 4. Note that only one of the four inp
-
Problems after upgrading 7.6.2 and Solution
I had similar problems as others after upgrading to 7.6.2; iTunes crashing/quiting when trying to download purchased movies from the store, crashing/quiting instantly when trying to play a purchased movie etc....After rebuilding permissions, re-insta
-
Smartform loop into internal table problem
hello experts, i am doing an example given in **************** regarding smartforms. I am getting problem which doing the smartforms . please help me. http://****************/Tutorials/Smartforms/SFMain.htm in that i am doing the program Working with