Using Oracle Stored Procedure in Interactive Reporting
Hello,
i'm trying to use Oracle Store procedure in Interactive reporting but all i get are errors.
My env:
Interactive Reporting 9.3.1
Oracle Database 10.2
I created OCE as ODBC/OBDC. Tables are returned and Stored Procedure entry is enabled.
If i use "microsoft ODBC for Oracle" i can see stored procedure list but i get this error:
SQL API: [SQLExecDirectW], SQL RETURN: [-1], SQL STATE: [42000], SQL NATIVE ERROR: [6550], SQL MESSAGE: [[Microsoft][ODBC driver for Oracle][Oracle]ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'TEST_PDC_RECORDSET'
If i use Oracle's odbc i get: "Error in function sequence".
If i use Merants (5.2) odbc i cannot retreive stored procedure list. (list is empty)
Note.
My stored procedure works (tested via sqlplus).
thank u daniele
Returning (or sending in) multiple rows directly from (or to) a stored procedure is not currently possible. I have been in contact with SAP on this subject earlier, and they suggest using a web service to do the job. I used this as a work around, calling the stored procedure from a web service. I send in VC tables to this web service, and this in turn contacts my stored procedure.
The problem is related to the connector framework in the J2EE environment.
I am on 7.0 sps 17
If you use stored procedure single value parameters of type varchar, number ... then VC has no problem communicating with your procedures.
Good luck
Henning Strand
Similar Messages
-
Error Calling Oracle Stored Procedure From Within Report
Hi,
I have a report that calls an oracle stored procedure which returns a ref cursor. The report is working ok in our development environment when called from our development website through .NET.
When the report is moved and accessed from our UAT website we get the following error :-
Failed to open a rowset. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for Oracle Description: One or more errors occurred during processing of command. Failed to open a rowset. Details: ADO Error Code: 0x Source: Microsoft OLE DB Provider for Oracle Description: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'RHS_GET_CAND_SECTION_REFS' ORA-06550: line 1, column 7: PL/SQL: Statement ignored Native Error: Failed to open a rowset. Error in File C:\WINDOWS\TEMP\temp_d663a952-bef6-4bf7-bf1a-5e288afdb612 {9B6DFB38-A436-4940-9D80-B4C23DFFFF19}.rpt: Failed to open a rowset.
If we open the report manually we are prompted to enter database connection info. If we enter the UAT connection details the report runs ok. If we save the report and try to open it from UAT website through .NET it now opens ok.
If we then move that same report back to the development environment and open from our development website it fails with the same error above.
Both connections are using Microsoft OLE DB drivers and the Oracle databases are the same version (10.2.0.1.0).
Is the connection information being stored in actual report and somehow being used when the report is opened through .NET?
Any help appreciated
Regards
PaulHi,
Please let me know if the issue occurs with the crystal reports designer, if you are facing issues with the .NET application then a need to create a post [here|SAP Crystal Reports, version for Visual Studio;.
Regards,
Hitesh -
Unknown Database Connector Error using Oracle stored procedures
We are using an Oracle database for the first time with our Crystal Reports, and I am attempting to modify a report to use a new stored procedure. When I attempt to add either the new procedure, or to add a new copy of the existing procedure, I get an error message:
Unknown Database Connector Error
If I remove the existing procedure first (leaving no database objects at all), and then attempt to add back exactly the same stored procedure that I just removed, I get a different error message:
Database Connector Error: '42000:[Oracle][ODBC]Syntax error or access violation'
Neither of these errors is particularly helpful. The stored procedure in question works as is. I can run it in SQL Developer, and it also executes within the existing report if I run it. Unfortunately, it needs to be modified and given a new name, so I need to be able to add the new stored procedure to the report.
The operating system is Windows XP Professional version 2002 SP3. The Oracle version is 11g (11.2.0.2.0). Crystal reports version is Crystal Reports 2008 (12.3.0.601). The stored procedure returns a refcursor. The ODBC connection is created using the "Oracle in OraClient11g_home1" driver. When I test the connection, it tells me it was successful.
If it matters, the report is a Saba report.
Can anyone shed any light on what the problem is and how to fix it. If the solution is to upgrade the Windows version, that is under the control of our tech support and there is no information available as to when it will happen.Yes - I had used the Set Datasource Location to point to the correct ODBC connection. I get the same results with an existing report as I do with a new blank report.
I have no idea where the service market place is. Honestly, I find the entire SAP site confusing. I found one reference to the PAM guide, but when I clicked on it, it insisted on a userid/password, and apparently the userid/password I have for this discussion group doesn't pass. I did find, eventually, a document called "Crystal Reports 2008 Service Pack 3 for Windows - Supported Platforms". When I read it, it tells me that it's compatible with Oracle 11g, generic ODBC, and Windows XP SP3, which is what we are using. I'm hoping that this document has equivalent information to the PAM guide. -
Looking for some help with using Oracle stored procedures in vb2010
First off thank you to whoever lends me a hand with my problem. A little background first I am in a software development class and we are currently building our program using VB (I have no experience in this), and Oracle(currently in a Oracle class so I know how to use Oracle itself just not with VB).
I am using vb2010 express edition if that helps. Currently I have a stored procedure that takes a 4char "ID" that returns a position (ie, salesperson,manager ect). I want to use the position returned to determine what vb form is displayed (this is acting as a login as you dont want a salesperson accessing the accountants page for payroll ect).
Here is the code I have currently on the login page of my VB form
Imports Oracle.DataAccess.Client
Imports Oracle.DataAccess.Types
Public Class Login
Dim conn As New OracleConnection
Private Sub empID_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles empID.Click
End Sub
Private Sub LoginBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginBtn.Click
conn.ConnectionString = "User ID = Auto" & _
";Password = ********" & _
";Data Source = XE"
conn.Open()
Dim sq1 As String = "Return_Position" 'name of procedure
Dim cmd As New OracleCommand(sq1, conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New OracleParameter("I_EmpID", OracleDbType.Char, 4)).Value = Emp_ID.Text
Dim dataReader As OracleDataReader = cmd.ExecuteReader
dataReader.Read()
Dim position As New ListBox
position.Items.Add(dataReader.GetString(0)) 'were I am getting an error, I also tried using the dataReader.getstring(0) to store its value in a string but its a no go
If position.FindStringExact("MANAGER") = "MANAGER" Then
Me.Hide()
Dim CallMenu As New Menu()
CallMenu.ShowDialog()
End If
LoginBtn.Enabled = False
End Sub
I have read the oracle.net developer guide for using oracle in vb2010 and have successfully gotten through the document however they never use a stored procedure, since the teacher wants this program to user a layered architecture I cannot directly store sql queries like the document does, thus the reason I want to use stored procedures.
This is getting frustrating getting stuck with this having no background in VB, I could easily do this in c++ using file i/o even through it would be a pain in the rear....Hello,
I am calling Oracle 11g stored procedures from VB.Net 2010. Here is a code sample (based on your code) you should be able to successfully implement in your application.
Please note that you may have to modify your stored procedure to include an OUT parameter (the employee position) if it doesn't have it yet.
Private Sub LoginBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoginBtn.Click
Dim sProcedureName As String = "Return_Position" 'name of stored procedure
Dim ORConn as OracleConnection, sConn as String
Dim sPosition as String, sDataSource as String, sSchema as String, sPWD as String
Dim cmd As OracleCommand
'please provide below sDataSource, sSchema and sPWD in order to connect to your Oracle DB
sConn = "Data Source=" & sDataSource & ";User Id=" & sSchema & ";Password=" & sPWD & ";"
ORConn = New OracleConnection(sConn)
ORConn.Open()
cmd = New OracleCommand(sProcedureName, ORConn)
With cmd
.CommandType = Data.CommandType.StoredProcedure
'input parameter in your stored procedure is EmpId
.Parameters.Add("EmpID", OracleDbType.Varchar2).Value = Emp_ID.Text
.Parameters.Item("EmpID").Direction = ParameterDirection.Input
'output parameter in your stored procedure is Emp_Position
.Parameters.Add("Emp_Position", OracleDbType.Varchar2).Direction = ParameterDirection.Output
.Parameters.Item("Emp_Position").Size = 50 'max number of characters for employee position
Try
.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message)
Exit sub
End Try
End With
sPosition = cmd.Parameters.Item("Emp_Position").Value.ToString
'close Oracle command
If Not Cmd Is Nothing Then Cmd.Dispose()
Cmd = Nothing
'close Oracle connection
If Not ORConn Is Nothing Then
If not ORConn.State = 0 Then
ORConn.Close()
End If
ORConn.Dispose()
End If
ORConn = Nothing
If UCase(sPosition) = "MANAGER" Then
Me.Hide()
Dim CallMenu As New Menu()
CallMenu.ShowDialog()
End If
LoginBtn.Enabled = False
End Sub
If you need further assistance with the code, please let me know.
Regards,
M. R. -
Problem while using oracle stored procedure in VC
Hi All,
I have created JDBC system and connected my locally installed Oracle data base to the VC. I mapped the data base user to my VC user. I tested connection and it is fine. Further I see the DB alias in Visual Composer and I can drop stored procedures to my story board. I can define parameters, but when I am executing procedures I get the error message.
Problem: I can not execute stored procedures stored in Oracle data base. Error Message: Portal request failed. Could not execute stored procedure.
In the stored procedure, I have used select query, that returns set of records, so that I have used REF CURSOR as OUT Parameter. Is REF CURSOR supported by VC?. Else, any tricks available to solve this problem?.
Note: Stored Procedure of Sql server is working fine in VC.
Thanks,
Venkatesh RReturning (or sending in) multiple rows directly from (or to) a stored procedure is not currently possible. I have been in contact with SAP on this subject earlier, and they suggest using a web service to do the job. I used this as a work around, calling the stored procedure from a web service. I send in VC tables to this web service, and this in turn contacts my stored procedure.
The problem is related to the connector framework in the J2EE environment.
I am on 7.0 sps 17
If you use stored procedure single value parameters of type varchar, number ... then VC has no problem communicating with your procedures.
Good luck
Henning Strand -
Using Oracle Stored Procedure to call a webservice
Hi,
I am using this version of Oracle:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
Requirement: I have to write a stored procedure that calls a webservice and get the result from webservice and show it on sqlplus.
I have read some articles, and am confused as to where to start. I have come across UTL_DBWS and UTL_HTTP. But to use them, I have to set up my database accordingly allocating pool size etc.
Is there an alternative?
I am reading through a lot of stuff, but I am honestly not getting a hold of anything. Please advice, how I can go step by step.
Thank you!!934451 wrote:
Hi,
I am using this version of Oracle:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
Requirement: I have to write a stored procedure that calls a webservice and get the result from webservice and show it on sqlplus.
I have read some articles, and am confused as to where to start. I have come across UTL_DBWS and UTL_HTTP. But to use them, I have to set up my database accordingly allocating pool size etc.
Is there an alternative?
I am reading through a lot of stuff, but I am honestly not getting a hold of anything. Please advice, how I can go step by step.
Thank you!!don't use Oracle to complete any non-DB related task.
while a shovel is a great tool for producing a hole in the ground,
it is sub-optimal when the wrong end of the shovel is used to move the dirt.
You are using the "wrong end" of Oracle. -
How to Return ten records into java class by using oracle stored procedure
Hello sir/Friends
There is a procedure that returns 10 records from the oracle table and i want to display all 10 records into the table in java class.
Please reply
Thanking you.When you execute the stored procedure it will return your results as a ResultSet. Iterate over itto get the values you need then do with them as you please.
List<MyObject> results = new ArrayList<MyObject>();
MyObject mo = null;
ResultSet rs = stmt.executeQuery("SELECT a_value FROM a_table");
while (rs.next())
mo = new MyObject();
mo.setValue(rs.getString(1));
results.add(mo);
} -
Oracle Stored Procedure using CR2011
We have CR11.5 reports that works using Oracle Stored Procedure. We are planning to upgrade to CR2011 but the report fails with the error message Failed to retrieve data from database. Details HY000 may not perform insert/delete/update operation inside a READ ONLY transaction
Hello Don,
I am trying to use OLE DB to access the stored procedure in the oracle. I can see the stored procedure in the crystal report with the fields but whenever i refresh i face a message box
the text of the message box is as follows
Crystal Reports
Failed to open a rowset.
Details: ADO Error Code: 0x80040e14
Source: Microsoft OLE DB Provider for Oracle
Description: ORA-06550: line 1, column 42:
PLS-00363: expression ' NULL' cannot be used as an assignment target
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
Native Error: 6550
OK
My stored procedure code is as follows
Create or Replace Package pckReports
AS
type agent_list is ref cursor return BAT_AGENTLIST%rowtype;
END;
CREATE or REPLACE PROCEDURE BatAgentlistReport (p_Recordset IN OUT pckReports.agent_list) AS
BEGIN
Open p_Recordset FOR
select * from bat_agentlist;
END;
The Ole db version is :- 10.1.0.4.0
The stored procedure is developed in Oraclient10g.
I am developing the stored procedure from the microsoft visual studio using a connection with the provider :- OraOLEDB.Oracle.1 -
How to call Oracle Stored Procedure using EDQ
Can someone tell me how to use Oracle Stored Procedure call in EDQ, sample scripts/steps will be really helpful. Thanks!
It is also possible to do this using a custom processor in EDQ. The processor needs to do something very similar to the external task above (opens a DB connection, authenticates, runs a stored procedure).
If you need this, please talk us through the use case so we can determine if it is the best fit. In some ways, an external task is better as logically a stored procedure call is normally divorced from any process logic in EDQ.
Regards,
Mike -
SSRS with Oracle Stored Procedures, Functions and Packages
Hi,
I am working on a BI project. Here we are using PowerPivot to access data from Oracle DB and generate reports. Currently Client generates Few reports using Oracle Stored Procedures, Functions and Packages. We need to move everything to PowerPivot, so
that user can generate all reports using same platform. But PowerPivot doesn'e support Oracle Stored Procedures, Functions and Packages. So we have decided to try those reports using SSRS.
I have no knowledge about using SSRS which will call Oracle function/stored procedures/packages for generating reports.
Can anybody help me in getting exact steps?
Please let me know if my question is not clear enough.
Thanks and Regards,
SSHi Visakh,
Thanks for the detailed steps. My next question is:
Is there any other way to develop such reports without using any development tool like Visual Studio? Our aim is to provide a self-serviced reporting platform where user don't need any technical knowledge.
I am sorry I have no knowledge about SSRS and Oracle DB.Can you please have a look at my Oracle function and let me know whether it's possible to execute this using SSRS? (I am pasting one by one as there is a character limit.
CREATE OR REPLACE TYPE obj_special_pass_cases
AS OBJECT
CLAIM_ID NUMBER(12),
claim_ref_no VARCHAR2(20),
OFFICER_NAME VARCHAR2(201),
SUBMIT_DT VARCHAR2(10),
ACC_DT VARCHAR2(10),
SP_ISSUE_DT VARCHAR2(10),
STATUS VARCHAR2(30),
SUB_STATUS VARCHAR2(30),
STATUS_LAST_UPDATE_DATE VARCHAR2(10),
SP_EXP_DT VARCHAR2(10),
INDUSTRY_CODE VARCHAR2(8),
EMP_SSIC VARCHAR2(8),
rel VARCHAR2(4),
WPNo VARCHAR2(20),
FIN VARCHAR2(9),
PASSPORT_NO VARCHAR2(16),
SPNo VARCHAR2(20),
VictimName VARCHAR2(100),
SP_EXT_PURPOSE VARCHAR2(100),
ISSUE_SYSTEM VARCHAR2(4),
REPATRIATION_DATE VARCHAR2(10),
SP_STATUS VARCHAR2(30),
SP_ISSUE_PURPOSE VARCHAR2(500)
CREATE OR REPLACE TYPE tbl_special_pass_cases
AS TABLE OF obj_special_pass_cases
CREATE OR REPLACE TYPE obj_special_pass_casesNew
AS OBJECT
CLAIM_ID NUMBER(12),
claim_ref_no VARCHAR2(20),
OFFICER_NAME VARCHAR2(201),
SUBMIT_DT VARCHAR2(10), /*Case Registration Date*/
ACC_DT VARCHAR2(10),
SP_ISSUE_DT VARCHAR2(10),
calc_sp_issue_dt VARCHAR2(10),
calc_sp_issue_dt_month VARCHAR2(2),
calc_sp_issue_dt_year VARCHAR2(4),
calc_Duration_Of_Stay VARCHAR2(4),
STATUS VARCHAR2(30),
SUB_STATUS VARCHAR2(30),
STATUS_LAST_UPDATE_DATE VARCHAR2(10),
lastUpdateDtMonth varchar2(2),
lastUpdateDtYear varchar2(4),
DurationOfUpdateDt VARCHAR2(4),
SP_EXP_DT VARCHAR2(10),
INDUSTRY_CODE VARCHAR2(8),
EMP_SSIC VARCHAR2(8),
rel VARCHAR2(4),
WPNo VARCHAR2(20), /* New columns from here - SR */
FIN VARCHAR2(9),
PASSPORT_NO VARCHAR2(16),
SPNo VARCHAR2(20),
VictimName VARCHAR2(100),
workerNationality VARCHAR2(20),
employName VARCHAR2(200),
reportType VARCHAR2(10),
SP_EXT_PURPOSE VARCHAR2(100),
ISSUE_SYSTEM VARCHAR2(4), /*IWPS, EIDS*/
REPATRIATION_DATE VARCHAR2(10),
SP_STATUS VARCHAR2(30),
SP_ISSUE_PURPOSE VARCHAR2(500)
CREATE OR REPLACE TYPE tbl_special_pass_casesNew
AS TABLE OF obj_special_pass_casesNew
FUNCTION getListOfSpecialPassCases(
vRepatriationDateFrom VARCHAR2,
vRepatriationDateTo VARCHAR2,
vIncludeRepatriationDate VARCHAR2)
RETURN tbl_special_pass_cases
IS
TYPE cur_typ IS REF CURSOR;
SPECIAL_PASS_CASES_CUR cur_typ;
vSQL1 VARCHAR2(4000);
--vSQL1 VARCHAR2(4000) := 'SELECT DISTINCT(A.CLAIM_ID), A.CLAIM_REF_NO, A.STATUS, A.SUB_STATUS, A.OFFICER_NAME, A.SUBMIT_DT, A.ACC_DT, A.vLatestUpdatedDate, A.INDUSTRY_CODE, A.ID_NO, A.vWorkerName, B.vSPWPNO, B.vFIN, B.vSPPassportNo,
B.vSPIssueDate, B.vSPExpiryDate, B.vSPNo, DECODE(B.vSPExtensionPurpose,''1'',''WICB'',''2'',''RE-APPLICATION'',''3'',''POLICE'',''4'',''REPATRIATION'',''5'',''LRD'',''6'',''LATE RENEWAL'',''9'',''OTHERS'',''10'',''LATE EISSUANCE'',''13'',''FMMD'',''14'',''TMB
PENDING REPATRIATION'',''15'',''TMB REPATRIATION'',''16'',''PENDING REPATRIATION (SB-F)'',''17'',''REPATRIATION (SB-F)'') vSPExtensionPurpose, B.vIssueSystem, B.vSPActualDepartDate, B.vSPStatus, DECODE(B.vSPIssuePurpose,''1'',''WICB'',''2'',''RE-APPLICATION'',''3'',''POLICE'',''4'',''REPATRIATION'',''5'',''LRD'',''6'',''LATE
RENEWAL'',''9'',''OTHERS'',''10'',''LATE EISSUANCE'',''11'',''PENDING DOCUMENT VERIFICATION'',''12'',''LATE ERENEWAL'',''13'',''FMMD'',''14'',''TMB PENDING REPATRIATION'',''15'',''TMB REPATRIATION'',''16'',''PENDING REPATRIATION (SB-F)'',''17'',''REPATRIATION
(SB-F)'') vSPIssuePurpose FROM (SELECT vSPWPNO, vFIN, vSPPassportNo, vSPIssueDate, vSPExpiryDate, vSPNo, vSPExtensionPurpose, vIssueSystem, vSPActualDepartDate, vSPStatus, vSPIssuePurpose FROM TABLE(IOSH_WIC_EXT_INTERFACE_PKG.getIWPSActiveSpecialPass) WHERE
(vSPWPNO IS NOT NULL OR vFIN IS NOT NULL)) B JOIN (SELECT WC.CLAIM_ID CLAIM_ID, WC.CLAIM_REF_NO CLAIM_REF_NO, WC.STATUS STATUS, WC.SUB_STATUS SUB_STATUS, TAS.LAST_NAME ||'' ''|| TAS.FIRST_NAME OFFICER_NAME, to_char(trunc(IRN.SUBMIT_DT), ''dd/MM/yyyy'')
SUBMIT_DT, TO_CHAR(trunc(decode(wc.assessmt_type,''OD-PI'',EV.OD_CONSULT_DT,''OD-TI'',ev.od_consult_dt,ECASE.acc_dt)), ''dd/MM/yyyy'') ACC_DT, (SELECT TO_CHAR(MAX(WCS.STATUS_START_DT), ''dd/MM/yyyy'') STATUS_LAST_UPDATE_DATE FROM WIC_CLAIM_STATUS WCS WHERE
WCS.CLAIM_ID=WC.CLAIM_ID) vLatestUpdatedDate, EC.INDUSTRY_CODE INDUSTRY_CODE, EP.ID_NO ID_NO, EP.NAME vWorkerName FROM EVENT_PERSON EP, WIC_CLAIMS WC, TBL_AA_SUBJECT TAS, EVENT_COMPANY EC,EVENT_CASE ECASE,event_victim ev WHERE EP.ID_NO IS NOT NULL AND EP.DELETE_IND
= ''F'' AND EP.INVOLVEMENT = ''VICTIM'' AND WC.EVENT_CASE_NO = EP.EVENT_CASE_NO AND WC.EVENT_PERSON_ID = EP.EVENT_PERSON_ID AND ep.event_person_id = ev.event_person_id (+) AND WC.ASSIGN_OFFICER_ID = TAS.SUBJECT_ID AND EC.EVENT_CASE_NO=WC.EVENT_CASE_NO AND
EC.INVOLVEMENT in (''EMPLOYER'',''EMPLOYER_OCCUPIER'') AND ECASE.EVENT_CASE_NO=WC.EVENT_CASE_NO AND EC.DELETE_IND = ''F'') A ON (B.vFIN = A.ID_NO OR B.vSPPassportNo = A.ID_NO)';
vSQL2 VARCHAR2(4000);
--vSQL2 VARCHAR2(4000) := 'SELECT DISTINCT(A.CLAIM_ID),A.CLAIM_REF_NO,A.STATUS,A.SUB_STATUS,A.OFFICER_NAME,A.SUBMIT_DT,A.ACC_DT,A.vLatestUpdatedDate,A.INDUSTRY_CODE,A.ID_NO,A.vWorkerName,B.vSPWPNO,B.vFIN,B.vSPPassportNo,B.vSPIssueDate,B.vSPExpiryDate,B.vSPNo,DECODE(B.vSPExtensionPurpose,''1'',''WICB'',''2'',''RE-APPLICATION'',''3'',''POLICE'',''4'',''REPATRIATION'',''5'',''LRD'',''6'',''LATE
RENEWAL'',''9'',''OTHERS'',''10'',''LATE EISSUANCE'',''13'',''FMMD'',''14'',''TMB PENDING REPATRIATION'',''15'',''TMB REPATRIATION'',''16'',''PENDING REPATRIATION (SB-F)'',''17'',''REPATRIATION (SB-F)'') vSPExtensionPurpose,B.vIssueSystem,B.vSPActualDepartDate,B.vSPStatus,DECODE(B.vSPIssuePurpose,''1'',''WICB'',''2'',''RE-APPLICATION'',''3'',''POLICE'',''4'',''REPATRIATION'',''5'',''LRD'',''6'',''LATE
RENEWAL'',''9'',''OTHERS'',''10'',''LATE EISSUANCE'',''11'',''PENDING DOCUMENT VERIFICATION'',''12'',''LATE ERENEWAL'',''13'',''FMMD'',''14'',''TMB PENDING REPATRIATION'',''15'',''TMB REPATRIATION'',''16'',''PENDING REPATRIATION (SB-F)'',''17'',''REPATRIATION
(SB-F)'') vSPIssuePurpose FROM (SELECT vSPWPNO,vFIN,vSPPassportNo,vSPIssueDate,vSPExpiryDate,vSPNo,vSPExtensionPurpose,vIssueSystem,vSPActualDepartDate,vSPStatus,vSPIssuePurpose FROM TABLE(IOSH_WIC_EXT_INTERFACE_PKG.getIWPSDepartedSpecialPass(''' || vRepatriationDateFrom
|| ''', ''' || vRepatriationDateTo || ''')) WHERE (vSPWPNO IS NOT NULL OR vFIN IS NOT NULL)) B JOIN (SELECT WC.CLAIM_ID CLAIM_ID, WC.CLAIM_REF_NO CLAIM_REF_NO, WC.STATUS STATUS,WC.SUB_STATUS SUB_STATUS, TAS.LAST_NAME ||'' ''|| TAS.FIRST_NAME OFFICER_NAME,
to_char(trunc(IRN.SUBMIT_DT), ''dd/MM/yyyy'') SUBMIT_DT,TO_CHAR(trunc(decode(wc.assessmt_type,''OD-PI'',EV.OD_CONSULT_DT,''OD-TI'',ev.od_consult_dt,ECASE.acc_dt)), ''dd/MM/yyyy'') ACC_DT, (SELECT TO_CHAR(MAX(WCS.STATUS_START_DT), ''dd/MM/yyyy'') STATUS_LAST_UPDATE_DATE
FROM WIC_CLAIM_STATUS WCS WHERE WCS.CLAIM_ID=WC.CLAIM_ID) vLatestUpdatedDate, EC.INDUSTRY_CODE INDUSTRY_CODE, EP.ID_NO ID_NO, EP.NAME vWorkerName FROM EVENT_PERSON EP, WIC_CLAIMS WC, TBL_AA_SUBJECT TAS, EVENT_COMPANY EC,EVENT_CASE ECASE, IR_NOTIFICATION IRN,event_victim
ev WHERE EP.ID_NO IS NOT NULL AND EP.DELETE_IND = ''F'' AND EP.INVOLVEMENT = ''VICTIM'' AND WC.EVENT_CASE_NO = EP.EVENT_CASE_NO AND WC.EVENT_PERSON_ID = EP.EVENT_PERSON_ID and ep.event_person_id = ev.event_person_id (+) AND WC.ASSIGN_OFFICER_ID = TAS.SUBJECT_ID
AND EC.EVENT_CASE_NO=WC.EVENT_CASE_NO AND EC.INVOLVEMENT in (''EMPLOYER'',''EMPLOYER_OCCUPIER'') AND ECASE.EVENT_CASE_NO=WC.EVENT_CASE_NO AND IRN.REF_NO(+) = ECASE.IR_REF_NO AND IRN.SUBMIT_TYPE IN (''SI'',''SE'') AND EC.DELETE_IND = ''F'') A ON (B.vFIN = A.ID_NO
OR B.vSPPassportNo = A.ID_NO)';
SPECIAL_PASS_CASES_TBL tbl_special_pass_cases := tbl_special_pass_cases();
cursor sp_pass_settle_cur is
SELECT DISTINCT (A.CLAIM_ID),
A.CLAIM_REF_NO,
A.STATUS,
A.SUB_STATUS,
A.OFFICER_NAME,
A.SUBMIT_DT,
A.ACC_DT,
A.vLatestUpdatedDate,
A.INDUSTRY_CODE,
A.ID_NO,
A.vWorkerName,
B.vSPWPNO,
B.vFIN,
B.vSPPassportNo,
B.vSPIssueDate,
B.vSPExpiryDate,
B.vSPNo,
DECODE(B.vSPExtensionPurpose,
'1',
'WICB',
'2',
'RE - APPLICATION',
'3',
'POLICE',
'4',
'REPATRIATION',
'5',
'LRD',
'6',
'LATE RENEWAL',
'9',
'OTHERS',
'10',
'LATE EISSUANCE',
'13',
'FMMD',
'14',
'TMB PENDING REPATRIATION',
'15',
'TMB REPATRIATION',
'16',
'PENDING REPATRIATION(SB - F)',
'17',
'REPATRIATION(SB - F)') vSPExtensionPurpose,
B.vIssueSystem,
B.vSPActualDepartDate,
B.vSPStatus,
DECODE(B.vSPIssuePurpose,
'1',
'WICB',
'2',
'RE - APPLICATION',
'3',
'POLICE',
'4',
'REPATRIATION',
'5',
'LRD',
'6',
'LATE RENEWAL',
'9',
'OTHERS',
'10',
'LATE EISSUANCE',
'11',
'PENDING DOCUMENT VERIFICATION',
'12',
'LATE ERENEWAL',
'13',
'FMMD',
'14',
'TMB PENDING REPATRIATION',
'15',
'TMB REPATRIATION',
'16',
'PENDING REPATRIATION(SB - F)',
'17',
'REPATRIATION(SB - F)') vSPIssuePurpose
FROM (SELECT vSPWPNO,
vFIN,
vSPPassportNo,
vSPIssueDate,
vSPExpiryDate,
vSPNo,
vSPExtensionPurpose,
vIssueSystem,
vSPActualDepartDate,
vSPStatus,
vSPIssuePurpose
FROM TABLE(IOSH_WIC_EXT_INTERFACE_PKG.getIWPSActiveSpecialPass)
WHERE (vSPWPNO IS NOT NULL OR vFIN IS NOT NULL)) B
JOIN (SELECT WC.CLAIM_ID CLAIM_ID,
WC.CLAIM_REF_NO CLAIM_REF_NO,
WC.STATUS STATUS,
WC.SUB_STATUS SUB_STATUS,
TAS.LAST_NAME ||''|| TAS.FIRST_NAME OFFICER_NAME,
'' SUBMIT_DT,
TO_CHAR(trunc(decode(wc.assessmt_type,
'OD-PI',
EV.OD_CONSULT_DT,
'OD-TI',
ev.od_consult_dt,
ECASE.acc_dt)),
'dd/MM/yyyy') ACC_DT,
(SELECT TO_CHAR(MAX(WCS.STATUS_START_DT), 'dd/MM/yyyy') STATUS_LAST_UPDATE_DATE
FROM WIC_CLAIM_STATUS WCS
WHERE WCS.CLAIM_ID = WC.CLAIM_ID) vLatestUpdatedDate,
EC.INDUSTRY_CODE INDUSTRY_CODE,
EP.ID_NO ID_NO,
EP.NAME vWorkerName
FROM EVENT_PERSON EP,
WIC_CLAIMS WC,
TBL_AA_SUBJECT TAS,
EVENT_COMPANY EC,
EVENT_CASE ECASE,
event_victim ev
WHERE EP.ID_NO IS NOT NULL
AND EP.DELETE_IND = 'F'
AND EP.INVOLVEMENT = 'VICTIM'
AND WC.EVENT_CASE_NO = EP.EVENT_CASE_NO
AND WC.EVENT_PERSON_ID = EP.EVENT_PERSON_ID
AND ep.event_person_id = ev.event_person_id(+)
AND WC.ASSIGN_OFFICER_ID = TAS.SUBJECT_ID
AND EC.EVENT_CASE_NO = WC.EVENT_CASE_NO
AND EC.INVOLVEMENT in ('EMPLOYER', 'EMPLOYER_OCCUPIER')
AND ECASE.EVENT_CASE_NO = WC.EVENT_CASE_NO
AND EC.DELETE_IND = 'F') A ON (B.vFIN = A.ID_NO OR B.vSPPassportNo = A.ID_NO);
sp_pass_settle_rec sp_pass_settle_cur%rowtype;
cursor sp_details_with_dt_cur is
SELECT DISTINCT (A.CLAIM_ID),
A.CLAIM_REF_NO,
A.STATUS,
A.SUB_STATUS,
A.OFFICER_NAME,
A.SUBMIT_DT,
A.ACC_DT,
A.vLatestUpdatedDate,
A.INDUSTRY_CODE,
A.ID_NO,
A.vWorkerName,
B.vSPWPNO,
B.vFIN,
B.vSPPassportNo,
B.vSPIssueDate,
B.vSPExpiryDate,
B.vSPNo,
DECODE(B.vSPExtensionPurpose,'1','WICB', '2','RE - APPLICATION','3','POLICE','4','REPATRIATION','5','LRD','6','LATE RENEWAL','9','OTHERS','10','LATE EISSUANCE',
'13','FMMD','14','TMB PENDING REPATRIATION','15','TMB REPATRIATION','16','PENDING REPATRIATION(SB - F)','17','REPATRIATION(SB
- F)') vSPExtensionPurpose,
B.vIssueSystem,
B.vSPActualDepartDate,
B.vSPStatus,
DECODE(B.vSPIssuePurpose,
'1','WICB','2','RE - APPLICATION','3','POLICE','4','REPATRIATION','5','LRD','6','LATE RENEWAL','9','OTHERS', '10', 'LATE EISSUANCE','11','PENDING
DOCUMENT VERIFICATION',
'12','LATE ERENEWAL','13','FMMD','14','TMB PENDING REPATRIATION','15','TMB REPATRIATION','16','PENDING REPATRIATION(SB - F)','17','REPATRIATION(SB
- F)') vSPIssuePurpose
FROM (SELECT vSPWPNO,
vFIN,
vSPPassportNo,
vSPIssueDate,
vSPExpiryDate,
vSPNo,
vSPExtensionPurpose,
vIssueSystem,
vSPActualDepartDate,
vSPStatus,
vSPIssuePurpose
FROM TABLE(IOSH_WIC_EXT_INTERFACE_PKG.getIWPSDepartedSpecialPass(''|| vRepatriationDateFrom ||'', ''|| vRepatriationDateTo ||''))
WHERE (vSPWPNO IS NOT NULL OR vFIN IS NOT NULL)) B
JOIN (SELECT WC.CLAIM_ID CLAIM_ID,
WC.CLAIM_REF_NO CLAIM_REF_NO,
WC.STATUS STATUS,
WC.SUB_STATUS SUB_STATUS,
TAS.LAST_NAME ||''|| TAS.FIRST_NAME OFFICER_NAME,
to_char(trunc(IRN.SUBMIT_DT), 'dd/MM/yyyy') SUBMIT_DT,
TO_CHAR(trunc(decode(wc.assessmt_type,
'OD - PI',
EV.OD_CONSULT_DT,
'OD - TI',
ev.od_consult_dt,
ECASE.acc_dt)),
'dd/MM/yyyy') ACC_DT,
(SELECT TO_CHAR(MAX(WCS.STATUS_START_DT), 'dd/MM/yyyy') STATUS_LAST_UPDATE_DATE
FROM WIC_CLAIM_STATUS WCS
WHERE WCS.CLAIM_ID = WC.CLAIM_ID) vLatestUpdatedDate,
EC.INDUSTRY_CODE INDUSTRY_CODE,
EP.ID_NO ID_NO,
EP.NAME vWorkerName
FROM EVENT_PERSON EP,
WIC_CLAIMS WC,
TBL_AA_SUBJECT TAS,
EVENT_COMPANY EC,
EVENT_CASE ECASE,
IR_NOTIFICATION IRN,
event_victim ev
WHERE EP.ID_NO IS NOT NULL
AND EP.DELETE_IND = 'F'
AND EP.INVOLVEMENT = 'VICTIM'
AND WC.EVENT_CASE_NO = EP.EVENT_CASE_NO
AND WC.EVENT_PERSON_ID = EP.EVENT_PERSON_ID
and ep.event_person_id = ev.event_person_id(+)
AND WC.ASSIGN_OFFICER_ID = TAS.SUBJECT_ID
AND EC.EVENT_CASE_NO = WC.EVENT_CASE_NO
AND EC.INVOLVEMENT in ('EMPLOYER', 'EMPLOYER_OCCUPIER')
AND ECASE.EVENT_CASE_NO = WC.EVENT_CASE_NO
AND IRN.REF_NO(+) = ECASE.IR_REF_NO
AND IRN.SUBMIT_TYPE IN ('SI', 'SE')
AND EC.DELETE_IND = 'F') A ON (B.vFIN = A.ID_NO OR B.vSPPassportNo = A.ID_NO);
sp_details_with_dt_rec sp_details_with_dt_cur%rowtype;
/*vSQL VARCHAR2(4000);
vFIN VARCHAR2(9);
vSPPassportNo VARCHAR2(16);
vSPWPNO VARCHAR2(20);
vSPIssueDate VARCHAR2(10);
vSPExpiryDate VARCHAR2(10);
vSPNo VARCHAR2(20);
vSPExtensionPurpose VARCHAR2(100);
vIssueSystem VARCHAR2(4);
vSPActualDepartDate VARCHAR2(10);
vSPStatus VARCHAR2(30);
vSPIssuePurpose VARCHAR2(500);
CLAIM_ID NUMBER(12);
CLAIM_REF_NO VARCHAR2(20);
STATUS VARCHAR2(30);
SUB_STATUS VARCHAR2(30);
OFFICER_NAME VARCHAR2(201);
SUBMIT_DT VARCHAR2(10);
ACC_DT VARCHAR2(10);
vLatestUpdatedDate VARCHAR2(10);
INDUSTRY_CODE VARCHAR2(8);
ID_NO VARCHAR2(50);
vWorkerName VARCHAR2(100);*/
BEGIN
if vIncludeRepatriationDate = 'Y' then
for sp_details_with_dt_rec in sp_details_with_dt_cur
loop
SPECIAL_PASS_CASES_TBL.EXTEND;
SPECIAL_PASS_CASES_TBL(SPECIAL_PASS_CASES_TBL.LAST) := obj_special_pass_cases(sp_details_with_dt_rec.CLAIM_ID,sp_details_with_dt_rec.CLAIM_REF_NO,sp_details_with_dt_rec.OFFICER_NAME,sp_details_with_dt_rec.SUBMIT_DT,sp_details_with_dt_rec.ACC_DT,sp_details_with_dt_rec.vSPIssueDate,sp_details_with_dt_rec.STATUS,sp_details_with_dt_rec.SUB_STATUS,sp_details_with_dt_rec.vLatestUpdatedDate,sp_details_with_dt_rec.vSPExpiryDate,sp_details_with_dt_rec.INDUSTRY_CODE,sp_details_with_dt_rec.INDUSTRY_CODE,'a',sp_details_with_dt_rec.vSPWPNO,sp_details_with_dt_rec.vFIN,sp_details_with_dt_rec.vSPPassportNo,sp_details_with_dt_rec.vSPNo,sp_details_with_dt_rec.vWorkerName,sp_details_with_dt_rec.vSPExtensionPurpose,sp_details_with_dt_rec.vIssueSystem,sp_details_with_dt_rec.vSPActualDepartDate,sp_details_with_dt_rec.vSPStatus,sp_details_with_dt_rec.vSPIssuePurpose);
end loop;
else
for sp_pass_settle_rec in sp_pass_settle_cur
loop
SPECIAL_PASS_CASES_TBL.EXTEND;
SPECIAL_PASS_CASES_TBL(SPECIAL_PASS_CASES_TBL.LAST) := obj_special_pass_cases(sp_pass_settle_rec.CLAIM_ID,sp_pass_settle_rec.CLAIM_REF_NO,sp_pass_settle_rec.OFFICER_NAME,sp_pass_settle_rec.SUBMIT_DT,sp_pass_settle_rec.ACC_DT,sp_pass_settle_rec.vSPIssueDate,sp_pass_settle_rec.STATUS,sp_pass_settle_rec.SUB_STATUS,sp_pass_settle_rec.vLatestUpdatedDate,sp_pass_settle_rec.vSPExpiryDate,sp_pass_settle_rec.INDUSTRY_CODE,sp_pass_settle_rec.INDUSTRY_CODE,'a',sp_pass_settle_rec.vSPWPNO,sp_pass_settle_rec.vFIN,sp_pass_settle_rec.vSPPassportNo,sp_pass_settle_rec.vSPNo,sp_pass_settle_rec.vWorkerName,sp_pass_settle_rec.vSPExtensionPurpose,sp_pass_settle_rec.vIssueSystem,sp_pass_settle_rec.vSPActualDepartDate,sp_pass_settle_rec.vSPStatus,sp_pass_settle_rec.vSPIssuePurpose);
end loop;
end if ;
RETURN SPECIAL_PASS_CASES_TBL;
END getListOfSpecialPassCases;
Thanks,
SS -
Need help with BC4J/Struts application using a Stored Procedure
Hi,
I am doing a proof of concept for a new project using JDeveloper, Struts and BC4J. We want to reuse our Business logic that is currently residing in Oracle Stored Procedures. I previously created a BC4J Entity Object based on a stored procedure Using Oracle Stored Procedures but this stored procedure is a bit different in that it returns a ref cursor as one of the paramters. http://radio.weblogs.com/0118231/stories/2003/03/03/gettingAViewObjectsResultRowsFromARefCursor.html
I tried the above method, but I am having some trouble with it. I keep getting the error ORA-01008: not all variables are bound when I test it using the AppModule tester.
Here is the store procedure definition:
CREATE OR REPLACE PACKAGE pprs_test_wrappers IS
TYPE sn_srch_results IS REF CURSOR;
PROCEDURE sn_srch_main_test
(serial_num_in IN OUT VARCHAR2
,serial_coll_cd_in IN OUT NUMBER
,max_rows_allowed IN OUT NUMBER
,total_rows_selected IN OUT NUMBER
,message_cd_out IN OUT VARCHAR2
,query_results OUT sn_srch_results
END pprs_test_wrappers;
And here is my code:
package pprs;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import oracle.jbo.JboException;
import oracle.jbo.domain.Number;
import oracle.jbo.server.DBTransaction;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.server.ViewRowImpl;
import oracle.jbo.server.ViewRowSetImpl;
import oracle.jdbc.driver.OracleCallableStatement;
import oracle.jdbc.driver.OracleTypes;
// --- File generated by Oracle Business Components for Java.
public class LienCheckImpl extends ViewObjectImpl
* This is the PLSQL block that we will execute to retrieve the REF CURSOR
private static final String SQL =
"begin ? := pprs_test_wrappers.sn_srch_main_test(?, ?, ?, ?, ?, ?);end;";
public LienCheckImpl() {}
* Overridden framework method.
* Executed when the framework needs to issue the database query for
* the query collection based on this view object. One view object
* can produce many related result sets, each potentially the result
* of different bind variable values. If the rowset in query is involved
* in a framework-coordinated master/detail viewlink, then the params array
* will contain one or more framework-supplied bind parameters. If there
* are any user-supplied bind parameter values, they will PRECEED the
* framework-supplied bind variable values in the params array, and the
* number of user parameters will be indicated by the value of the
* numUserParams argument.
protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
* If there are where-clause params (for example due to a view link)
* they will be in the 'params' array.
* We assume that if some parameter is present, that it is a Deptno
* value to pass as an argument to the stored procedure.
* NOTE: Due to Bug#2828248 I have to cast to BigDecimal for now,
* ---- but this parameter value should be oracle.jbo.domain.Number type.
String serialNumIn = null;
BigDecimal serialCollCdIn = null;
BigDecimal maxRowsAllowed = null;
BigDecimal totalRowsSelected = null;
String messageCdOut = null;
if (params != null) {
serialNumIn = (String)params[0];
serialCollCdIn = (BigDecimal)params[1];
maxRowsAllowed = (BigDecimal)params[2];
totalRowsSelected = (BigDecimal)params[3];
messageCdOut = (String)params[4];
storeNewResultSet(qc,retrieveRefCursor(qc,serialNumIn,
serialCollCdIn,
maxRowsAllowed,
totalRowsSelected,
messageCdOut));
super.executeQueryForCollection(qc, params, numUserParams);
* Overridden framework method.
* Wipe out all traces of a built-in query for this VO
protected void create() {
getViewDef().setQuery(null);
getViewDef().setSelectClause(null);
setQuery(null);
* Overridden framework method.
* The role of this method is to "fetch", populate, and return a single row
* from the datasource by calling createNewRowForCollection() and populating
* its attributes using populateAttributeForRow().
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
* We ignore the JDBC ResultSet passed by the framework (null anyway) and
* use the resultset that we've stored in the query-collection-private
* user data storage
rs = getResultSet(qc);
* Create a new row to populate
ViewRowImpl r = createNewRowForCollection(qc);
try {
* Populate new row by attribute slot number for current row in Result Set
populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
populateAttributeForRow(r,1, nullOrNewNumber(rs.getBigDecimal(2)));
populateAttributeForRow(r,2, rs.getString(3));
populateAttributeForRow(r,3, rs.getString(4));
populateAttributeForRow(r,4, rs.getString(5));
catch (SQLException s) {
throw new JboException(s);
return r;
* Overridden framework method.
* Return true if the datasource has at least one more record to fetch.
protected boolean hasNextForCollection(Object qc) {
ResultSet rs = getResultSet(qc);
boolean nextOne = false;
try {
nextOne = rs.next();
* When were at the end of the result set, mark the query collection
* as "FetchComplete".
if (!nextOne) {
setFetchCompleteForCollection(qc, true);
* Close the result set, we're done with it
rs.close();
catch (SQLException s) {
throw new JboException(s);
return nextOne;
* Overridden framework method.
* The framework gives us a chance to clean up any resources related
* to the datasource when a query collection is done being used.
protected void releaseUserDataForCollection(Object qc, Object rs) {
* Ignore the ResultSet passed in since we've created our own.
* Fetch the ResultSet from the User-Data context instead
ResultSet userDataRS = getResultSet(qc);
if (userDataRS != null) {
try {
userDataRS.close();
catch (SQLException s) {
/* Ignore */
super.releaseUserDataForCollection(qc, rs);
* Return a JDBC ResultSet representing the REF CURSOR return
* value from our stored package function.
private ResultSet retrieveRefCursor(Object qc,
String serialNum,
BigDecimal serialColCd,
BigDecimal maxRows,
BigDecimal totalRows,
String messageCd ) {
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
* Register the first bind parameter as our return value of type CURSOR
st.registerOutParameter(1,OracleTypes.CURSOR);
* Set the value of the 2nd bind variable to pass id as argument
if (serialNum == null) st.setNull(2,Types.CHAR);
else st.setString(2,serialNum);
if (serialColCd == null) st.setNull(3,Types.NUMERIC);
else st.setBigDecimal(3,serialColCd);
if (maxRows == null) st.setNull(4,Types.NUMERIC);
else st.setBigDecimal(4,maxRows);
if (totalRows == null) st.setNull(5,Types.NUMERIC);
else st.setBigDecimal(5,totalRows);
if (messageCd == null) st.setNull(6,Types.CHAR);
else st.setString(6,messageCd);
st.execute();
ResultSet rs = ((OracleCallableStatement)st).getCursor(1);
* Make this result set use the fetch size from our View Object settings
rs.setFetchSize(getFetchSize());
return rs ;
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Store a new result set in the query-collection-private user-data context
private void storeNewResultSet(Object qc, ResultSet rs) {
ResultSet existingRs = getResultSet(qc);
// If this query collection is getting reused, close out any previous rowset
if (existingRs != null) {
try {existingRs.close();} catch (SQLException s) {}
setUserDataForCollection(qc,rs);
hasNextForCollection(qc); // Prime the pump with the first row.
* Retrieve the result set wrapper from the query-collection user-data
private ResultSet getResultSet(Object qc) {
return (ResultSet)getUserDataForCollection(qc);
* Return either null or a new oracle.jbo.domain.Number
private static oracle.jbo.domain.Number nullOrNewNumber(BigDecimal b) {
try {
return b != null ? new oracle.jbo.domain.Number(b) : null;
catch (SQLException s) { }
return null;
I created the view object in expert mode so there is no entity object. Can someone help? I don't have much time left to finish this.
Also, could I have done this from the Entity object instead of the view object by registering the ref cursor OUT parameter in handleStoredProcInsert()?
Thanks
NatalieI was able to get the input parameter by putting the following in my struts actions class
vo.setWhereClauseParam(0,request.getParameter("row0_SerialNum"));
The full code is:
package mypackage2;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import oracle.jbo.html.BC4JContext;
import oracle.jbo.ViewObject;
import oracle.jbo.html.struts11.BC4JUtils;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LienCheckView1QueryAction extends Action
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
BC4JContext context = BC4JContext.getContext(request);
// Retrieve the view object instance to work with by name
ViewObject vo = context.getApplicationModule().findViewObject("LienCheckView1");
vo.setRangeSize(3);
vo.setIterMode(ViewObject.ITER_MODE_LAST_PAGE_PARTIAL);
// Do any additional VO setup here (e.g. setting bind parameter values)
vo.setWhereClauseParam(0,request.getParameter("row0_SerialNum"));
// default value for serialCollCd 1 is for Motor Vehicles
vo.setWhereClauseParam(1,new oracle.jbo.domain.Number(1));
// Default value for maxRows_allowed
vo.setWhereClauseParam(2,new oracle.jbo.domain.Number(20));
return BC4JUtils.getForwardFromContext(context, mapping);
This doesn't always work properly though. The first time I press the query button, the SerialNum parameter is still null, however if I re-execute the query by pressing the query button again. It will work, and return the rows. I always have to query twice. Also the SerialNum attribute is set to a String in my view object, it is a varchar column in the database, but some serial number I enter give a "Error Message: oracle.jbo.domain.Number ". This happens even though the underlying BC4J is returning values for the query. I also get a "500 Internal Server Error java.lang.ClassCastException: java.lang.String on my View object's code at line 65 which is
if (params.length>1) serialCollCdIn = (BigDecimal)params[1];
This is an input paramter to the oracle stored procedure that defaults to a Number value of 1.
Any idea what the problem is? Here is the full code for my view object:
package mypackage1;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import oracle.jbo.JboException;
import oracle.jbo.domain.Number;
import oracle.jbo.server.DBTransaction;
import oracle.jbo.server.ViewObjectImpl;
import oracle.jbo.server.ViewRowImpl;
import oracle.jbo.server.ViewRowSetImpl;
import oracle.jdbc.driver.OracleCallableStatement;
import oracle.jdbc.driver.OracleTypes;
// --- File generated by Oracle Business Components for Java.
public class LienCheckViewImpl extends ViewObjectImpl
* This is the PLSQL block that we will execute to retrieve the REF CURSOR
private static final String SQL =
"begin pprs_test_wrappers.sn_srch_main_test(?, ?, ?, ?, ?, ?);end;";
private BigDecimal totalRows = null;
private String messageCd = null;
private BigDecimal serialColCd = null;
private BigDecimal maxRows = null;
public LienCheckViewImpl() {}
* Overridden framework method.
* Executed when the framework needs to issue the database query for
* the query collection based on this view object. One view object
* can produce many related result sets, each potentially the result
* of different bind variable values. If the rowset in query is involved
* in a framework-coordinated master/detail viewlink, then the params array
* will contain one or more framework-supplied bind parameters. If there
* are any user-supplied bind parameter values, they will *PRECEED* the
* framework-supplied bind variable values in the params array, and the
* number of user parameters will be indicated by the value of the
* numUserParams argument.
protected void executeQueryForCollection(Object qc,Object[] params,int numUserParams) {
* If there are where-clause params (for example due to a view link)
* they will be in the 'params' array.
* We assume that if some parameter is present, that it is a Deptno
* value to pass as an argument to the stored procedure.
* NOTE: Due to Bug#2828248 I have to cast to BigDecimal for now,
* ---- but this parameter value should be oracle.jbo.domain.Number type.
String serialNumIn = null;
BigDecimal serialCollCdIn = null;
BigDecimal maxRowsAllowed = null;
BigDecimal totalRowsSelected = null;
String messageCdOut = null;
if (params != null) {
if (params.length>0) serialNumIn = (String)params[0];
if (params.length>1) serialCollCdIn = (BigDecimal)params[1];
if (params.length>2) maxRowsAllowed = (BigDecimal)params[2];
storeNewResultSet(qc,retrieveRefCursor(qc,serialNumIn,
serialCollCdIn,
maxRowsAllowed));
super.executeQueryForCollection(qc, params, numUserParams);
* Overridden framework method.
* Wipe out all traces of a built-in query for this VO
protected void create() {
getViewDef().setQuery(null);
getViewDef().setSelectClause(null);
setQuery(null);
* Overridden framework method.
* The role of this method is to "fetch", populate, and return a single row
* from the datasource by calling createNewRowForCollection() and populating
* its attributes using populateAttributeForRow().
protected ViewRowImpl createRowFromResultSet(Object qc, ResultSet rs) {
* We ignore the JDBC ResultSet passed by the framework (null anyway) and
* use the resultset that we've stored in the query-collection-private
* user data storage
rs = getResultSet(qc);
* Create a new row to populate
ViewRowImpl r = createNewRowForCollection(qc);
try {
* Populate new row by attribute slot number for current row in Result Set
//AddedByRegisNum
populateAttributeForRow(r,0, nullOrNewNumber(rs.getBigDecimal(1)));
System.out.println("AddedByRegisNum :" + rs.getBigDecimal(1));
// OrigRegisNum
populateAttributeForRow(r,1, nullOrNewNumber(rs.getBigDecimal(2)));
System.out.println("OrigRegisNum :" + rs.getBigDecimal(2));
// SerialNum
populateAttributeForRow(r,2, rs.getString(3));
System.out.println("SerialNum :" + rs.getString(3));
// SerialNumDesc
populateAttributeForRow(r,3, rs.getString(4));
System.out.println("SerialNumDesc :" + rs.getString(4));
// FlagExactMatch
populateAttributeForRow(r,4, rs.getString(5));
System.out.println("FlagExactMatch :" + rs.getString(5));
// MessageCd
populateAttributeForRow(r,5, messageCd);
// TotalRows
populateAttributeForRow(r,6, totalRows);
catch (SQLException s) {
throw new JboException(s);
return r;
* Overridden framework method.
* Return true if the datasource has at least one more record to fetch.
protected boolean hasNextForCollection(Object qc) {
ResultSet rs = getResultSet(qc);
boolean nextOne = false;
try {
nextOne = rs.next();
* When were at the end of the result set, mark the query collection
* as "FetchComplete".
if (!nextOne) {
setFetchCompleteForCollection(qc, true);
* Close the result set, we're done with it
rs.close();
catch (SQLException s) {
throw new JboException(s);
return nextOne;
* Overridden framework method.
* The framework gives us a chance to clean up any resources related
* to the datasource when a query collection is done being used.
protected void releaseUserDataForCollection(Object qc, Object rs) {
* Ignore the ResultSet passed in since we've created our own.
* Fetch the ResultSet from the User-Data context instead
ResultSet userDataRS = getResultSet(qc);
if (userDataRS != null) {
try {
userDataRS.close();
catch (SQLException s) {
/* Ignore */
super.releaseUserDataForCollection(qc, rs);
* Overridden framework method
* Return the number of rows that would be returned by executing
* the query implied by the datasource. This gives the developer a
* chance to perform a fast count of the rows that would be retrieved
* if all rows were fetched from the database. In the default implementation
* the framework will perform a SELECT COUNT(*) FROM (...) wrapper query
* to let the database return the count. This count might only be an estimate
* depending on how resource-intensive it would be to actually count the rows.
public long getQueryHitCount(ViewRowSetImpl viewRowSet) {
Object[] params = viewRowSet.getParameters(true);
String serialNumIn = (String)params[0];
BigDecimal serialCollCdIn = (BigDecimal)params[1];
BigDecimal maxRowsAllowed = (BigDecimal)params[2];
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
* Register the fourth bind parameter as our return value of type NUMERIC
st.registerOutParameter(4,Types.NUMERIC);
* Set the value of the 3 bind variables to pass as arguments
if (serialNumIn == null) st.setNull(1, Types.CHAR);
else st.setString(1,serialNumIn);
if (serialCollCdIn == null) st.setNull(2,Types.NUMERIC);
else st.setBigDecimal(2,serialCollCdIn);
if (maxRowsAllowed == null) st.setNull(3, Types.NUMERIC);
else st.setBigDecimal(3, maxRowsAllowed);
st.execute();
System.out.println("returning value of :" + st.getLong(4));
return st.getLong(4);
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Return a JDBC ResultSet representing the REF CURSOR return
* value from our stored package function.
private ResultSet retrieveRefCursor(Object qc,
String serialNum,
BigDecimal serialColCd,
BigDecimal maxRows) {
CallableStatement st = null;
try {
st = getDBTransaction().createCallableStatement(SQL,DBTransaction.DEFAULT);
* Set the value of the bind variables
System.out.println("SerialNumIn :" + serialNum);
if (serialNum == null) st.setNull(1,Types.CHAR);
else st.setString(1,serialNum);
if (serialColCd == null) st.setNull(2,Types.NUMERIC);
else st.setBigDecimal(2,serialColCd);
if (maxRows == null) st.setNull(3,Types.NUMERIC);
else st.setBigDecimal(3,maxRows);
st.registerOutParameter(1, Types.CHAR); // serialNum
st.registerOutParameter(2, Types.NUMERIC); // serialColCd
st.registerOutParameter(3, Types.NUMERIC); // maxRows
st.registerOutParameter(4, Types.NUMERIC); // totalRows
st.registerOutParameter(5, Types.CHAR); // messageCd
* Register the 6th bind parameter as our return value of type CURSOR
st.registerOutParameter(6,OracleTypes.CURSOR);
st.execute();
ResultSet rs = ((OracleCallableStatement)st).getCursor(6);
serialColCd = st.getBigDecimal(2);
System.out.println("SerialColCd= " + serialColCd);
maxRows = st.getBigDecimal(3);
System.out.println("maxRows= " + maxRows);
totalRows = st.getBigDecimal(4);
System.out.println("totalRows= " + totalRows);
messageCd = st.getString(5);
System.out.println("messageCd= " + messageCd);
* Make this result set use the fetch size from our View Object settings
rs.setFetchSize(getFetchSize());
return rs ;
catch (SQLException s) {
throw new JboException(s);
finally {try {st.close();} catch (SQLException s) {}}
* Store a new result set in the query-collection-private user-data context
private void storeNewResultSet(Object qc, ResultSet rs) {
ResultSet existingRs = getResultSet(qc);
// If this query collection is getting reused, close out any previous rowset
if (existingRs != null) {
try {existingRs.close();} catch (SQLException s) {}
setUserDataForCollection(qc,rs);
hasNextForCollection(qc); // Prime the pump with the first row.
* Retrieve the result set wrapper from the query-collection user-data
private ResultSet getResultSet(Object qc) {
return (ResultSet)getUserDataForCollection(qc);
* Return either null or a new oracle.jbo.domain.Number
private static oracle.jbo.domain.Number nullOrNewNumber(BigDecimal b) {
try {
return b != null ? new oracle.jbo.domain.Number(b) : null;
catch (SQLException s) { }
return null;
Natalie -
Oracle Stored Procedure not working
Hi Guy's,
I want to connect directly from Visual Composer to Oracle Database 10.2.x.x using Oracle Stored Procedure and JDBC System to demonstrate how easy you can show data vith VC. So I have created a simple Oracle Stored Procedure, a JDBC System with a valid alias, User mapping (Portal User --> Oracle User).
When I invoke the stored procedure I receive the following error: "Portal request Failed (Could not execute stored procedure)". The Stored Procedure is working fine in Oracle iSQL*Plus.
Any idea's?
Thanks,
RidouanHi,
did you use the portal JDBC as it is described here:
<a href="https://wiki.sdn.sap.com/wiki/display/VC/Cannotseetables">https://wiki.sdn.sap.com/wiki/display/VC/Cannotseetables</a>
Best Regards,
Marcel -
Oracle stored procedure VS TOOL
We are interested in having feedback on the possibility of using Oracle
stored procedure versus TOOL code to perform db access ( typically, you can
provide a stored procedure that implements a SO method ).
In particular we are working on several project with relational db and
Oracle DBMS is our choice since years. So there is no need to evolving to
other dbms.
Using oracle stored procedure, by including some logic in the db, could be
a way to reuse logic in other other context, where Fortè is not used.
I would really appreciate any comments about this topic ( advantages &
drawbacks )
Thanks
FabrizioWe are interested in having feedback on the possibility of using Oracle
stored procedure versus TOOL code to perform db access ( typically, you can
provide a stored procedure that implements a SO method ).
In particular we are working on several project with relational db and
Oracle DBMS is our choice since years. So there is no need to evolving to
other dbms.
Using oracle stored procedure, by including some logic in the db, could be
a way to reuse logic in other other context, where Fortè is not used.
I would really appreciate any comments about this topic ( advantages &
drawbacks )
Thanks
Fabrizio -
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 -
How to use a stored procedure in oracle reports
How to use a stored procedure in oracle reports
Dear,
In report triggers you can write your procedure/functions or call it like
function AfterPForm return boolean is
begin
myprocedure(:mydate);
return (TRUE);
end;
Thanks
Jamil
Maybe you are looking for
-
How does I read a HWS file that contains 2 traces, in labview? (error -21508)
Dear experts, I have been using a PXI-5105 acquisition card to save data from 2 channels at the same time (coming from different sensors). Up to now I have been reading the files in Matlab, taking into consideration the group name, the trace name and
-
So starting around December, my ipod would be so difficult to connect. When I'm trying to charge it and I move my ipod, it would unconnect and reconnect even though the wire is still attached to the ipod. I thought it was an ipod wire problem so I bo
-
How do i set up photoshop to open when i connect my iphone
It used to be when I connected my iphone to backup to my pc that photoshop would open to store new photos. But since the last firmware update that does not happen. What preference do i have to check so that it does that it opens photoshop again?
-
What's the URL for a tabbed panel?
I posted this question last week to a topic that I think now must have been abandoned, so I'm giving it another try as a fresh topic. I've read everything in the Forums thus far posted about linking to a non-default tab in a tabbed panel. But even af
-
Spry navbar position with other page elements.
2 questions on positioning a horizontal navbar with other page elements. 1.) I replaced a standard horizontal navbar with a spry horizontal bar. Below the navbar is a simple image div- centering an image on the page. The image is placed with auto ma