How to execute an Oracle stored procedure which returns many records?
I have two synchronous scenarios XI<->PI<->JDBC, where JDBC is receiver adapter.
Each scenario runs a different stored procedure in Oracle database.
The first stored procedure returns only one record, the second stored procedure returns many records, which come from a cursor.
In the first scenario I executed the stored procedure following the directions of Help SAP page and works perfectly.
Link: [http://help.sap.com/saphelp_nw70/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm]
<root>
<StatementName5>
<storedProcedureName action=u201DEXECUTEu201D>
<table>realStoredProcedureName</table>
<param1 [isInput=u201Dtrueu201D] [isOutput=true] type=SQLDatatype>val1</param1>
</storedProcedureName>
</StatementName5>
<root>
I have sought in the forums of SDN and cannot find the way to run the second stored procedure, and receive the information it returns.
Thank you for your help.
Rafael Rojas.
Think It doesnt matter either cursor or result set. Try to get the response back from JDBC and see what are the fields it exactly populating.
In Procedure you can able to find the columns selecting in Cursors. Give those columns in the DT.
File - JDBC (Execute-- Procedure)
To get the response
JDBC_respose - File
Correct me if im wrong.
Regards
Ramg
Similar Messages
-
SOS..How to execute an Oracle Stored procedure
Please help me.
I need to execute an oracle stored procedure from a JSP.
I'M using Jakarta Tomcat and I dont have the Oracle Jbo tags and no BC4j tags.
Anyone have an example using standar tags or directives???.
This an emergency call..!!!!!!To execute a stored procedure (Oracle or other), you must create a CallableStatement.
Here is the link to the API description:
http://java.sun.com/products/jdk/1.2/docs/api/java/sql/CallableStatement.html
You use it like a query but the the syntax is:
{call <procedure-name>[<arg1>,<arg2>, ...]} -
XI calling an Oracle Stored Procedure which returns an Object to XI
I am currently trying to call an Oracle Packaged/Procedure from XI which accepts a couple of parameters as I/O and returns an Object as one of the parameters.
I have created the Object within the Oracle Database CREATE OR REPLACE TYPE xy_jdbc AS OBJECT
column_name type ...etc
CREATE OR REPLACE TYPE xy_tab_jdbc AS TABLE OF xy_jdbc;
One of the parameters for the stored procedure is set up as this type xy_tab_jdbc this will be populated based upon one of the parameters passed into the Package/Procedure.
Is this possible? If it is, how do I map the returned object within XI?Dear Hilary,
the JDBC adapter does not support vendor-specific or non-scalar data types.
Workaround: Change the stored proc's signature not to use an object, but the object's fields instead.
Regards,
Thilo -
Calling a Oracle Stored Procedure which will take a while to complete
Hey.
I'm calling a Oracle stored procedure which goes of and do a whole lot of things and therefore takes a fair while to complete.
Currently I am doing this:
String sql = "begin concorde.start_transfer(); end;";
HibernateUtil.getSessionFactory().openStatelessSession().connection().prepareCall(sql).execute();
....Where HibernateUtil is just a mean to get to the SessionFactory. The connection I get is the same one as a JDBC, I think.
I would want to regain control of the application as soon as the procedure is called and continue with the rest of the logic.
How do I do that? Do I have to initiate it from a different thread?
ThanksIf it was me I wouldn't have a stored proc that took a while to complete. Instead I would submit a job to job queue. In terms of implementation I would call a proc that writes a record to a table. Then a process in the database polls that table and runs jobs it finds there. Then reports results somewhere.
Sometime later you collect the results.
But without that then the solution in java is obvious - create a thread. -
Executing an oracle stored procedure in xMII 11.5
Dear all,
I am facing problem executing an oracle stored procedure using sql query in MII. The SP does not have any input or output parameters & consists of only 2 insert statements. I tried to use Command Mode, FixedQuery & FixedQuery With output mode, but the SP doesn't run.
This is the error i get when i use :
execute InsertTest or exec InsertTest - A SQL Error has occurred on query, ORA-00900: invalid SQL statement
I read in one of the posts to use 'CALL' instead of 'exec' or 'execute'. Even with this i get error which states:
A SQL Error has occurred on query, ORA-06576: not a valid function or procedure name
The syntax i used is CALL InsertTest - 'InsertTest' is the SP name.
I also checked Sam's comment in one of the posts about jdbc driver. We are using oracle 9i, so i guess there is no problem with the version of DB.
The stored procedure is working fine in SQL Developer, How else can i invoke the SP in MII?
Any help would be greatly appreciated.
Thanks,
Sushma.Hi all,
for insert create procedure
CREATE PROCEDURE MII_TEST_INSUPD
(ID_IN IN NUMBER,
NAME_IN IN VARCHAR2)
IS
BEGIN
-- UPDATE ROW
UPDATE TEST SET
NAME = NAME_IN
WHERE
ID = ID_IN;
-- NOT RETURN INSERT NEW LINE IN TABLE
IF SQL%ROWCOUNT = 0 THEN
INSERT INTO TEST (ID, NAME) VALUES (ID_IN, NAME_IN);
END IF;
END;
In MII you create a query template
Mode - Command
FixedQuery - insert the code below
CALL MII_TEST_INSUPD ([Param.1],'[Param.2]')
for returns the grid using procedures in oracle you need create a package on oracle server
CREATE PACKAGE PKG_test IS
TYPE cursortype is ref cursor;
PROCEDURE test (mycursor in out cursortype);
END PKG_test;
CREATE PACKAGE BODY PKG_test IS
PROCEDURE test (mycursor in out cursortype) AS
BEGIN
open mycursor for select * from test;
END;
END PKG_test;
In MII you create a query template
Mode - FixedQueryWithOutput
FixedQuery - insert the code below
CALL PKG_TEST.TEST(?)
Danilo -
How to execute the parametered stored procedure in sql *plus ?
how to execute the parametered stored procedure in sql *plus ?
my storedprocedure format
CREATE OR REPLACE PROCEDURE SMS_SELECTMPLOYEE
(empDOB out date, empEmpName out varchar2)
thanks & regards
mk_murOh, sorry... making many reading-too-fast mistakes today...
You can't declare date variables in SQL*Plus (seel help var), but you can cast to varchar2:
TEST> CREATE OR REPLACE PROCEDURE SMS_SELECTMPLOYEE (empDOB out date, empEmpName out varchar2) IS
2 d date := sysdate;
3 e varchar2(10) := 'bob';
4 begin
5 empdob := d;
6 empempname := e;
7 end;
8 /
Procedure created.
TEST> var d varchar2(30)
TEST> var n varchar2(30)
TEST> call SMS_SELECTMPLOYEE(:d,:n);
Call completed.
TEST> print d n
D
11/07/06
N
bobYoann. -
How in ColdFusion with in variables get a Oracle stored procedure to return values?
How in ColdFusion with in variables get a Oracle stored procedure to return values?
We have tried several things, we can get a stored procedure to return a result set if we are not passing in variables but we cannot get them when we are passing in variables.
We know how to do it calling MS SQL.
Thanks for any help,
Nathan Sr
P.S. we have heard this may not be possible with the current Oracle Driver is there a different Oracle driver?I can only barely understand what you're asking here (not from a technical perspective, but from understanding your written English), but I suspect you're wanting to know how to pass back values other than recordsets from Oracle?
You should be able to pass them back via a type=out proc param, shouldn't you?
If you could reword your post so it's a bit more coherent, and possibly post some code, that might help.
Adam -
Using XI - RFC table and an Oracle stored procedure that returns a cursor.
I need to create an interface using XI between an RFC table and an Oracle stored procedure that returns a cursor. We are on oarcle 9.2 and SP12.
My stored procedure looks something like this:
CREATE OR REPLACE
PROCEDURE testproc_xi2 (p_recordset1 OUT SYS_REFCURSOR,
in_quoteid IN varchar2 )
AS
BEGIN
OPEN p_recordset1 FOR
SELECT q.quote_id,
q.modified_by,
q.quote_status,
q.total_cost
FROM quote q
WHERE q.quote_id = in_quoteid
AND q.total_cost > 0 ;
END testproc_xi2 ;
My RFC has table and one import parameter .
I wanted to know how to create the data type for the ref cursor? and also for the table type in the RFC?
CAN XI handle multi rows coming from a Stored procedure? Are there any other alternative methods if this is not supported?Any pointers to this would be helpful.
I have called a Oracle SP from an RFC before, but that interface had one input parameter going to the stored procedure from the RFC and about 6 o/p parameters coming from the Stored procedure. This works fine.
Thanks for the help.
MalaMala,
i dont think there is anything called an rfc table...RFC stands for remote function call. That in essence would imply you need a rfc to jdbc connection.
yes XI can handle multiple rows cooming from the the stored procedure if you have them mapped appropriately.
Now as to how to create the data type within xi , you need to know what fields are going to be returned and whether they are nested and then just create them as you would for an xml
for ex
<Details>
<FirstName>
<LastName>
</Details>
that in xi would be smthing like
Details type of data occurence
FirstName type of data occurence
LastName type of data occurence.
Hope that helps.
If it does dont forget the points..:-) -
Calling a stored procedure which returns a value
Hi Friends,
I want to call a stored procedure which returns a value.
Eg
create or replace procedure xyz(a1 in varchar2, a2 in varchar2, z1 out number)
thanksHi,
use this.
declare
retval number;
begin
abc('aaa','bbb',retval);
dbms_output.put_line('retval is ' ||retval);
end;
--Basava.S -
Executing an Oracle Stored Procedure from Sender JDBC adapter
I could really use some help from someone who had done this before.
I've read the help about using the JDBC sender adapter, but it's not helping enough.
I found this line: "Specify an SQL EXECUTE statement to execute a stored procedure, which contains exactly one SELECT statement.
The expression must correspond to the SQL variant supported by the relevant JDBC driver. It can also contain table JOINs."
That's definately what we want to do, but we can't figure out the syntax.
The procedure in oracle looks like this:
CREATE OR REPLACE PROCEDURE test_ref_cursor
( cur_generic IN OUT result_sets.cur_generic)
as
BEGIN
Open cur_generic for
select
proposal_number,
to_char(sequence_number),
column_name,
column_value,
update_timestamp,
update_user
from
coeus.sap_test;
END test_ref_cursor;
And we have tried every kind of statement we can think of, but the file adapter always gives us an "invalid sql statement" error.
Does anyone know what syntax we need to put in the "Query SQL Statement" in the JDBC sender adapter in order to call this procedure? Or is there something wrong with the procedure that is causing the error?
<i>I will absolutely return and give points, but PLEASE read my whole post before answering and do not just link me to or quote the help for configuring a sender JDBC adapter or blogs that are about the JDBC adapter in general but do not deal with the issues I am having. Thank you.</i>Hi Vanda,
Unfortunately, the sender JDBC adapter does not support Oracle's store procedure/function. Unlike stored procedures from other database vendors, Oracle returns a cursor, not a resultset. The sender JDBC adapter must send a resultset to XI.
There are 2 possible ways you can accomplish this:
1. Use BPM and call the Oracle stored procedure using a receiver adapter via a asynch-synch bridge.
2. Develop a user-module for the adapter, which can be used with a sender adapter.
Thanks
Prasad -
How send mail from Oracle stored procedure?
Hi,
I need send mail using Oracle stored procedure. Can anybody helpme with any recomendation about that, sample code or so?.
[email protected]
nullHi Raul Martinez
utl_smtp package is available since oracle 8.1.6.
If U have a older version then U can not.
Thank U.
edwin -
Calling Stored Procedure which returns single or multiple value
Hi All Experts,
I have written one stored procedure which is returning different
integer values according to condition.I am calling this
stored procedure through prepareCall() method then executeUpdate() method ,but it is always returning 1,not my desired value.
Pl also tell me,if my stored procedure returns more than one value
then how will i get those values in my java program?
Pl help by writing some sample code.
Thanx in Advance.
Pradipto1) Create CallableStatement
2) For each of returning value you have to call RegisterOutParameter()
3) For others user setXXX() method depending on type of parameter
4) call
5) use vars registered through RegisterOutParameter() - all your values should be there
Pavel -
Call to Oracle stored procedure that returns ref cursor doesn't work
I'm trying to use an OData service operation with Entity Framework to call an Oracle stored procedure that takes an number as an input parameter and returns a ref cursor. The client is javascript so I'm using the rest console to test my endpoints. I have been able to successful call a regular Oracle stored procedure that takes a number parameter but doesn't return anything so I think I have the different component interactions correct. When I try calling the proc that has an ref cursor for the output I get the following an error "Invalid number or type of parameters". Here are my specifics:
App.config
<oracle.dataaccess.client>
<settings>
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.0" value="implicitRefCursor metadata='ColumnName=WINDFARM_ID;BaseColumnName=WINDFARM_ID;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Number;ProviderType=Int32'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.1" value="implicitRefCursor metadata='ColumnName=STARTTIME;BaseColumnName=STARTTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.2" value="implicitRefCursor metadata='ColumnName=ENDTIME;BaseColumnName=ENDTIME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.3" value="implicitRefCursor metadata='ColumnName=TURBINE_NUMBER;BaseColumnName=TURBINE_NUMBER;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.4" value="implicitRefCursor metadata='ColumnName=NOTES;BaseColumnName=NOTES;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYWINDFARMID.RefCursorMetaData.P_RESULTS.Column.5" value="implicitRefCursor metadata='ColumnName=TECHNICIAN_NAME;BaseColumnName=TECHNICIAN_NAME;BaseSchemaName=PGDATA_WC;BaseTableName=WORKORDERS;NATIVEDATATYPE=Varchar2;ProviderType=Varchar2'" />
<add name="PGDATA_WC.ODATAPOC.GETWORKORDERSBYID.RefCursor.P_RESULTS" value="implicitRefCursor bindinfo='mode=Output'" />
</settings>
OData Service Operation:
public class OracleODataService : DataService<OracleEntities>
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
// TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
// Examples:
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("GetWorkOrdersByWindfarmId", ServiceOperationRights.All);
config.SetServiceOperationAccessRule("CreateWorkOrder", ServiceOperationRights.All);
config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
[WebGet]
public IQueryable<GetWorkOrdersByWindfarmId_Result> GetWorkOrdersByWindfarmId(int WindfarmId)
return this.CurrentDataSource.GetWorkOrdersByWindfarmId(WindfarmId).AsQueryable();
[WebGet]
public void CreateWorkOrder(int WindfarmId)
this.CurrentDataSource.CreateWorkOrder(WindfarmId);
Here is the stored procedure:
procedure GetWorkOrdersByWindFarmId(WINDFARMID IN NUMBER,
P_RESULTS OUT REF_CUR) is
begin
OPEN P_RESULTS FOR
select WINDFARM_ID,
STARTTIME,
ENDTIME,
TURBINE_NUMBER,
NOTES,
TECHNICIAN_NAME
from WORKORDERS
where WINDFARM_ID = WINDFARMID;
end GetWorkOrdersByWindFarmId;
I defined a function import for the stored procedure using the directions I found online by creating a new complex type. I don't know if I should be defining the input parameter, WindfarmId, in my app.config? If I should what would that format look like? I also don't know if I'm invoking the stored procedure correctly in my service operation? I'm testing everything through the rest console because the client consuming this information is written in javascript and expecting a json format. Any help is appreciated!
Edited by: 1001323 on Apr 20, 2013 8:04 AM
Edited by: jennyh on Apr 22, 2013 9:00 AMMaking the change you suggested still resulted in the same Oracle.DataAccess.Client.OracleException {"ORA-06550: line 1, column 8:\nPLS-00306: wrong number or types of arguments in call to 'GETWORKORDERSBYWINDFARMID'\nORA-06550: line 1, column 8:\nPL/SQL: Statement ignored"} System.Exception {Oracle.DataAccess.Client.OracleException}
I keep thinking it has to do with my oracle.dataaccess.client settings in App.Config because I don't actually put the WindfarmId and an input parameter. I tried a few different ways to do this but can't find the correct format. -
Using a ORACLE stored procedure to return a query set.
I would like to call an ORACLE stored procedure from inside the Creator. The stored procedure returns the data in a hierarchical format. Is there an example of calling ORACLE stored procedures available?
Thanks for your help.
CharlesSee this thread - might help:
http://swforum.sun.com/jive/thread.jspa?threadID=47188&tstart=0
v -
How to call a Oracle Stored Procedure from Excel?
Hi,
I am new to Oracle database programming.I have an application in excel which has to update info in every row to the database.I am calling a stored procedure in excel for this.The stored procedure is as follows which is executing without a hitch in Oracle:
CREATE OR REPLACE PROCEDURE APD_MASS_UPLOAD_UNITS
(PRODUCT_ID VARCHAR2,Product_Code VARCHAR2, str_Adpt_Grp VARCHAR2,str_Adpt_Type VARCHAR2,
str_PDC VARCHAR2,str_Release_ID VARCHAR2,str_Created_by VARCHAR2,
str_Last_Updated_By VARCHAR2, dt_created_Date VARCHAR2,dt_Last_Updated_Date VARCHAR2,
StrMonth1 VARCHAR2,strMth2 VARCHAR2,StrMth3 VARCHAR2,StrMth4 VARCHAR2,
StrMth5 VARCHAR2,StrMth6 VARCHAR2,Sample Varchar2,str_message OUT Varchar2)
AS
type Month_type is table of VARCHAR2(10) index by binary_integer;
str_month Month_Type;
Fac_ID VARCHAR2(20);
Org_ID VARCHAR2(20);
Cnt_Units NUMBER;
i_POS NUMBER;
i_Month NUMBER;
i_UNITS NUMBER;
CURSOR C1 IS
SELECT * FROM TBLLINE_ADOPT_PLAN WHERE SPEC_ID = Product_ID AND
ADOPT_GROUP = str_Adpt_Grp AND ADOPT_TYPE = str_Adpt_Type
AND RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_Id);
CURSOR C2 IS
SELECT FACILITY_ID FROM TBLADOPT_GROUP_CSC WHERE ADOPT_GROUP = str_Adpt_Grp;
CURSOR C3 IS
SELECT ORG_ID FROM APD_DV_PRODUCT_V WHERE SPEC_ID = Product_ID;
CURSOR C4 IS
SELECT * FROM TBLPROD_CSC WHERE PROD_SPEC_ID = Product_ID;
Adopt_Rec C1%ROWTYPE;
Fac_Rec C2%ROWTYPE;
PMORG_REC C3%ROWTYPE;
CSC_Rec C4%ROWTYPE;
i_Count NUMBER;
Message VARCHAR2(20);
BEGIN
Message := APD_SPECID_VALIDATE(Product_ID,Product_code,Str_PDC, str_Release_ID);
IF TRIM(Message) is null then
OPEN C1;
FETCH C1 INTO Adopt_Rec;
IF C1%NOTFOUND THEN
INSERT INTO TBLLINE_ADOPT_PLAN (SPEC_ID,ADOPT_GROUP, ADOPT_TYPE,RELEASE_ID, SAMPLES,CREATED_BY,CREATED_DATE, LAST_UPDATED_BY,LAST_UPDATED_DATE,SAMPLE_ONLY_IND, GRID_TYPE_CD) VALUES
(Product_ID,str_Adpt_Grp ,str_Adpt_Type,
APD_Get_Release_ID(str_PDC,str_Release_Id), 0,str_Created_By,
TO_DATE(dt_Created_Date,'DD/MM/YYYY'),str_Last_Updated_By,
TO_DATE(dt_Last_Updated_Date,'DD/MM/YYYY'),'N','C');
END IF;
CLOSE C1;
str_Month(1) := strMonth1;
str_Month(2) := strMth2;
str_Month(3) := strMth3;
str_Month(4) := strMth4;
str_Month(5) := strMth5;
str_Month(6) := strMth6;
OPEN C2;
FETCH C2 INTO Fac_REC;
Fac_ID := Fac_Rec.FACILITY_ID;
CLOSE C2;
OPEN C3;
FETCH C3 INTO PMORG_Rec;
Org_ID := PMORG_Rec.Org_ID;
CLOSE C3;
OPEN C4;
FETCH C4 INTO CSC_Rec;
IF C4%NOTFOUND THEN
INSERT INTO TBLPROD_CSC(PROD_SPEC_ID,CSC_FACILITY_ID, PROFIT_CENTER_CD,DEFAULT_IND, CREATED_BY, CREATED_DATE, LAST_UPDATED_BY, LAST_UPDATED_DATE) VALUES
(Product_ID , Fac_ID,Org_id, 'N', str_Created_by ,
To_date ( dt_Created_Date,'DD/MM/YYYY') ,str_Last_updated_by ,
To_Date (dt_Last_Updated_Date ,'DD/MM/YYYY'));
END IF;
CLOSE C4;
IF Sample > 0 Then
UPDATE TBLLINE_ADOPT_PLAN
SET SAMPLES = Sample
WHERE SPEC_ID = Product_ID AND
ADOPT_GROUP = str_adpt_grp AND
ADOPT_TYPE = str_Adpt_Type AND
RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_Id);
END IF;
str_Message := 'Updated';
END IF;
END;
The code to call the stored procedure in Excel is as follows:
Dim Conn As New ADODB.Connection
Dim InputParam1 As New ADODB.Parameter
Dim InputParam2 As New ADODB.Parameter
Dim InputParam3 As New ADODB.Parameter
Dim InputParam4 As New ADODB.Parameter
Dim InputParam5 As New ADODB.Parameter
Dim InputParam6 As New ADODB.Parameter
Dim InputParam7 As New ADODB.Parameter
Dim InputParam8 As New ADODB.Parameter
Dim InputParam9 As New ADODB.Parameter
Dim InputParam10 As New ADODB.Parameter
Dim InputParam11 As New ADODB.Parameter
Dim InputParam12 As New ADODB.Parameter
Dim InputParam13 As New ADODB.Parameter
Dim InputParam14 As New ADODB.Parameter
Dim InputParam15 As New ADODB.Parameter
Dim InputParam16 As New ADODB.Parameter
Dim InputParam17 As New ADODB.Parameter
Dim InputParam18 As New ADODB.Parameter
Dim OutputParam As New ADODB.Parameter
Dim Mth1, Mth2, Mth3, Mth4, Mth5, Mth6 As String
Dim Rs_data As New ADODB.Recordset
Conn.ConnectionString = ("Provider=MSDAORA.1;User ID=" & "cnbg" & ";PASSWORD=" & "cnbg" & ";Data Source=" & "DAQ01" & ";Persist Security Info=False")
Conn.Open
OraCmd.ActiveConnection = Conn
OraCmd.CommandText = "APD_MASS_UPLOAD_UNITS"
OraCmd.CommandType = adCmdStoredProc
Conn.CursorLocation = adUseClient
OraCmd.Parameters.Refresh
Set InputParam1 = OraCmd.CreateParameter("Product_ID", adVarChar, adParamInput, 20)
InputParam1.Value = spec_id
Set InputParam2 = OraCmd.CreateParameter("Product_code", adVarChar, adParamInput, 20)
InputParam2.Value = str_product_code
Set InputParam3 = OraCmd.CreateParameter("str_Adpt_Type", adVarChar, adParamInput, 10)
InputParam3.Value = Adopt_Group
Set InputParam4 = OraCmd.CreateParameter("str_Adpt_Type", adVarChar, adParamInput, 10)
InputParam4.Value = Adopt_Type
Set InputParam5 = OraCmd.CreateParameter("str_pdc", adVarChar, adParamInput, 10)
InputParam5.Value = ThisWorkbook.strDbPDC
Set InputParam6 = OraCmd.CreateParameter("str_Release_ID", adVarChar, adParamInput, 10)
InputParam6.Value = str_Release_Id
Set InputParam7 = OraCmd.CreateParameter("str_created_by", adVarChar, adParamInput, 10)
InputParam7.Value = ThisWorkbook.User_Name
Set InputParam8 = OraCmd.CreateParameter("str_last_updated_by", adVarChar, adParamInput, 10)
InputParam8.Value = ThisWorkbook.User_Name
Set InputParam9 = OraCmd.CreateParameter("dt_created_date", adVarChar, adParamInput, 10)
InputParam9.Value = Sheet1.Cells(8, 2)
Set InputParam10 = OraCmd.CreateParameter("dt_Last_Updated_Date", adVarChar, adParamInput, 10)
InputParam10.Value = Sheet1.Cells(8, 2)
Set InputParam11 = OraCmd.CreateParameter("strMonth1", adVarChar, adParamInput, 10)
InputParam11.Value = Mth1
Set InputParam12 = OraCmd.CreateParameter("strMth2", adVarChar, adParamInput, 10)
InputParam12.Value = Mth2
Set InputParam13 = OraCmd.CreateParameter("strMth3", adVarChar, adParamInput, 10)
InputParam13.Value = Mth3
Set InputParam14 = OraCmd.CreateParameter("strMth4", adVarChar, adParamInput, 10)
InputParam14.Value = Mth4
Set InputParam15 = OraCmd.CreateParameter("strMth5", adVarChar, adParamInput, 10)
InputParam15.Value = Mth5
Set InputParam16 = OraCmd.CreateParameter("strMth6", adVarChar, adParamInput, 10)
InputParam16.Value = Mth6
Set InputParam17 = OraCmd.CreateParameter("Sample", adInteger, adParamInput, 10)
InputParam17.Value = 0
Set InputParam18 = OraCmd.CreateParameter("str_message", adVarChar, adParamOutput, 10)
OraCmd.Parameters.Append InputParam1
OraCmd.Parameters.Append InputParam2
OraCmd.Parameters.Append InputParam3
OraCmd.Parameters.Append InputParam4
OraCmd.Parameters.Append InputParam5
OraCmd.Parameters.Append InputParam6
OraCmd.Parameters.Append InputParam7
OraCmd.Parameters.Append InputParam8
OraCmd.Parameters.Append InputParam9
OraCmd.Parameters.Append InputParam10
OraCmd.Parameters.Append InputParam11
OraCmd.Parameters.Append InputParam12
OraCmd.Parameters.Append InputParam13
OraCmd.Parameters.Append InputParam14
OraCmd.Parameters.Append InputParam15
OraCmd.Parameters.Append InputParam16
OraCmd.Parameters.Append InputParam17
OraCmd.Parameters.Append InputParam18
Set Rs_data = New ADODB.Recordset
Set Rs_data = OraCmd.Execute
I am getting an error at this point which
ORA-06550:line 1,column 54:
PLS-00103:Encountered the symbol ">" when expecting one of the following:
. ( ) * @ % & = - + < / > at in is mod not rem
<an exponent(**)> <> or != or ~= or >= <= <> and or like
between ||
Can anyone pls help me?Thanks.You do not need to code an explicit cursor for a single fetch. An implicit cursor is less code to write, read, maintain and execute.
E.g. Instead of all this:
CURSOR C2 IS
SELECT FACILITY_ID FROM TBLADOPT_GROUP_CSC WHERE ADOPT_GROUP = str_Adpt_Grp;
OPEN C2;
FETCH C2 INTO Fac_REC;
Fac_ID := Fac_Rec.FACILITY_ID;
CLOSE C2;
Simply code this:SELECT
Fac_Rec.FACILITY_ID INTO Fac_ID
FROM BLADOPT_GROUP_CSC
WHERE ADOPT_GROUP = str_Adpt_Grp;PL/SQL procedure calls have to be made (to Oracle) as anonymous PL/SQL blocks. This means that you need to wrap the procedure call into BEGIN..END tags.
So instead of coding this:
OraCmd.CommandText = "APD_MASS_UPLOAD_UNITS"
You need to code something like:
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS; END;"
However, this will not work as APD_MASS_UPLOAD_UNITS expects a bunch of input parameters. And you're on the right track about attempting to bind your Excel variables' values to the PL/SQL procedure's parameters.
Unsure how ADO works, but typically you can bind by name or by position. Let's assume bind by position (typically in PHP):
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS( ?, ?, ?, ?, ?. ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); END;"
Then you will bind values to positions 1 to 18 (did I count the number of params right?). Something like:
OraCmd.CreateParameterByPosition( 1, adVarChar, adParamInput, 20)
Or you can bind by name. E.g.
OraCmd.CommandText = "BEGIN APD_MASS_UPLOAD_UNITS( :pid, :pcode, ..etc.. ); END;"
And:
OraCmd.CreateParameterByName( 'pid', adVarChar, adParamInput, 20)
Read up on your OraCmd.CreateParameter() to see how to correctly use it.
A few more comments. 18 parameters in a call is something I would seriously reconsider. It is quite easy to get it wrong - transpose two parameters. It is very difficult to read and check. Very difficult to maintain. It is much safer to rather define a %ROWTYPE structure to pass, or a PL/SQL record structure.
You are passing date values as VARCHAR2. Rather pass the parameter as the correct data type. E.g.
create or replace procedure foo( custID number, invoiceDate date )...
And then when you call it (in your client code), you specify the date string and date format and make it into a date. E.g.
OraCmd.CommandText = "begin foo( :myCust, TO_DATE(:myDateString,:myDateFormat) ); end;"
Maybe you are looking for
-
now we r implementation in sap. Requirement is if any vendor at the time of payment 20,000 maxumum Value if above to pay vendor system should not allowed. Ex: In f-53 inputs for document Date, Com Code, Bank ACCOUNT Amount value in Amount value up t
-
Trying to deploy a webservice, I messed with the annotations on some beans and now when I try to deploy to the server I get this in the "Feedback" window and nothing else. Previously reported error [IllegalArgumentException in com.sun.tools.jdi.JNITy
-
I have been a long time PC user and im now ready to switch over to apple. Im thinking of getting a MacBook but im thinking that down the line I may want to use Final Cut Studio and I dont think it will work on the MacBook, so I was wondering if I sho
-
Is it possible to correct Acrobat's OCR errors?
When Acrobat 8 OCRs a document, it makes a fair number of errors - which I could live with if one could correct the errors afterwards, but I can't see any way to do that - is it possible to? "Find OCR Suspect" doesn't find anything because Acrobat "t
-
Database Change Notification and TopLink Cache Invalidation
Has someone succeeed in implementing the How-to Database Change Notification and TopLink Cache Invalidation. I have corrected some document errata about the pl/sql content and I manage to have messages in the 'notify_queue'. I obtain the Topic in Jav