Oracle stored Procedure and Packages in CR4E
Hi,
I want to use Stored Procedure in CR4E. I don't know how to use Stored Procedures and packages in Crystal Reports for Eclipse. In the data source explorer I can only see the Tables, Views and Stored Procedures but not packages from my Schema and when I can only drag & drop the Tables and Views into the Field Explorer, I can't drag & Drop the Stored Procedures.
I managed to attached the stored procedure from CR studio. I opened the report in CR4E and I can see the stored procedure and can preview the data. When I try to run the report and override the datasource, it throws oracle error saying "ORA-01008: Not all variables bound". When I tried to use the option
DBOptions._doNotVerifyDB
while replacing connection I get the this error
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
at java.lang.Boolean.compareTo(Boolean.java:26)
at com.crystaldecisions.sdk.occa.report.lib.ClonableMap.hasContent(ClonableMap.java:112)
at com.crystaldecisions.client.helper.CloneUtil.hasContent(CloneUtil.java:135)
at com.crystaldecisions.sdk.occa.report.data.ConnectionInfo.hasContent(SourceFile:151)
at com.crystaldecisions.client.helper.CloneUtil.hasContent(CloneUtil.java:135)
at com.crystaldecisions.sdk.occa.report.data.Table.hasContent(SourceFile:286)
at com.crystaldecisions.sdk.occa.report.data.Procedure.hasContent(SourceFile:212)
at com.crystaldecisions.sdk.occa.report.lib.ArrayListMerger.haveMatchingContent(ArrayListMerger.java:232)
at com.crystaldecisions.sdk.occa.report.lib.ArrayListMerger.mergePass(ArrayListMerger.java:138)
at com.crystaldecisions.sdk.occa.report.lib.ArrayListMerger.merge(ArrayListMerger.java:86)
at com.crystaldecisions.sdk.occa.report.lib.ControllableList.copyTo(ControllableList.java:68)
at com.crystaldecisions.sdk.occa.report.data.Database.copyTo(SourceFile:105)
at com.crystaldecisions.sdk.occa.report.lib.ControllableHelper.copyToPreservingReferences(ControllableHelper.java:153)
at com.crystaldecisions.sdk.occa.report.application.ReportClientDocument.a(SourceFile:2556)
at com.crystaldecisions.sdk.occa.report.application.b9.onDataSourceChanging(SourceFile:315)
at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(SourceFile:971)
at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(SourceFile:4078)
at com.crystaldecisions.sdk.occa.report.application.bv.new(SourceFile:121)
at com.crystaldecisions.sdk.occa.report.application.bv.int(SourceFile:91)
at com.crystaldecisions.proxy.remoteagent.UndoUnitBase.performDo(SourceFile:151)
at com.crystaldecisions.proxy.remoteagent.UndoUnitBase.a(SourceFile:106)
at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(SourceFile:2159)
at com.crystaldecisions.sdk.occa.report.application.DatabaseController.mapFields(SourceFile:4061)
at com.crystaldecisions.sdk.occa.report.application.DatabaseController.a(SourceFile:3914)
at com.crystaldecisions.sdk.occa.report.application.DatabaseController.replaceConnection(SourceFile:3880)
at
Please advice if Stored procedures and packages are supported in CR4E ?
Hi, Jack76,
According to the [CR4E Release Notes|http://help.sap.com/businessobject/product_guides/cr4E/en/cr4e_relnotes_en.pdf] (available from the [CR4E Download page|http://www.businessobjects.com/campaigns/forms/downloads/crystal/eclipse/datasave.asp]), stored procedures are supported, as long as they don't use parameters that need null values.
I don't see any references to packages.
Bryan
Similar Messages
-
Administering Stored Procedures and Packages
I've read about WRAP utility but I don't know exactly what's it about. Here you are what ýI've read:ý
The code used to create the procedure ,package ,or function is available in the dictionary ýviews DBA_Source ,All_Source,and user_source except when you create them with the ýWRAP utility .the WRAP utility generates encrypted code, which only the Oracle server ýcan interpret .ý
does any one have any idea .
Thanks in advanceGenerally, one uses the WRAP utility when
- You are delivering code to a third party
- You want to ensure that the third party isn't able to decompile your code.
If you built a CRM application with stored procedures and packages and you started selling that commercially, for example, you would use the WRAP utility to ensure that competitors couldn't reverse engineer your code and see how you did things.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Calling an Oracle stored procedure and retrieving result from OUT parameter
Hello,
I have a stored procedure that returns a string in an OUT parameter after receiving 6 IN parameters. I have tested the procedure in PL/SQL and it's producing the right output there. The problem is when I call the stored procedure from my Java method. I then get an error message telling me that I have the wrong number or types of arguments in my procedure call. I have checked that the method receives and sends the correct data in the correct order and I'm not sure what else the error message can relate to...?
The exception is called on my second try statement but I haven't been able to find out what I have done wrong there. Does anyone have any suggestions? Thanks.
the error message
java.sql.SQLException: ORA-06550: line 1, column 13: PLS-00306: wrong number or types of arguments in call to 'P_SET_GIVEN_ANSWER' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
the procedure
CREATE OR REPLACE PROCEDURE p_set_given_answer(
strfeedback OUT VARCHAR2,
intpi_id IN INTEGER,
intquestion_id IN INTEGER,
intgivenanswer IN INTEGER,
strgivenprefix IN VARCHAR2,
strgivenunit IN VARCHAR2,
strgu_id IN VARCHAR2) AS
-- some declarations
BEGIN
-- some processing and then returns the string below indicating the outcome
strfeedback = 'result';
END
the java method (the class is called dbUtil and the database connection is created in the method called getDbConnection() )
public void setGivenAnswer(int intPi_id, int intQuestion_id, int intGivenAnswer, String strGu_id, String strGivenPrefix, String strGivenUnit) {
java.sql.Connection con = null;
String query = "{call ? := p_set_given_answer(?,?,?,?,?,?)}";
try {
con = dbUtil.getDbConnection();
} catch(Exception e) {
dbConnectionExceptionMessage = "error 1:"+e.toString();
try{
CallableStatement stmt = con.prepareCall(query);
// register the type of the out param - an Oracle specific type
stmt.registerOutParameter(1, OracleTypes.VARCHAR);
// set the in params
stmt.setInt(2, intPi_id);
stmt.setInt(3, intQuestion_id);
stmt.setInt(4, intGivenAnswer);
stmt.setString(5, strGivenPrefix);
stmt.setString(6, strGivenUnit);
stmt.setString(7, strGu_id);
// execute the stored procedure
stmt.execute();
// retrieve the results
strFeedback = stmt.getString(1);
} catch (java.sql.SQLException e) {
dbConnectionExceptionMessage = "error 2:"+e.toString();
try {
con.close();
} catch (java.sql.SQLException e) {
dbConnectionExceptionMessage = "error 3:"+e.toString();
----------------------------------------Looks like you are declaring a procedure, but you are calling it like a function. A procedure has no return value, it has only parameters: "{call p_set_given_answer(?,?,?,?,?,?,?)}"
-
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 -
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 -
Oracle stored procedure in a package
Hello,
I'm working on a Web service -> XI -> Oracle scenario.
In the receiver side I'm using JDBC Adapter to call to stored procedure.
I have stored procedure in a package.
For example: package "price_list_pk" and stored procedure "is_pl".
When I try to enter the stored procedure path to XML tags I need to separate between the package and the stored procedure with dot "." and dot is not allowed in XML tag.
I want to now if you have answer for this problem
Have other way to work with stored procedure in packages?
EladHey everyone,
What Elad means is that in the XML structure of JDBC there are 2 places you define the DB\SP name:
1. Defined in the structure itself as an element name. (DT)
2. Mapped with a constant to a subelement called TABLE. (MM)
The MM shouldn't be a problem as a value can get the dot character.
But, in the DT structure, because you define here a XSD (XML structure) there is a problem naming the element with the dot character being part of the name as this character is not accepted in a XML tagname.
The right question is if anyone knows of a special XML attribute with which you could define that the element name would contain a dot character? Or else a creative way to call a Stored Procedure inside a Package despite the disabilities above?
Ben -
Creating Sap Crystal Report Through Oracle Stored Procedure Packages
Hi,
1.How we can create crystal report through oracle stored
procedure packages pls tell me the steps through adding command then
tell me the syntax what should i write in command to call the stored
procedure packages or if have some other option then also tell.
2.can
we link stored procedure column to other table column that used in
report.Hi Ganesh,
As this error comes when you are trying to insert non-numeric value into a numeric column in db it seems that your field might be numeric and you are trying to send it as a string in database.
Please check your Store Proc carefully..
Reference Thread: Oracle/PLSQL: ORA-01722
--Dhana -
Difference between a "stored procedure" and a "procedure defined in package
Hi,
Is there any difference between a "stored procedure" and a "procedure defined in package"
thanks in advancehttp://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_packages.htm#sthref779
Steps
http://www.oracle.com/pls/db102/homepage
http://www.oracle.com/pls/db102/search?word=stored+procedure+package
5th result -
JDBC Thin-Driver and Oracle Stored Procedure
I've got a Oracle stored procedure which returns a Oracle record.
How can I retrieve the record in java using the JDBC Thin-Driver ?
Record:
TYPE messagerec IS RECORD
(log_level VARCHAR(2), timestamp VARCHAR2(19), text VARCHAR2(200));Using PL/SQL BOOLEAN, RECORD Types, and TABLE Types:
Oracle SQLJ and JDBC do not support calling arguments or return values of the
PL/SQL BOOLEAN type or RECORD types. Also, when using the Thin driver, they
do not support calling arguments or return values of PL/SQL TABLE types (known
as indexed-by tables). TABLE types are supported for the OCI driver.
Check the following guide,
http://otn.oracle.com/tech/java/sqlj_jdbc/pdf/a96655.pdf -
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..:-) -
Create Oracle BLOB and Pass to Oracle Stored Procedure
Hi All,
I am using Oracle 10g and am dealing with a requirement where I have to upload a file to Oracle Portal from the client's local machine using a JSP.
I am planning to convert the text file to a BLOB and pass it to an Oracle stored procedure which does the rest.
I am unable to create a BLOB object. Can anybody help me with this please.
Is there a better alternative to do it?
Thanks in advance,
Shardulu can create blob as below...
java.sql.Blob blob=new Blob();
File file=new File(fullPathTo UrFile);
FileInputStream fInSteam = new FileInputStream(file);
BufferedInputStream bInputStream = new BufferedInputStream(fInSteam);
ByteArrayOutputStream bOutputStream = new ByteArrayOutputStream();
int nextByte;
while (( nextByte = bInputStream.read() ) != - 1)
bOutputStream.write(nextByte);
byte[] byteContent = bOutputStream.toByteArray();
blob.setBytes(byte[]);
i think it should work for u... -
Hello Experts,
Is there any efficient way to see what stored procedures and ssis packages are connecting to server ss-cube?
Can you please help me to come across.
Thanks in advance,
Regards,
HariHello Experts,
Is there any efficient way to see what stored procedures and ssis packages are connecting
to server ss-cube?
Can you please help me to come across.
Thanks in advance,
Regards,
Hari -
Dynamic SQL and Oracle stored procedures
Does anybody has any experience with invoking an Oracle stored procedures
with output parameters, using dynamic SQL from Forte?
Thanks,
DimitarI would be interested. We are currently using a homegrown DataMapper architecture with the Microsoft OracleClient. I would like to move to ODP.Net once a production version supporting ADO.Net 2.0 is available. After that, I would then like to look at using an off the shelf persistence framework such as EntitySpaces, NHibernate or IdeaBlade's DevForce.
-
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? -
Help....on stored procedure (or package)
Hi,
I have any problem to create stored procedure in Oracle, Can you help me?
I have to create a stored procedure (or package) in order to reserve the free rooms to the students in the period comprised between the DATE_START and DATE_END.
Table of the present rooms in building BL1 (RM): SEX 1 = M - SEX 2 = F SEX = 0 (ROOM WITHOUT SEX)
BL_ID.....FL_ID.......RM_ID.........SEX......RM_STD.....RM_CAT
BL1.........1..........101..............1........S........ROOM
BL1.........1..........102..............0........D........ROOM
BL1.........1..........103..............2........T........ROOM
BL1.........2..........201..............2........S........ROOM
BL1.........2..........202..............1........D........ROOM
BL1.........2..........203..............1........T........ROOM
BL1.........3..........301..............2........S........APARTMENT
BL1.........3..........302..............2........D........APARTMENT
BL1.........3..........303..............1........T........APARTMENT
BL1.........3..........304..............1........D........APARTMENT
BL1.........3..........305..............0........D........APARTMENT
Table of the students (EM):
EM_ID...........BL_ID.......FL_ID........RM_ID........COD_STUD
SABRINA..........BL1..........1............102.........524505
TAKEM............BL1..........1............103.........569673
SERAFINO.........BL1..........1............103.........589920
STELLA...........BL1..........1............102.........574659
CHIARA...........BL1..........1............101.........587845
VIDAL............BL1..........1............102.........602877
ROSARIA..........BL1..........2............202.........517070
LUCA.............BL1..........2............201.........602743
DANIELA..........BL1..........2............203.........602865
ANNAMARIA........BL1..........3............305.........588721
LUIGI............BL1..........3............304.........546517
Type of rooms (RM_STD):
RM_STD.......STD_EM........DESCRIPTION
D.............4..............DOUBLE
T.............6..............TRIPLE
S.............2..............SINGLE
Tables of the reservations carried out from the students (RMPCT):
EM_ID......BL_ID........FL_ID......RM_ID......DATE_START.......DATE_END.......COD_STUD
CHIARA......BL1.........1..........101.......11/02/2004.......12/02/2004.......587845
CHIARA......BL1.........1..........101.......03/02/2005.......16/02/2005.......587845
SERAFINO....BL1.........1..........102.......12/02/2004.......19/02/2004.......589920
VIDAL.......BL1.........1..........102.......16/02/2004.......01/03/2004.......602877
SERAFINO....BL1.........1..........103.......01/02/2004.......15/02/2004.......589920
TAKEM.......BL1.........1..........103.......04/02/2005.......10/02/2005.......569673
LUCA........BL1.........2..........201.......03/02/2005.......23/02/2005.......602743
ROSARIA.....BL1.........2..........202.......03/02/2005.......16/02/2005.......517070
DANIELA.....BL1.........2..........203.......03/02/2005.......04/02/2005.......602865
LUIGI.......BL1.........3..........301.......03/02/2005.......23/02/2005.......546517
VALERIA.....BL1.........3..........302.......12/02/2004.......16/02/2004.......515348
CHIARA......BL1.........3..........302.......05/02/2004.......15/02/2004.......587845
CHIARA......BL1.........3..........304.......10/02/2004.......12/02/2004.......587845
CHIARA......BL1.........3..........305.......20/01/2004.......04/02/2004.......587845
ANNAMARIA...BL1.........3..........305.......03/02/2005.......16/02/2005.......588721
INPUT PARAMETERS:
CREATE OR REPLACE Procedure RESERVE_ROOMS (stud_name varchar2,
cod_stud varchar2,
bl_in varchar2,
fl_in varchar2,
rm_in in varchar2,
sex_in varchar2,
date_start_in varchar2,
date_end_in varchar2)
CONDITIONS:
verify if there are students in table EM:
select count (1)
into v_appo
from em
where em_id = stud_name
and cod_stud = cod_stud;
if v_appo = 0 then
insert new student:
insert into em (em_id,cod_sud,sex)
values (stud_name,cod_stud,sex_in);
Now I must verify the free rooms in the period comprised between the DATE_START_IN and DATE_END_IN.
I tried this query: (seem correct...have you any idea?)
select bl_id,fl_id,rm_id,RM_STD
from rm
where (bl_id,fl_id,rm_id,RM_STD) not in (select a.bl_id,a.fl_id,a.rm_id,A.RM_STD
from rm a, rmpct b
where a.bl_id=b.bl_id
and a.fl_id=b.fl_id
and a.rm_id=b.rm_id
AND((b.date_start <= TO_DATE(date_start_in, 'dd-mm-YYYY')
AND b.date_end >= TO_DATE(date_end_in, 'dd-mm-YYYY'))
OR ( b.date_end <= TO_DATE(date_end_in, 'dd-mm-YYYY'))
AND b.date_end >= TO_DATE(date_start_in, 'dd-mm-YYYY')
OR ( b.date_start >= TO_DATE(date_start_in, 'dd-mm-YYYY')
and b.date_start <= TO_DATE(date_end_in, 'dd-mm-YYYY')
AND b.date_end >= TO_DATE(date_end_in, 'dd-mm-YYYY'))))
with this query I get all free rooms in period date_start_in - date_end_in, but I must,also,verify if there are double or triple rooms (reserved) with minus of 2 (double) or minus of 3 (triple) students. If there are I can reserved these rooms.
I tried to verify with these steps:
CREATE OR REPLACE VIEW COUNT_EM ( BL_ID,
FL_ID, RM_ID, NUMBER_EM ) AS
(SELECT rm.bl_id, rm.fl_id, rm.rm_id, COUNT(*) as numero_em
FROM em, rm
WHERE em.bl_id(+) = rm.bl_id
AND em.fl_id(+) = rm.fl_id
AND em.rm_id(+) = rm.rm_id
and rm.rm_std in ('S', 'D', 'T')
group by rm.bl_id, rm.fl_id, rm.rm_id)
CREATE OR REPLACE VIEW COUNT_RMPCT ( BL_ID,
FL_ID, RM_ID, STD_EM, NUMBER_RMPCT
) AS
SELECT rm.bl_id, rm.fl_id, rm.rm_id, rmstd.std_em, COUNT(*) as numero_rmpct
FROM rm, rmpct,rmstd
WHERE rmpct.bl_id(+) = rm.bl_id
AND rmpct.fl_id(+) = rm.fl_id
AND rmpct.rm_id(+) = rm.rm_id
and rm.rm_std=rmstd.rm_std
and rm.rm_std in ('S', 'D', 'T')
AND((rmpct.date_start <= TO_DATE(date_start_in', 'dd-mm-YYYY')
AND rmpct.date_end >= TO_DATE(date_end_in, 'dd-mm-YYYY'))
OR ( rmpct.date_end <= TO_DATE(date_end_in, 'dd-mm-YYYY'))
AND rmpct.date_end >= TO_DATE(date_start_in, 'dd-mm-YYYY')
OR ( rmpct.date_start >= TO_DATE(date_start_in, 'dd-mm-YYYY')
and rmpct.date_start <= TO_DATE(date_end_in, 'dd-mm-YYYY')
AND rmpct.date_end >= TO_DATE(date_end_in, 'dd-mm-YYYY')))
group by rm.bl_id, rm.fl_id, rm.rm_id, rmstd.std_em
AND FINALLY:
select a.bl_id, a.fl_id, a.rm_id, a.NUMBER_RMPCT, B.NUMBER_EM, a.std_em, (a.std_em - (a.NUMBER_RMPCT+B.NUMBER_EM)) RM_FREE
from COUNT_RMPCT a, COUNT_EM b
where a.bl_id=b.bl_id
and a.fl_id=b.fl_id
and a.rm_id=b.rm_id
if RM_FREE > 0 THEN there are free rooms (D or T) between those occupied in that period.
Now If the room (bl_in,fl_in,rm_in) is free I can reserve inserting it in the table RMPCT:
INSERT INTO rmpct (bl_id, fl_id, rm_id,em_id,cod_stud,date_start, date_end)
values(bl_in,fl_in,rm_in,stud_name,cod_stud,date_start_in,date_end_in);
If I haven't rm_in (can be null) I must reserve the first free room (random).
after these controls: I update table of the students:
UPDATE em
Set bl_id = BL_IN,fl_id= FL_IN,rm_id=rm_in
where em_id=stud_name
and cod_stud=cod_stud;
Finally I must make a control on the sex of the room, because there are rooms that have sex=0
if RM.SEX <> 0 then
null
else
if rm_cat = 'ROOM' then
UPDATE rm
set sex = sex_in
where bl_id = in
and fl_id = in
and rm_id = in;
if rm_cat = 'APARTMENT' then (update on all rooms)
UPDATE rm
set sex = sex_in
where bl_id = in
and fl_id = in;
IF v_appo > 0 then
Same controls except: insert into em (em_id,cod_sud,sex)
values (stud_name,cod_stud,sex_in);
How I can insert in one stored procedure (or package) all these instructions and controls?
Thanks in advance!In the following demonstation, I have changed the names of some of your variables, in order to standardize them. I have prefaced input parameters with p_ and local variables with v_ and followed them with the name of the column that they are associated with when appropriate. This avoids conflicts with any column names and makes the code easier to read and follow. I have also used table_name.column_name%type to specify the data type associated with the variables instead of using varchar2. That way, if the data type of the columns changes, the code does not have to be updated. This is standard practice.
In your first insert statement, you have attempted to insert sex into the em table, but there is no sex column in the em table data that you displayed, so I removed the sex.
Instead of using a complicated mess of views and such to check whether there is a room available and then assign it, I have used just one select statement to select an available room and used an exception clause that handles a no_data_found exception to deal with when there is no room available.
I have greatly simplified your checking of dates within that select statement.
You were on the right track with the outer joins and grouping and checking for single, double, or triple rooms. Instead of count, I have used sum and nvl2, so that only the occupied rooms are counted and the rows generated by the outer join are zeroes.
I have used the nvl function to allow for null values in the input parameters, so that any room can be selected. I used dbms_random.random to ensure that the rows are ordered randomly, but you can leave that out if it is really not that critical that the result be truly random and any row will do. I have used rownum=1 in an outer query to select just one row.
When you select from a table in pl/sql, you have to select into something. You cannot just issue a select statement, then use an if statement to compare some value in the select statement. For example, you cannot use "if rm.sex ..." you have to select rm.sex into a variable, like v_sex, then use "if v_sex ...". So, I have selected the result of the select statement into local variables, then used those variables for comparisons. I have also used those variables for inserting and updating the appropriate tables, rather than just using the original input parameters, since some of them may have been null.
In the example below, I have demonstrated how the procedure rejects an unavailable room, accepts a specific available room, and randomly assigns a room.
-- procedure:
scott@ORA92> CREATE OR REPLACE PROCEDURE reserve_rooms
2 -- input parameters:
3 (p_em_id IN em.em_id%TYPE,
4 p_cod_stud IN em.cod_stud%TYPE,
5 p_bl_id IN rm.bl_id%TYPE,
6 p_fl_id IN rm.fl_id%TYPE,
7 p_rm_id IN rm.rm_id%TYPE,
8 p_sex IN rm.sex%TYPE,
9 p_date_start IN VARCHAR2,
10 p_date_end IN VARCHAR2)
11 AS
12 -- local variables:
13 v_appo INTEGER;
14 v_bl_id rm.bl_id%TYPE;
15 v_fl_id rm.fl_id%TYPE;
16 v_rm_id rm.rm_id%TYPE;
17 v_rm_cat rm.rm_cat%TYPE;
18 v_sex rm.sex%TYPE;
19 BEGIN
20 -- verify if the student is in table em:
21 SELECT COUNT (*)
22 INTO v_appo
23 FROM em
24 WHERE em_id = p_em_id
25 AND cod_stud = p_cod_stud;
26 -- if the student is not in table em, then insert new student:
27 IF v_appo = 0 THEN
28 INSERT INTO em (em_id, cod_stud)
29 VALUES (p_em_id, p_cod_stud);
30 END IF;
31 BEGIN
32 -- find available room:
33 SELECT bl_id, fl_id, rm_id, sex, rm_cat
34 INTO v_bl_id, v_fl_id, v_rm_id, v_sex, v_rm_cat
35 FROM (SELECT rm.bl_id, rm.fl_id, rm.rm_id, rm.sex, rm.rm_cat
36 FROM rmpct, rm
37 WHERE rm.bl_id = rmpct.bl_id (+)
38 AND rm.fl_id = rmpct.fl_id (+)
39 AND rm.rm_id = rmpct.rm_id (+)
40 AND rm.bl_id = NVL (p_bl_id, rm.bl_id)
41 AND rm.fl_id = NVL (p_fl_id, rm.fl_id)
42 AND rm.rm_id = NVL (p_rm_id, rm.rm_id)
43 AND (rm.sex = p_sex OR rm.sex = 0)
44 AND rmpct.date_start (+) <= TO_DATE (p_date_end, 'DD-MM-YYYY')
45 AND rmpct.date_end (+) >= TO_DATE (p_date_start, 'DD-MM-YYYY')
46 GROUP BY rm.bl_id, rm.fl_id, rm.rm_id, rm.sex, rm.rm_cat, rm.rm_std
47 HAVING SUM (NVL2 (rmpct.rm_id (+), 1, 0))
48 < DECODE (rm_std, 'S', 1, 'D', 2, 'T', 3)
49 ORDER BY DBMS_RANDOM.RANDOM)
50 WHERE ROWNUM = 1;
51 -- reserve room:
52 INSERT INTO rmpct (bl_id, fl_id, rm_id, em_id, cod_stud, date_start, date_end)
53 VALUES (v_bl_id, v_fl_id, v_rm_id, p_em_id, p_cod_stud,
54 TO_DATE (p_date_start, 'DD-MM-YYYY'),
55 TO_DATE (p_date_end, 'DD-MM-YYYY'));
56 -- update students:
57 UPDATE em
58 SET bl_id = v_bl_id, fl_id = v_fl_id, rm_id = v_rm_id
59 WHERE em_id = p_em_id
60 AND cod_stud = p_cod_stud;
61 -- update sex of room or apartment floor:
62 IF v_sex = 0 THEN
63 IF v_rm_cat = 'ROOM' THEN
64 UPDATE rm
65 SET sex = p_sex
66 WHERE bl_id = v_bl_id
67 AND fl_id = v_fl_id
68 AND rm_id = v_rm_id;
69 ELSIF v_rm_cat = 'APARTMENT' THEN
70 UPDATE rm
71 SET sex = p_sex
72 WHERE bl_id = v_bl_id
73 AND fl_id = v_fl_id;
74 END IF;
75 END IF;
76 EXCEPTION
77 -- if no room is available:
78 WHEN NO_DATA_FOUND THEN
79 RAISE_APPLICATION_ERROR (-20001, 'Sorry, there is no such room available.');
80 END;
81 END reserve_rooms;
82 /
Procedure created.
scott@ORA92> SHOW ERRORS
No errors.
-- rejects unavailable room of wrong sex:
scott@ORA92> EXECUTE reserve_rooms ('BARBARA', 654321, 'BL1', 1, 101, 2, '04-02-2005', '10-02-2005')
BEGIN reserve_rooms ('BARBARA', 654321, 'BL1', 1, 101, 2, '04-02-2005', '10-02-2005'); END;
ERROR at line 1:
ORA-20001: Sorry, there is no such room available.
ORA-06512: at "SCOTT.RESERVE_ROOMS", line 79
ORA-06512: at line 1
-- accepts available room of same sex:
scott@ORA92> EXECUTE reserve_rooms ('BARBARA', 654321, 'BL1', 1, 103, 2, '04-02-2005', '10-02-2005')
PL/SQL procedure successfully completed.
-- assigns random available room of same or no sex:
scott@ORA92> EXECUTE reserve_rooms ('BARBARA', 654321, NULL, NULL, NULL, 2, '11-02-2005', '23-02-2005')
PL/SQL procedure successfully completed.
-- results:
scott@ORA92> -- one and only one row added to em table:
scott@ORA92> SELECT * FROM em WHERE em_id = 'BARBARA'
2 /
EM_ID BL_I FL_ID RM_ID COD_STUD
BARBARA BL1 1 102 654321
scott@ORA92> -- rooms reserved and other people who have reserved same room
scott@ORA92> -- (there are 3 who reserved a double room, but only 2 at a time):
scott@ORA92> SELECT *
2 FROM rmpct
3 WHERE (bl_id, fl_id, rm_id) IN
4 (SELECT bl_id, fl_id, rm_id
5 FROM rmpct
6 where em_id = 'BARBARA')
7 /
EM_ID BL_ FL_ID RM_ID DATE_STAR DATE_END COD_STUD
BARBARA BL1 1 102 11-FEB-05 23-FEB-05 654321
SERAFINO BL1 1 102 12-FEB-04 19-FEB-04 589920
VIDAL BL1 1 102 16-FEB-04 01-MAR-04 602877
SERAFINO BL1 1 103 01-FEB-04 15-FEB-04 589920
TAKEM BL1 1 103 04-FEB-05 10-FEB-05 569673
BARBARA BL1 1 103 04-FEB-05 10-FEB-05 654321
6 rows selected.
scott@ORA92> -- rooms reserved are all correct sex
scott@ORA92> -- (note that room 102 was updated from 0 to 2):
scott@ORA92> SELECT *
2 FROM rm
3 WHERE (bl_id, fl_id, rm_id) IN
4 (SELECT bl_id, fl_id, rm_id
5 FROM rmpct
6 where em_id = 'BARBARA')
7 /
BL_ FL_ID RM_ID SEX R RM_CAT
BL1 1 102 2 D ROOM
BL1 1 103 2 T ROOM
scott@ORA92>
Maybe you are looking for
-
I have problems installing Adobe Flash Player. Can you help?
When I try to install Flahs Player, it keeps telling me that the installation will be finalized when I will reopen navigators such as Safari. Then I shut down and restart but it does not install
-
I've been an IPod user since Gen 1 - I think I'm on my fifth or sixth. I rely on it as my source of music for all exercising as well as one of the main sources to play music along with. With that in mind I have several wishes that were, or maybe are,
-
how do you find out how old your ipad is...is there somewhere to enter the serial number. thanks andy
-
UCCX 7.0(1) RmCm resource issue
I have an issue with our UCCX 7.0(1): In RmCm -> Resource configuration Just for one particular resource - the resource group changes from "Service Desk" to "Not selected" overnight and team changes from "Service Desk" to "Default". The next morning
-
How do I import and access bookmarks from my laptop firefox
nowhere do I see bookmarks on android Firefox