Oracle Procedure update
We have two tables.
1. EMP_STAGE 2. EMP
Find the structure for the above two tables.
EMP_STAGE EMP
EMP_ID ID
PAN EMP_PAN
STATUS STATUS
LAST_DAY EMP_FLAG
END_DATE
one of our applications EMP_STAGE table get the data then EMP_STAGE table data will be loaded into EMP table.
I need to write a procedure, based on the results of EMP_STAGE table EMPLOYEE table should update like ,
1. if employee is still with the organization the STATUS is "Active" in EMP_STAGE table if he resigned or terminated then his status should be "inactive" and LAST_DAY (date format) of employees data also updated in EMP_STAG table.
2. while loading the data into EMP table based on the data from EMP_STAGE , in employee table STATUS of employee ='ACTIVE/INACTIVE' and END_DATE = LAST_DAY( from EMP_STAGE table) based on these two the column EMP_FLAG will update like EMP_FLAG = ( if employee existed then 'YES' else 'NO') ;
please provide me your thoughts on this.
now i am confused going back to your previous posting you do not have those end_dates on your sample data. below is your sample data.
emp_stage.EMPID emp_stage.LAST_DAY emp_stage.STATUS Status Match? emp.ID emp.END_DATE emp.STATUS
1012028 19-Jun-13 T FALSE 1012028 19-Jun-13 A
1472711 20-Jun-13 T FALSE 1472711 20-Jun-13 A
1012025 21-Jun-13 T FALSE 1012025 21-Jun-13 A
234567 19-Jun-13 T FALSE 234567 19-Jun-13 A
43567 20-Jun-13 T FALSE 43567 20-Jun-13
76788 21-Jun-13 T FALSE 76788 21-Jun-13 A
1234876 22-Jun-13 T FALSE 1234876 22-Jun-13 A
maybe it will help if you can re-post again wtih a clean sample data for example.
source emp_stage table:
emp_id pan status last_day
1012028 Inactive 19-Jun-13
1472711 Inactive 20-Jun-13
1234567 Active 29-Dec-13
expected result in emp table:
id emp_pan status emp_flag end_date
1012028 T N 19-Jun-13
1472711 T N 20-Jun-13
1234567 A Y 29-Dec-13
you can give this a try:
with emp_stage as
(select 1012028 emp_id, to_date('19-Jun-13','dd-mon-rr') last_day, 'Active' status from dual union all
select 1472711 emp_id, to_date('20-Jun-13','dd-mon-rr') last_day, 'Active' status from dual union all
select 1012025 emp_id, to_date('21-Jun-13','dd-mon-rr') last_day, 'Active' status from dual union all
select 234567 emp_id, to_date('19-Jun-13','dd-mon-rr') last_day, 'Active' status from dual union all
select 43567 emp_id, to_date('20-Jun-13','dd-mon-rr') last_day, 'Active' status from dual union all
select 76788 emp_id, to_date('21-Jun-13','dd-mon-rr') last_day, 'Active' status from dual union all
select 1234876 emp_id, to_date('22-Jun-13','dd-mon-rr') last_day, 'Active' status from dual union all
select 54321 emp_id, to_date('29-Dec-13','dd-mon-rr') last_day, 'Active' status from dual union all
select 67890 emp_id, to_date('30-Aug-13','dd-mon-rr') last_day, 'Active' status from dual)
select emp_id,
case when status = 'ACTIVE' or (trunc(last_day) > trunc(sysdate)) then
'A'
when status = 'INACTIVE' or (trunc(last_day) < trunc(sysdate)) then
'T'
end status,
case when status = 'ACTIVE' or (trunc(last_day) > trunc(sysdate)) then
'N'
when status = 'INACTIVE' or (trunc(last_day) < trunc(sysdate)) then
'Y'
end emp_flag,
last_day
from EMP_STAGE;
EMP_ID STATUS EMP_FLAG LAST_DAY
1012028 T Y 19-Jun-2013
1472711 T Y 20-Jun-2013
1012025 T Y 21-Jun-2013
234567 T Y 19-Jun-2013
43567 T Y 20-Jun-2013
76788 T Y 21-Jun-2013
1234876 T Y 22-Jun-2013
54321 A N 29-Dec-2013
67890 A N 30-Aug-2013
9 rows selected
SQL>
Similar Messages
-
Update Yes/No field in access table through oracle procedure
Hi,
How to update Yes/No field in access table through oracle procedure. all other fields like AutoNumber, Text I can update it. Yes/No field how to update? Please, any one can help me?
Thanks and Regards,
Sudha.Sudha Teki wrote:
select "fldPost" from tblPHd@ODBCLNKNot quite sure what you mean, but the way you select the column would indicate a case sensitive column name
Look at this example
SQL> create table t
2 ("this" varchar2(10))
3 /
Table created.
SQL> insert into t values ('hello')
2 /
1 row created.
SQL> select *
2 from t
3 /
this
hello
SQL> select this
2 from t
3 /
select this
ERROR at line 1:
ORA-00904: "THIS": invalid identifier
SQL> select "this"
2 from t
3 /
this
helloIs your column name also case sensitive? -
Hi,
We have a problem with a Oracle procedure call using the Sql Execute
Procedure statement.
The call gives us this error :
SYSTEM ERROR: (This error was converted)
(This error was converted)
OpenCursor failed for SQL statement in project LFB010, class
ClsDemarreLFB010,
method Demarre, methodId 4, line 32, error from database is:
ORA-01036: illegal variable name/num
Class: qqdb_ResourceException
Distributed method called: qqdb_SessionProxy.OpenCursor!22 (object
name
instance/d4745a10-c8e4-11d1-97fd-90cad1e7aa77:0x196:0x4/lfb010_cl0/lfb010_cl
0-fonctiondbservice0x196:0x2)
from partition "LFB010_CL0_Client", (partitionId =
D4745A10-C8E4-11D1-97FD-90CAD1E7AA77:0x196:0x4, taskId =
[D4745A10-C8E4-11D1-97FD-90CAD1E7AA77:0x196.3]) in application
"FTLaunch_cl0", pid 4290975297 on node LAXOU146 in environment
CentralEnv
Oracle error: 1036, Server: sipre_tcp, UserName: forte
Database Statement: begin
:qqReturnValue := AID_CUMUL_ELTVAL;
end;
Class: qqdb_ResourceException ..........
And this is the TOOL code :
BEGIN TRANSACTION
TmpEtat : IntegerData = new;
TmpEtat.SetValue (( SQL EXECUTE PROCEDURE AID_CUMUL_ELTVAL ON SESSION
FonctionDBService ));
Etat = TmpEtat.Value;
END TRANSACTION;
Our procedure has no parameter and when we put a dummy parameter to the
procedure and pass it in the TOOL SQL statement, it works fine althoug the
Forté help says the parameter list is optionnal !
We tried to execute the procedure in a "SQL Select OurProdecure Into ..."
statement, but it does'nt work because there is a SQL update in the
procedure and it is forbidden by Oracle.
Has anyone seen this error before ?
Any ideas would be greatly appreciated.
Many thanks and regards,
Manuel DEVEAUX
Previade, France
e-mail : deveauxpreviade.frHi,
We have a problem with a Oracle procedure call using the Sql Execute
Procedure statement.
The call gives us this error :
SYSTEM ERROR: (This error was converted)
(This error was converted)
OpenCursor failed for SQL statement in project LFB010, class
ClsDemarreLFB010,
method Demarre, methodId 4, line 32, error from database is:
ORA-01036: illegal variable name/num
Class: qqdb_ResourceException
Distributed method called: qqdb_SessionProxy.OpenCursor!22 (object
name
instance/d4745a10-c8e4-11d1-97fd-90cad1e7aa77:0x196:0x4/lfb010_cl0/lfb010_cl
0-fonctiondbservice0x196:0x2)
from partition "LFB010_CL0_Client", (partitionId =
D4745A10-C8E4-11D1-97FD-90CAD1E7AA77:0x196:0x4, taskId =
[D4745A10-C8E4-11D1-97FD-90CAD1E7AA77:0x196.3]) in application
"FTLaunch_cl0", pid 4290975297 on node LAXOU146 in environment
CentralEnv
Oracle error: 1036, Server: sipre_tcp, UserName: forte
Database Statement: begin
:qqReturnValue := AID_CUMUL_ELTVAL;
end;
Class: qqdb_ResourceException ..........
And this is the TOOL code :
BEGIN TRANSACTION
TmpEtat : IntegerData = new;
TmpEtat.SetValue (( SQL EXECUTE PROCEDURE AID_CUMUL_ELTVAL ON SESSION
FonctionDBService ));
Etat = TmpEtat.Value;
END TRANSACTION;
Our procedure has no parameter and when we put a dummy parameter to the
procedure and pass it in the TOOL SQL statement, it works fine althoug the
Forté help says the parameter list is optionnal !
We tried to execute the procedure in a "SQL Select OurProdecure Into ..."
statement, but it does'nt work because there is a SQL update in the
procedure and it is forbidden by Oracle.
Has anyone seen this error before ?
Any ideas would be greatly appreciated.
Many thanks and regards,
Manuel DEVEAUX
Previade, France
e-mail : deveauxpreviade.fr -
Unusual behavior with 'IKM Oracle Incremental Update' knowledge module
Hi All,
We are getting strange behaviour in our PIP.We have following three scenarios in our PIP.
1) LOAD_ORACLEEBIZ_PROCESSMFG_BULK_LOT_DATA_TO_PAS_PKG
2) LOAD_ORACLEEBIZ_DISCRETEMFG_WORKORDER_DATA_TO_PAS_PKG
3) LOAD_ORACLEEBIZ_PROCESSMFG_WORKORDER_DATA_TO_PAS_PKG
we have a project variable PVV_GET_SCEN_NAME which will hold the scenario name in that package.
we are trying to modify the 'IKM Oracle Incremental Update' knowledge module, we have written following code.this code will match the content of I$ table with target table based on various columns.if they are matching we will delete the matching rows from target table. But when we are executing scenario "LOAD_ORACLEEBIZ_PROCESSMFG_BULK_LOT_DATA_TO_PAS_PKG",then the wrong IF condition is getting matched in the following procedure.
the condition that is getting matched is "ELSIF ('#ORACLEEBIZ_TO_PAS_PROJECT.PVV_GET_SCEN_NAME'='LOAD_ORACLEEBIZ_DISCRETEMFG_WORKORDER_DATA_TO_PAS_PKG') THEN".Actually the value of #ORACLEEBIZ_TO_PAS_PROJECT.PVV_GET_SCEN_NAME will be LOAD_ORACLEEBIZ_PROCESSMFG_BULK_LOT_DATA_TO_PAS_PKG.i am not sure why odi is matching this condition.
Please provide your comments on this issue.thanks in advace.
IKM step:
BEGIN
IF '#PVV_GET_SCEN_NAME'='LOAD_ORACLEEBIZ_PROCESSMFG_BULK_LOT_DATA_TO_PAS_PKG' THEN
DELETE FROM <%=odiRef.getTable("L", "TARG_NAME", "W")%> WHERE (item_number,lot_number,source_system) IN
(SELECT item_number,lot_number,source_system FROM <%=odiRef.getTable("L", "INT_NAME", "A")%>);
COMMIT;
ELSIF '#PVV_GET_SCEN_NAME'='LOAD_ORACLEEBIZ_DISCRETEMFG_WORKORDER_DATA_TO_PAS_PKG' THEN
DELETE FROM <%=odiRef.getTable("L", "TARG_NAME", "W")%> WHERE (segment1,segment2,segment3,source_system,item_number) IN
(SELECT segment1,segment2,segment3,source_system,item_number FROM <%=odiRef.getTable("L", "INT_NAME", "A")%>);
COMMIT;
ELSIF '#PVV_GET_SCEN_NAME'='LOAD_ORACLEEBIZ_PROCESSMFG_WORKORDER_DATA_TO_PAS_PKG' THEN
DELETE FROM <%=odiRef.getTable("L", "TARG_NAME", "W")%> WHERE (segment2,source_system) IN
(SELECT segment2,source_system FROM <%=odiRef.getTable("L", "INT_NAME", "A")%>);
COMMIT;
ELSE
NULL;
END IF;
END;
Thanks
BajiHi Himanshu,
Thanks for your help.
I gave fully qualified name,even then it didn't worked.
- How are you deriving the value of variable
project variable PVV_GET_SCEN_NAME is refreshing variable and it will get the value of scenario with the following sql query
select SESS_NAME
from <%=snpRef.getObjectName("L","SNP_SESSION","D")%>
where SESS_NO = <%=snpRef.getSession("SESS_NO")%>
-Log or store the value of variable as comment in IKM sql query using "-- #varvalue" and note the value is same as compared
When i gave --#varvalue (or) --#ORACLEEBIZ_TO_PAS_PROJECT.PVV_GET_SCEN_NAME is doesnot display any thing.what i did is I changed the PVV_GEN_SCEN_NAME variable to hostorize variable to see correct value of that and after the executing the scenario,i can see the value as "LOAD_ORACLEEBIZ_PROCESSMFG_BULK_LOT_DATA_TO_PAS_PKG".I also tried same thing by changing technology to jython and i am able to see same value "LOAD_ORACLEEBIZ_PROCESSMFG_BULK_LOT_DATA_TO_PAS_PKG" for the PVV_GET_SCEN_NAME variable.
Thanks
Baji -
Oracle Messaging Gateway vs. Oracle Procedural Gateway
What is difference between Oracle Messaging Gateway for IBM MQSeries and Oracle Procedural Gateway for IBM MQSeries? Which one is the best solution for IBM WebSphere MQ integration from architecture design point of view? Does anyone have any documentation on comparing Oracle Messaging Gateway for IBM MQSeries with Oracle Procedural Gateway for IBM MQSeries, for example, pros and cons etc?
Any help will be greatly appreciated.
YangDear Yang!
I have the same problem considering the two possibilities to connect ibm with oracle...
Did you get some useful information or do you have some experience now? If yes could you please update the post!
Thanks
Markus -
Convert php script to oracle procedure
To all please help me... I wanna convert php script to oracle procedure..and the script is (exp)..
<?php
include("../config/koneksi.php");
$customer=$_POST['customer'];
$tanggal1=$_POST['theDate1'];
$tanggal2=$_POST['theDate2'];
$no_bulan=substr($tanggal1,0,2);
$bulan_sajah= (substr($no_bulan,0,1)=='0')? substr($no_bulan,1,1) : $no_bulan;
$tahun_sajah=substr($tanggal1,3,4);
$blnkmrn=(int)$bulan_sajah;
$thnkmrn=(int)$tahun_sajah;
if ($blnkmrn==1) {
$bulan_lalu=12;
$tahun_lalu=$thnkmrn-1;}
else {
$bulan_lalu=$blnkmrn-1;
$tahun_lalu=$thnkmrn;
$bulanlalu=strval($bulan_lalu);
$tahunlalu=strval($tahun_lalu);
$sql = "select nip_nas from edo_customer_master_dives where standard_name='$customer'";
$stm = ociparse($conn,$sql);
ociexecute($stm);
ocifetch($stm);
$data=ociresult($stm,1);
$sql12 = "select PRODUCT_LINE_ID,sum(REVENUE)
from PA_FACT_REV_BILLED_CC
where nip_nas='$data' and year_id='$tahun_sajah' and month_id='$bulan_sajah' group by PRODUCT_LINE_ID";
$stm12 = ociparse($conn,$sql12);
ociexecute($stm12);
$total_revenue=0;
$i="0";
while (ocifetch($stm12)){
$rev_items=ociresult($stm12,1);
$revenue=ociresult($stm12,2);
$sql2 = "select * from PA_FACT_REV_BILLED_CC
where nip_nas='$data' and PRODUCT_LINE_ID='$rev_items'";
$stm2 = ociparse($conn,$sql2);
ociexecute($stm2);
ocifetch($stm2);
$tahun=ociresult($stm2,1);
$bulan=ociresult($stm2,2);
$nipnas=ociresult($stm2,3);
$prod_line=ociresult($stm2,4);
$rev_item=ociresult($stm2,5);
//$revenue=ociresult($stm2,6);
$query1 = "select standard_name from edo_customer_master_dives where nip_nas='$nipnas'";
$st1 = ociparse($conn,$query1);
ociexecute($st1);
ocifetch($st1);
$nama_cust=ociresult($st1,1);
$query2 = "select prod_line_lname from parameter.p_prod_line@dwhnas where prod_line_id='$prod_line'";
$st2 = ociparse($conn,$query2);
ociexecute($st2);
ocifetch($st2);
$nama_prod_line=ociresult($st2,1);
$query3 = "select REV_TYPE_LNAME from parameter.p_rev_type@dwhnas where REV_TYPE_ID='$rev_item'";
$st3 = ociparse($conn,$query3);
ociexecute($st3);
ocifetch($st3);
$nama_rev_item=ociresult($st3,1);
$query4="select sum(total_usage) from PA_FACT_TRAFFIC_CC where PRODUCT_LINE_ID='$prod_line' and nip_nas='$nipnas' and year_id='$tahun_sajah' and month_id='$bulan_sajah' group by PRODUCT_LINE_ID";
$st4 = ociparse($conn,$query4);
ociexecute($st4);
ocifetch($st4);
$total_usage=ociresult($st4,1);
$total=$revenue + $total_usage;
echo $tahun." ".$bulan." ".$nama_cust." ".$nama_prod_line." ".$nama_rev_item." ".$revenue." ".$total_usage." ".$total."<br>";
$total_revenue=$total_revenue+$total;
$i++;
echo $total_revenue;
//cost of product
$query5="select * from PA_FACT_TRAFFIC_CC where nip_nas='$nipnas' and year_id='$tahunlalu' and month_id='$bulanlalu'";
$st5 = ociparse($conn,$query5);
ociexecute($st5);
$total1=0;
$total2=0;
$total3=0;
$total4=0;
$total5=0;
while (ocifetch($st5)){
$nipnas=ociresult($st5,3);
$lineid=ociresult($st5,4);
$itemid=ociresult($st5,5);
$call=ociresult($st5,6);
$unit=ociresult($st5,7);
$query6 = "select prod_line_lname from parameter.p_prod_line@dwhnas where prod_line_id='$lineid'";
$st6 = ociparse($conn,$query6);
ociexecute($st6);
ocifetch($st6);
$nama_prod_line=ociresult($st6,1);
$query7 = "select REV_item_LNAME from parameter.p_rev_item@dwhnas where REV_item_ID='$itemid'";
$st7 = ociparse($conn,$query7);
ociexecute($st7);
ocifetch($st7);
$nama_rev_item=ociresult($st7,1);
$query8 = "select * from cost_of_product where prod_line_lname='$nama_prod_line' and REV_item_LNAME='$nama_rev_item' and end_date is null";
$st8 = ociparse($conn,$query8);
ociexecute($st8);
ocifetch($st8);
$lineid_cost=ociresult($st8,1);
$itemid_cost=ociresult($st8,2);
$satuan=ociresult($st8,5);
$nilai=ociresult($st8,7);
if (strtoupper($satuan)=='MENIT') $total1=$total1+(($unit/60)*$nilai);
if (strtoupper($satuan)=='KBPS') $total2=$total2+($unit*$nilai);
if (strtoupper($satuan)=='SMS') $total3=$total3+($call*$nilai);
if (strtoupper($satuan)=='SSL') $total4=$total4+($call*$nilai);
if (strtoupper($satuan)=='SST') $total5=$total5+($call*$nilai);
$total_cost_pots=$total1+$total2+$total3+$total4+$total5;
echo $total_cost_pots;
?>
this script just for exp.Please convert step by step. for example
(1) remove inverted quotation mark ( ` )
(2) modify constraints syntax (PRIMARY KEY,UNIQUE KEY, KEY etc.) to [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/clauses002.htm#g1053592]Oracle constraints.
(3) modify some datatype to [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#i45441]Oracle datatype
(4) think how to convert auto_increment ([url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_6015.htm#i2067093]Sequence, [url http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7004.htm#i2235611]Beffore Trigger etc. on Oracle)
http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_packages.htm#sthref864
http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm -
not able to see ikm oracle incremental update and ikm oracle slowly changing dimensions under PHYSCIAL tab in odi 12c
But i'm able to see other IKM's please help me, how can i see themNope, It has not been altered.
COMPONENT NAME: LKM Oracle to Oracle (datapump)
COMPONENT VERSION: 11.1.2.3
AUTHOR: Oracle
COMPATIBILITY: ODI 11.1.2 and above
Description:
- Loading Knowledge Module
- Loads data from an Oracle Server to an Oracle Server using external tables in the datapump format.
- This module is recommended when developing interfaces between two Oracle servers when DBLINK is not an option.
- An External table definition is created on the source and target servers.
- When using this module on a journalized source table, the Journaling table is first updated to flag the records consumed and then cleaned from these records at the end of the interface. -
Issu for running insert statement in oracle procedure.
Hi expert,
I ran a oracle procedure with a insert statement inside as:
insert into table1 select....
but I got error message related to this insert statement as "SQLERRM= ORA-08103: object no longer exists"
I ran this statement separately in toad, no error message, but no data result from this execute.
please tell how to fix this issue.
Many Thanks,
Edited by: 918440 on 27-Jun-2012 8:04 AMHi friend,
my insert statement is as follows:
INSERT INTO HIROC_RU_FACT_S
select
pp.policy_fk,
pp.transaction_log_fk,
p.policy_no,
p.policy_type_code,
hiroc_rpt_user.hiroc_get_entity_name(pp.policy_fk,'POLHOLDER') policy_holder,
pp.risk_fk,
r.risk_base_record_fk,
r.entity_fk,
hiroc_sel_entity_risk_name2 (pp.risk_fk,r.entity_fk) risk_name,
substr(trim(nvl(r.county_code_used_to_rate,pth.issue_state_code)),1,2) rating_state_code,
hiroc_get_province_name(substr(trim(nvl(r.county_code_used_to_rate,pth.issue_state_code)),1,2), 'PROVINCE_CODE', 'L') rating_state_name,
hiroc_get_provicne_pol_prefix(substr(trim(nvl(r.county_code_used_to_rate,pth.issue_state_code)),1,2),p.policy_type_code) rating_prov_pol_prefix,
nvl(r.risk_cls_used_to_rate,pth.peer_groups_code) rating_peer_group_code,
hiroc_get_lookup_desc('PEER_GROUP',nvl(r.risk_cls_used_to_rate,pth.peer_groups_code),'L') rating_peer_group_name,
pth.policy_term_history_pk,
pth.term_base_record_fk,
to_char(pth.effective_from_date,'yyyy') term_effective_year,
c.coverage_pk,
c.coverage_base_record_fk,
pc.coverage_code,
c.product_coverage_code,
pc.long_description,
pp.coverage_component_code,
c.effective_from_date,
c.effective_to_date,
cls.coverage_code coverage_class_code,
cls.coverage_long_desc coverage_class_long_desc,
decode(pp.coverage_component_code ,'GROSS',cls.exposure_unit,null) exposure_unit, --hiroc_get_expos_units_by_cov(c.coverage_pk,pc.coverage_code,c.effective_from_date,c.effective_to_date) exposure_unit,
decode(pp.coverage_component_code ,'GROSS',cls.number_of_patient_day,null) number_of_patient_day,
pth.effective_from_date term_eff_from_date,
pth.effective_to_date term_eff_to_date,
pp.premium_amount premium_amount,
(case when (pc.coverage_code in ('CP','MC1','MC2','MC3','MC4','HR','F') or pc.coverage_code like 'ST%') and
pp.coverage_component_code != 'RISKMGMT' then
(nvl(pp.premium_amount,0))
else
0
end) primary_premium,
(hiroc_get_risk_units(hiroc_get_provicne_pol_prefix(substr(trim(nvl(r.county_code_used_to_rate,pth.issue_state_code)),1,2),p.policy_type_code)-- rating_prov_pol_prefix
,nvl(r.risk_cls_used_to_rate,pth.peer_groups_code) -- rating_peer_group_code
,cls.coverage_code --coverage_class_code
,decode(pp.coverage_component_code ,'GROSS',cls.exposure_unit,null)
,pp.premium_amount
,(case when (pc.coverage_code in ('CP','MC1','MC2','MC3','MC4','HR','F') or pc.coverage_code like 'ST%') and
pp.coverage_component_code != 'RISKMGMT' then
(nvl(pp.premium_amount,0))
else
0
end) -- primary_premium
,p.policy_type_code
,trunc(pth.effective_to_date))) risk_units
from proddw_mart.rmv_territory_makeup tm,
proddw_mart.rmv_premium_class_makeup pcm,
proddw_mart.rmv_product_coverage pc,
proddw_mart.rmv_coverage c,
proddw_mart.rmv_risk r,
proddw_mart.rmv_policy_term_history pth,
proddw_mart.rmv_policy p,
proddw_mart.rmv_transaction_log tl,
proddw_mart.rmv_policy_premium pp,
(select /* +rule */
p.policy_no,
p.policy_start_date,
p.policy_end_date,
r.risk_pk,
r.risk_description,
c.coverage_pk,
c.parent_coverage_base_record_fk,
pc.parent_product_covg_code,
pc.coverage_code,
pc.short_description coverage_short_desc,
pc.long_description coverage_long_desc,
c.exposure_unit,
pc.exposure_basis_code,
c.number_of_patient_day,
p.policy_start_date policy_effective_date,
p.policy_end_date policy_expiry_date,
c.effective_from_date,
c.effective_to_date,
to_char(c.effective_from_date,'YYYY') class_eff_year
from proddw_mart.odwr_coverage_only c
,proddw_mart.odwr_product_coverage pc
,proddw_mart.odwr_risk r
,proddw_mart.odwr_policy p
where pc.code = c.product_coverage_code
and pc.parent_product_covg_code is not null -- coverage classes only
and r.risk_pk = c.risk_base_record_fk
and c.accounting_to_date = to_date('1/1/3000','mm/dd/yyyy') -- only open records
and c.base_record_b = 'N'
and p.base_record_b = 'N'
and p.policy_pk = r.policy_fk
and p.accounting_to_date = to_date('1/1/3000','mm/dd/yyyy') -- only open records
group by p.policy_no,
p.policy_start_date,
p.policy_end_date,
r.risk_pk,
r.risk_description,
c.coverage_pk,
c.parent_coverage_base_record_fk,
pc.parent_product_covg_code,
pc.coverage_code,
pc.short_description, -- coverage_short_desc,
pc.long_description, -- coverage_long_desc,
c.exposure_unit,
pc.exposure_basis_code,
c.number_of_patient_day,
p.policy_start_date, -- policy_effective_date,
p.policy_end_date, -- policy_expiry_date,
c.effective_from_date,
c.effective_to_date,
to_char(c.effective_from_date,'YYYY')-- class_eff_year
) cls
where tm.risk_type_code = r.risk_type_code
and tm.county_code = r.county_code_used_to_rate
and tm.effective_from_date <= pp.rate_period_from_date
and tm.effective_to_date > pp.rate_period_from_date
and pcm.practice_state_code (+) = r.practice_state_code
and pcm.risk_class_code (+) = r.risk_cls_used_to_rate
and nvl(pcm.effective_from_date, pp.rate_period_from_date) <= pp.rate_period_from_date
and nvl(pcm.effective_to_date, to_date('01/01/3000','mm/dd/yyyy')) > pp.rate_period_from_date
and pc.code = c.product_coverage_code
and c.base_record_b = 'N'
and ( c.record_mode_code = 'OFFICIAL'
and (c.closing_trans_log_fk is null or
c.closing_trans_log_fk != tl.transaction_log_pk)
or c.record_mode_code = 'TEMP'
and c.transaction_log_fk = tl.transaction_log_pk )
and c.parent_coverage_base_record_fk is null
and c.effective_from_date < c.effective_to_date
and c.effective_from_date <= pp.rate_period_from_date
and c.effective_to_date > pp.rate_period_from_date
and c.accounting_from_date <= tl.accounting_date
and c.accounting_to_date > tl.accounting_date
and c.coverage_base_record_fk=pp.coverage_fk
and r.base_record_b = 'N'
and ( r.record_mode_code = 'OFFICIAL'
and (r.closing_trans_log_fk is null or
r.closing_trans_log_fk != tl.transaction_log_pk)
or r.record_mode_code = 'TEMP'
and r.transaction_log_fk = tl.transaction_log_pk )
and r.effective_from_date < r.effective_to_date
and r.effective_from_date <= pp.rate_period_from_date
and r.effective_to_date > pp.rate_period_from_date
and r.accounting_from_date <= tl.accounting_date
and r.accounting_to_date > tl.accounting_date
and r.risk_base_record_fk = pp.risk_fk
and pth.base_record_b = 'N'
and ( pth.record_mode_code = 'OFFICIAL'
and (pth.closing_trans_log_fk is null or
pth.closing_trans_log_fk != tl.transaction_log_pk)
or pth.record_mode_code = 'TEMP'
and pth.transaction_log_fk = tl.transaction_log_pk )
and pth.accounting_from_date <= tl.accounting_date
and pth.accounting_to_date > tl.accounting_date
and pth.term_base_record_fk = pp.policy_term_fk
and p.policy_pk = pp.policy_fk
and tl.transaction_log_pk = pp.transaction_log_fk
and pp.active_premium_b = 'Y'
and pp.rate_period_type_code in ('CS_PERIOD','SR_PERIOD')
and pp.rate_period_to_date > pp.rate_period_from_date
and tl.accounting_date <= sysdate
and p.policy_cycle_code = 'POLICY'
and substr(p.policy_no,1,1) <> 'Q'
and tl.transaction_log_pk = (select max(pp.transaction_log_fk)
from proddw_mart.rmv_policy_premium pp,proddw_mart.rmv_transaction_log tl2
where pth.term_base_record_fk = pp.policy_term_fk
and pp.transaction_log_fk = tl2.transaction_log_pk
and tl2.accounting_date <= sysdate )
and p.policy_type_code in ('LIABCRIME','MIDWIFE')
and pth.accounting_to_date = to_date('01/01/3000','mm/dd/yyyy') --<<<******* eliminates duplicates
and p.policy_no = cls.policy_no
-- and r.risk_pk = cls.risk_pk
and c.coverage_base_record_fk = cls.parent_coverage_base_record_fk(+)
and cls.effective_from_date < pth.effective_to_date -- from date less than period end date
and cls.effective_to_date > pth.effective_from_date -- to date greater than period start date
and cls.policy_effective_date < pth.effective_to_date -- from date less than period end date
and cls.policy_expiry_date > pth.effective_from_date -- to date greater than period start date
group by pp.policy_fk,
pp.transaction_log_fk,
p.policy_no,
p.policy_type_code,
pp.risk_fk,
r.risk_base_record_fk,
r.entity_fk,
substr(trim(nvl(r.county_code_used_to_rate,pth.issue_state_code)),1,2), -- rating_state_code,
r.county_code_used_to_rate,
pth.issue_state_code,
nvl(r.risk_cls_used_to_rate,pth.peer_groups_code) , -- rating_peer_group_code,
r.risk_cls_used_to_rate,
pth.peer_groups_code,
pth.policy_term_history_pk,
pth.term_base_record_fk,
to_char(pth.effective_from_date,'yyyy'), --term_effective_year,
c.coverage_pk,
c.coverage_base_record_fk,
pc.coverage_code,
c.product_coverage_code,
pc.long_description,
pp.coverage_component_code,
c.effective_from_date,
c.effective_to_date,
cls.coverage_code, -- coverage_class_code,
cls.coverage_long_desc, -- coverage_class_long_desc,
decode(pp.coverage_component_code ,'GROSS',cls.exposure_unit,null),-- exposure_unit,
decode(pp.coverage_component_code ,'GROSS',cls.number_of_patient_day,null), -- number_of_patient_day,
pth.effective_from_date, --term_eff_from_date,
pth.effective_to_date, --, --term_eff_to_date,
pp.premium_amount ;Edited by: BluShadow on 27-Jun-2012 16:12
added {noformat}{noformat} tags for readability. PLEASE READ {message:id=9360002} AS PREVIOUSLY REQUESTED! & -
- I have a Product list box (asp.net) used as multiple selected values for a parameter.
- The Product ID is defined in the Oracle procedure as NUMBER data type.
- In my crystal report, I have a parameter field allow multiple values as p_product_id type as Number. This is the code in my Record Selection Formula for the report:
({?p_product_id}[1] = -1 OR {Procedure_name.product_id} in {p_product_id})
- In C#, this is my code
List<decimal?> productUnit = new List<decimal?>();
int counter = 0;
decimal prod;
for (int i = 0; i < lstProducts.Items.Count; i++)
if (lstProducts.Items[i].Selected)
if (decimal.TryParse(lstProduct.Items[i].Value, out prod))
productUnit.Add((decimal?)prod);
counter++;
if (counter == 0)
productUnit.Add(-1);
ReportingDAO rDataFactory = new ReportingDAO();
retVal = rDataFactory.GetProductReport(productUnit);
public CrystalDecisions.CrystalReports.Engine.ReportDocument GetProductReport(List<decimal?> productUnit)
CrystalDecisions.CrystalReports.Engine.ReportDocument retVal = new rptProductDownload();
ReportLogon rptLog = new ReportLogon();
rptLog.Logon(retVal, "RPT_PRODUCT_DOWNLOAD");
retVal.SetParameterValue("p_product_id", productUnit);
I keep having the "Value does not fall within the expected range" when I debug. My question is, is the data type I used for procedure/Crystal report/ and C# correct ? I always have problem with the data type. Any help would be
appreciated
Thank youHi progGirl,
Thank you for your post, but Microsoft doesn't provide support for CrystalReport now. Please post your question in SAP official site here:
http://forums.sdn.sap.com/forum.jspa?forumID=313
Thank you for your understanding.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
How to call an Oracle Procedure and get a return value in Php
Hi Everyone,
Has anyone tried calling an Oracle procedure from Php using the ora functions and getting the return value ? I need to use the ora funtions (no oci)because of compatibility and oracle 7.x as the database.
The reason why I post this here is because the ora_exec funtion is returning FALSE but the error code displayes is good. Is this a bug in the ora_exec funtion ?
My code after the connection call is as follows:
$cur = ora_open($this->conn);
ora_commitoff($this->conn);
$requestid = '144937';
echo $requestid;
$rc = ora_parse($cur, "begin p_ins_gsdata2
(:requestid, :returnval); end;");
if ($rc == true) {
echo " Parse was successful ";
$rc2 = ora_bind ($cur, "requestid", ":requestid", 32, 1);
if ($rc2 == true) echo " Requestid Bind Successful ";
$rc3 = ora_bind ($cur, "returnval", ":returnval", 32, 2);
if ($rc3 == true) echo " Returnval Bind Successful ";
$returnval = "0";
$rc4 = ora_exec($cur);
echo " Result = ".$returnval." ";
if ($rc4 == false) {
echo " Exec Returned FALSE ";
echo " Error = ".ora_error($cur);
echo " ";
echo "ErrorCode = ".ora_errorcode($cur);
echo "Error Executing";
ora_close ($cur);
The Oracle procedure has a select count from a table and it returns the number of records in that table. It's defined as:
CREATE OR REPLACE procedure p_ins_gsdata2 (
p_requestid IN varchar2 default null,
p_retcode OUT varchar2)
as
BEGIN
SELECT COUNT (*) INTO p_retcode
FROM S_GSMRY_DATA_SURVEY
WHERE request_id = p_requestid ;
COMMIT;
RETURN;
END;
Nothing much there. I want to do an insert into a table,
from the procedure later, but I figured that I start with a select count since it's simpler.
When I ran the Php code, I get the following:
144937
Parse was successful
Requestid Bind Successful
Returnval Bind Successful
Result = 0
Exec Returned FALSE
Error = ORA-00000: normal, successful completion -- while
processing OCI function OBNDRA
ErrorCode = 0
Error Executing
I listed the messages on separate lines for clarity. I don't understand why it parses and binds o.k. but the exec returns false.
Thanks again in advance for your help. Have a great day.
Regards,
Rudiretcode=`echo $?`is a bit convoluted. Just use:
retcode=$?I see no EOF line terminating your input. Your flavour of Unix might not like that - it might ignore the command, though I'd be surprised (AIX doesn't).
replace the EXEC line with :
select 'hello' from dual;
and see if you get some output - then you know if sqlplus commands are being called from your script. You didn't mentioned whether you see the banner for sqlplus. Copy/paste the output that you get, it will give us much more of an idea. -
Problem in XML Parsing via oracle procedure...
Hi,
I wrote one oracle procedure for xml parsing.
I have one valid xml file which has "encode UTF-8". The XML file contains some comments also. While we are parsing the xml file at that time it is not parse successfully and also it is not giving any error. After the following line it is skip rest of the codes(lines).
dbms_xmlparser.parseclob(l_parser, l_clob);
At the end of the xml file there are some comments which is like "<!-- abc --> ".
When I am changing the "encode UTF-8 to ISO-88596-1" & removing the comments which wrote on bottom of the file then its working fine, but the files which we are getting from the system is contains the encode UTF-8 and we don't want to preprocess on that xml files. Even if we will do that via shell script or perl script then it will be overhead to the system and in a single stroke our system will parse more than 5k xml files, so if we will do some preprocess on it, it will take some more time approx 1-2 minutes extra.
So, If someone knows any solution of this problem, then please guide & help me on this.
My xml file structure is as follows:-
<?xml version="1.0" encoding="UTF-8"?>
<mcd xmlns:HTML="http://www.w3.org/TR/REC-xml">
<child>
<child1>32.401 V5.5</child1>
<child2>ZoneGate</child2>
</child>
<mc>
<newid>
<id>12</id>
</newid>
<mindex>
<date>20111102180000</date>
<mt>abc1</mt>
<mt>abc2</mt>
<mvalue>
<r>val_1</r>
<r>val_2</r>
</mvalue>
</mindex>
</mc>
</mcd>
<!--
ALARM STATUS
morning 10
afternoon 14
evening 18
night 22
-->
<!--
PARAM:EID = 1
PARAM:GId = 3
PARAM:GSId = 0
--!>
And my oracle procedure is as follows:-
create or replace procedure loadXMLtotable(dir_name IN varchar2, xmlfile IN varchar2) AS
-- Defining the variables
ecode NUMBER;
emesg VARCHAR2(200);
l_bfile BFILE;
l_clob CLOB;
l_dest_offset INTEGER:=1;
l_src_offset INTEGER:=1;
l_Char_set_id NUMBER := NLS_CHARSET_ID('UTF8');
l_lang_context INTEGER := dbms_lob.default_lang_ctx;
l_warning INTEGER;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
l_nl1 dbms_xmldom.DOMNodeList;
l_nl2 dbms_xmldom.DOMNodeList;
l_n dbms_xmldom.DOMNode;
node1 dbms_xmldom.DOMNode;
colid integer ; -- column id used for identifying which column it belongs.
l_xmltype XMLTYPE;
sub_xmltype XMLTYPE;
num_nodes number;
l_index PLS_INTEGER;
l_subIndex PLS_INTEGER;
starttime Date;
temp_datatime VARCHAR(25);
columnname varchar2(300);
columnvalue varchar2(300);
-- creating a Type which is a type of "test_hem" table RowType, which I created in SVN server
TYPE tab_type IS TABLE OF test_hem%ROWTYPE;
t_tab tab_type := tab_type();
BEGIN
-- Passing the xmlfile and virtual directory name which we gave at the time of directory creation
l_bfile := BFileName('MY_FILES', xmlfile);
dbms_lob.createtemporary(l_clob, cache=>FALSE);
dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
--dbms_lob.loadFromFile(dest_lob => l_clob,
-- src_lob => l_bfile,
-- amount => dbms_lob.getLength(l_bfile));
dbms_lob.loadclobfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile),
l_dest_offset, l_src_offset, l_Char_set_id, l_lang_context, l_warning);
dbms_lob.close(l_bfile);
-- make sure implicit date conversions are performed correctly
dbms_session.set_nls('NLS_DATE_FORMAT','''YYYY-MON-DD HH24:MI:SS''');
dbms_output.put_line('Date format set');
-- Create a parser.
l_parser := dbms_xmlparser.newParser;
dbms_output.put_line('output 1');
-- Parse the document and create a new DOM document.
dbms_xmlparser.parseclob(l_parser, l_clob);
dbms_output.put_line(' passed parsing');
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_output.put_line(' passed getdocument');
-- Free resources associated with the CLOB and Parser now they are no longer needed.
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
-- Get a list of all the EMP nodes in the document using the XPATH syntax.
l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/child');
-- Loop through the list and create a new record in a tble collection
FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
l_n := dbms_xmldom.item(l_nl1, cur_sel);
t_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
dbms_xslprocessor.valueOf(l_n,'child1/text()',t_tab(t_tab.last).country);
-- putting the state and vendorname into the table rowtype
dbms_xslprocessor.valueOf(l_n,'child2/text()',t_tab(t_tab.last).state);
END LOOP;
-- getting the version and putting into the table rowtype
l_n := dbms_xslprocessor.selectSingleNode(dbms_xmldom.makeNode(l_doc),'//mcd/mc/newid/id');
dbms_xslprocessor.valueOf(l_n,'id/text()',t_tab(t_tab.last).id);
-- selecting the nodes whose starting tag is "mindex"
l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/mc/mindex');
-- checking the total number of nodes whose starting through "mi"
num_nodes := dbms_xmldom.getLength(l_nl1);
l_index := 1;
-- For loop to iterate the nodes.
FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
-- whole current node is selected and storing into the node1 variable
node1 := dbms_xmldom.item(l_nl1, cur_sel);
-- setting the xmltype as AL32UTF8
l_xmltype := xmltype(l_bfile, nls_charset_id('AL32UTF8'));
-- if selecting parent node containing the mt child node then only proceed else skip that parent node.
IF (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r') > 0) Then
-- fetch the datatime, convert it into to_date format and store it into table rowtype
temp_datatime := dbms_xslprocessor.valueOf(node1, 'date/text()');
t_tab(t_tab.last).data_time := to_char(to_date(temp_datatime, 'YYYYMmcDHH24MISS'));
l_subIndex := 1;
while (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt[' || l_subIndex || ']') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r['|| l_subIndex || ']') > 0 ) LOOP
-- getting mt and corresponging mvalue/r values
dbms_xslprocessor.valueOf(node1,'mt[' || l_subIndex || ']/text()',columnname);
dbms_xslprocessor.valueOf(node1,'mvalue/r[' || l_subIndex || ']/text()',columnvalue);
l_subIndex := l_subIndex + 1;
-- getting the column to which this mapping belongs.
select columnid into colid from abc_table where columnname=name;
CASE colid
WHEN 1 THEN t_tab(t_tab.last).col1 := columnvalue;
WHEN 2 THEN t_tab(t_tab.last).col2 := columnvalue;
WHEN 3 THEN t_tab(t_tab.last).col3 := columnvalue;
ELSE dbms_output.put_line('No column mapping for counter ' || columnname) ;
END CASE; -- end of case statement.
END LOOP;
-- Insert data into the real table from the table collection.
FORALL i IN t_tab.first .. t_tab.last
INSERT INTO test_hem VALUES t_tab(i);
END IF;
l_index := l_index + 1;
COMMIT;
END LOOP;
commit;
EXCEPTION
WHEN OTHERS THEN
ecode := SQLCODE;
emesg := SQLERRM;
dbms_output.put_line(TO_CHAR(ecode) || '-' || emesg);
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
END;Sorry Odie,
I am new to this site as well as PL/SQL. I am giving additional details which you had mentioned in your last comments.
our Oracle Database version is "10.2.0.4.0"
The structure of target table Instrument_Details is as follows:
Create table Instrument_Details (
instrument_id Integer Primary Key,
provider_name Varchar2(32),
version_number Varchar2(32),
location_id Integer,
installation_date Date,
granularity Integer,
time_out Integer );
Note:- Here test_hem is alias of Instrument_details.
Here instrument_id is a primary key.
provider_name contains the child2 xml tag value.
version_number contains the child1 xml tag value.
location_id contains the newid/id value which is map to other table which fetching the location name corresponding to the location_id.
installation_date contains the date xml tag value.
Now we have created one mapping tables where we mapped the xml tag values "mt" with table column name means "abc1 = granularity", "abc2 = time_out" in that table.
these table column value are written under mvalue xml tag.
_Our Database Character set is_:-
NLS_CHARACTERSET WE8ISO8859P1
Now as you suggest me to format your code. I am writing the xml code and procedure code again.
My xml file structure is as follows:-
<?xml version="1.0" encoding="UTF-8"?>
<mcd xmlns:HTML="http://www.w3.org/TR/REC-xml">
<child>
<child1>32.401 V5.5</child1>
<child2>ZoneGate</child2>
</child>
<mc>
<newid>
<id>12</id>
</newid>
<mindex>
<date>20111102180000</date>
<mt>abc1</mt>
<mt>abc2</mt>
<mvalue>
<r>val_1</r> -- here val_1 and val_2 are numeric values
<r>val_2</r>
</mvalue>
</mindex>
</mc>
</mcd>
<!--
ALARM STATUS
morning 10
afternoon 14
evening 18
night 22
-->
<!--
PARAM:EID = 1
PARAM:GId = 3
PARAM:GSId = 0
--!> And my oracle procedure is as follows:-
create or replace procedure loadXMLtotable(dir_name IN varchar2, xmlfile IN varchar2) AS
-- Defining the variables
ecode NUMBER;
emesg VARCHAR2(200);
l_bfile BFILE;
l_clob CLOB;
l_dest_offset INTEGER:=1;
l_src_offset INTEGER:=1;
l_Char_set_id NUMBER := NLS_CHARSET_ID('UTF8');
l_lang_context INTEGER := dbms_lob.default_lang_ctx;
l_warning INTEGER;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
l_nl1 dbms_xmldom.DOMNodeList;
l_nl2 dbms_xmldom.DOMNodeList;
l_n dbms_xmldom.DOMNode;
node1 dbms_xmldom.DOMNode;
colid integer ; -- column id used for identifying which column it belongs.
l_xmltype XMLTYPE;
sub_xmltype XMLTYPE;
num_nodes number;
l_index PLS_INTEGER;
l_subIndex PLS_INTEGER;
starttime Date;
temp_datatime VARCHAR(25);
columnname varchar2(300);
columnvalue varchar2(300);
-- creating a Type which is a type of "Instrument_Details" table RowType, which I created in SVN server
TYPE tab_type IS TABLE OF Instrument_Details%ROWTYPE;
t_tab tab_type := tab_type();
BEGIN
-- Passing the xmlfile and virtual directory name which we gave at the time of directory creation
l_bfile := BFileName('MY_FILES', xmlfile);
dbms_lob.createtemporary(l_clob, cache=>FALSE);
dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
--dbms_lob.loadFromFile(dest_lob => l_clob,
-- src_lob => l_bfile,
-- amount => dbms_lob.getLength(l_bfile));
dbms_lob.loadclobfromfile(l_clob, l_bfile, dbms_lob.getlength(l_bfile),
l_dest_offset, l_src_offset, l_Char_set_id, l_lang_context, l_warning);
dbms_lob.close(l_bfile);
-- make sure implicit date conversions are performed correctly
dbms_session.set_nls('NLS_DATE_FORMAT','''YYYY-MON-DD HH24:MI:SS''');
dbms_output.put_line('Date format set');
-- Create a parser.
l_parser := dbms_xmlparser.newParser;
dbms_output.put_line('output 1');
-- Parse the document and create a new DOM document.
dbms_xmlparser.parseclob(l_parser, l_clob);
*-- Below lines are skipping....*
dbms_output.put_line(' passed parsing');
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_output.put_line(' passed getdocument');
-- Free resources associated with the CLOB and Parser now they are no longer needed.
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
-- Get a list of all the EMP nodes in the document using the XPATH syntax.
l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/child');
-- Loop through the list and create a new record in a tble collection
FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
l_n := dbms_xmldom.item(l_nl1, cur_sel);
t_tab.extend;
-- Use XPATH syntax to assign values to he elements of the collection.
dbms_xslprocessor.valueOf(l_n,'child1/text()',t_tab(t_tab.last).country);
-- putting the state and vendorname into the table rowtype
dbms_xslprocessor.valueOf(l_n,'child2/text()',t_tab(t_tab.last).state);
END LOOP;
-- getting the version and putting into the table rowtype
l_n := dbms_xslprocessor.selectSingleNode(dbms_xmldom.makeNode(l_doc),'//mcd/mc/newid/id');
dbms_xslprocessor.valueOf(l_n,'id/text()',t_tab(t_tab.last).id);
-- selecting the nodes whose starting tag is "mindex"
l_nl1 := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'//mcd/mc/mindex');
-- checking the total number of nodes whose starting through "mi"
num_nodes := dbms_xmldom.getLength(l_nl1);
l_index := 1;
-- For loop to iterate the nodes.
FOR cur_sel IN 0 .. dbms_xmldom.getLength(l_nl1) - 1 LOOP
-- whole current node is selected and storing into the node1 variable
node1 := dbms_xmldom.item(l_nl1, cur_sel);
-- setting the xmltype as AL32UTF8
l_xmltype := xmltype(l_bfile, nls_charset_id('AL32UTF8'));
-- if selecting parent node containing the mt child node then only proceed else skip that parent node.
IF (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r') > 0) Then
-- fetch the datatime, convert it into to_date format and store it into table rowtype
temp_datatime := dbms_xslprocessor.valueOf(node1, 'date/text()');
t_tab(t_tab.last).data_time := to_char(to_date(temp_datatime, 'YYYYMmcDHH24MISS'));
l_subIndex := 1;
while (l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mt[' || l_subIndex || ']') > 0 and l_xmltype.Existsnode('//mcd/mc/mindex[' || l_index || ']/mvalue/r['|| l_subIndex || ']') > 0 ) LOOP
-- getting mt and corresponging mvalue/r values
dbms_xslprocessor.valueOf(node1,'mt[' || l_subIndex || ']/text()',columnname);
dbms_xslprocessor.valueOf(node1,'mvalue/r[' || l_subIndex || ']/text()',columnvalue);
l_subIndex := l_subIndex + 1;
-- getting the column to which this mapping belongs.
select columnid into colid from abc_table where columnname=name;
CASE colid
WHEN 1 THEN t_tab(t_tab.last).col1 := columnvalue;
WHEN 2 THEN t_tab(t_tab.last).col2 := columnvalue;
WHEN 3 THEN t_tab(t_tab.last).col3 := columnvalue;
ELSE dbms_output.put_line('No column mapping for counter ' || columnname) ;
END CASE; -- end of case statement.
END LOOP;
-- Insert data into the real table from the table collection.
FORALL i IN t_tab.first .. t_tab.last
INSERT INTO test_hem VALUES t_tab(i);
END IF;
l_index := l_index + 1;
COMMIT;
END LOOP;
commit;
EXCEPTION
WHEN OTHERS THEN
ecode := SQLCODE;
emesg := SQLERRM;
dbms_output.put_line(TO_CHAR(ecode) || '-' || emesg);
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
END;Thanks in advance for your help... -
Issue with IN parameter of Oracle Procedure returning two RefCursors...
Hi all,
I'm having a nightmare with an Oracle procedure that takes one input parameter and returns two RefCursors as outputs. I recently got help in this forum getting a procedure to work that took no inputs but returned two refcursors and that's still working fine. So, for my current issue I have a procedure defined as follows:
PROCEDURE getQueueInfo(domainKey char, importQueues OUT ODPNet.refcur, exportQueues OUT ODPNet.refcur) IS
BEGIN
OPEN importQueues FOR SELECT
source_key, source_applid,
import_status(source_key) as status,
time_added, time_processed
FROM wm_import_source_header
WHERE source_id = domainKey
ORDER BY source_key DESC;
OPEN exportQueues FOR SELECT
h.source_key, d.source_applid,
export_status(h.source_key) as status,
d.source_wire_code, d.destination_wire_code, h.time_added,
h.time_transmitted
FROM wm_export_source_header h, wm_export_source_data d
WHERE h.source_key = d.source_key
and d.source_id = domainKey
ORDER BY h.source_key DESC;
END getQueueInfo;This is defined within a package called ODPNet as with my previous procedure and all works fine (I can execute within Oracle SQL Developer and it returns the expected results). Within my .NET application my code is as follows:
try
using (OracleConnection conn = new OracleConnection(connString))
using (OracleCommand comm = new OracleCommand())
comm.CommandText = "ODPNet.getQueueInfo";
comm.CommandType = CommandType.StoredProcedure;
comm.Connection = conn;
OracleParameter domainKey = new OracleParameter();
OracleParameter importQueues = new OracleParameter();
OracleParameter exportQueues = new OracleParameter();
domainKey.OracleDbType = OracleDbType.Char;
importQueues.OracleDbType = OracleDbType.RefCursor;
exportQueues.OracleDbType = OracleDbType.RefCursor;
domainKey.Value = "UKBD72";
domainKey.Direction = ParameterDirection.Input;
importQueues.Direction = ParameterDirection.Output;
exportQueues.Direction = ParameterDirection.Output;
comm.Parameters.Add(domainKey);
comm.Parameters.Add(importQueues);
comm.Parameters.Add(exportQueues);
conn.Open();
comm.ExecuteNonQuery();
OracleDataReader dr1 = ((OracleRefCursor)importQueues.Value).GetDataReader();
OracleDataReader dr2 = ((OracleRefCursor)exportQueues.Value).GetDataReader();
if (dr1.HasRows)
while (dr1.Read())
result6 += dr1["source_applid"].ToString() + "<br>";
else
result6 += "No Rows";
if (dr2.HasRows)
while (dr2.Read())
result7 += dr2["source_applid"].ToString() + "<br>";
else
result7 += "No Rows";
catch (Exception ex)
result6 = ex.ToString();
}The value I want to submit as the IN parameter of the procedure is "UKBD72". but I'm really not sure how to apply this and then return my two refcursors into separate datareaders (except for the input parameter stuff the code above is exactly what I did with the other procedure that returned two ref cursors and still works fine). When I run this code I get no errors, I just get told that each DataReader has no rows returned, which shouldn't be right.
Any help with this would be hugely appreciated.
Cheers,
SebSorry folks, after staring at this over and over, eventually going to sleep and coming back to it with some fresh eyes I realised I was just being a complete idiot - I was feeding the procedure different data in the .NET app than I was when testing in Oracle SQL Developer. Low and behold once I gave it the right data it worked!
Silly me... -
How to get resultset from oracle procedure use ejb3
how to get resultset from oracle procedure use ejb3
i know oracle procedure should like this
Create or replace PROCEDURE resultset_test(
aaa IN NUMBER,
bbb OUT sys_refcursor) ....
but what s the ejb3 scripts looks like? please give me an example or link~
ths- there are no EJB3 scripts, only compiled application code
- the part of the EJB spec that deals with databases is called the Java Persistence API, but likely you are just looking for the JDBC API.
Now you should know what to Google to get your "example script": "java jdbc oracle procedure" -
Problem in calling oracle procedure from java
Oracle procedure with the following parameters.
CREATE OR REPLACE PROCEDURE CREDITED_TO_STORE_INSERT (P_CUST# IN NUMBER,
P_INV_DATE IN DATE,
P_MEMO# IN NUMBER,
P_SESS_ID IN VARCHAR2 ) IS
BEGIN
/*.........Procedure Body with select and insert statements there no OUT or return variable/value......*/
END;
Now i am calling this procedure with the java code in java.
public boolean execProcedure(String storeNo, String invoiceDate, String claimNo, String sessionID) throws SQLException {
CallableStatement cstmt = null;
java.sql.Date invicDate = this.StringToDate(invoiceDate);
try
cstmt = conn.prepareCall("{call WEBUSER.CREDITED_TO_STORE_INSERT(?,?,?,?,?,?)}");
cstmt.setInt(1, Integer.parseInt(storeNo));
cstmt.setDate(2, invicDate);
cstmt.setInt(3, Integer.parseInt(claimNo));
cstmt.setString(4, sessionID);
cstmt.execute();
catch (Exception e)
System.out.println (e);
} // catch (Exception e)
finally
try
cstmt.close();
catch (Exception ex)
} // catch (Exception ex)
} // finally
return true;
But it will return the following exception.
[STDOUT] java.sql.SQLException: Missing IN or OUT parameter at index:: 5
i don't know why :( please help me ...your procedure has 4 parameters but in the prepared statement you define 6 placeholders
-
Error in odi- IKM oracle incremental update
hi,
i am integrating Oracle to Oracle databse using ODI.
i am using IKM Oracle Incremental Update and i am having the following error:
ORA-01747: invalid user.table.column, table.column, or column specification
for the description below
update EBS.SY_NAMADD T
set (
) =
select
from EBS.I$_SY_NAMADD S
where T.NADCOD =S.NADCOD
where (NADCOD)
in (
select NADCOD
from EBS.I$_SY_NAMADD
where IND_UPDATE = 'U'
since in the SQL in the EST there is no column specify it gin=ving me this error.
should i have specify it somewhere
thanks a lot
nazeedahhi,
another error is taht when i set the control to Yes unser IKM and in the control tab i have chosen :CKM oracle.
i am having an error while creating teh table below
create table EBS.SNP_CHECK_TAB
CATALOG_NAME VARCHAR2(100 CHAR) NULL ,
SCHEMA_NAME VARCHAR2(100 CHAR) NULL ,
RESOURCE_NAME VARCHAR2(100 CHAR) NULL,
FULL_RES_NAME VARCHAR2(100 CHAR) NULL,
ERR_TYPE VARCHAR2(1 CHAR) NULL,
ERR_MESS VARCHAR2(250 CHAR) NULL ,
CHECK_DATE DATE NULL,
ORIGIN VARCHAR2(100 CHAR) NULL,
CONS_NAME VARCHAR2(35 CHAR) NULL,
CONS_TYPE VARCHAR2(2 CHAR) NULL,
ERR_COUNT NUMBER(10) NULL
error: missing parenthese
please help
nazeedah
Maybe you are looking for
-
Swf site uploading using dreamweaver
I made a site using indesign and saved it as .swf but i don't know how to upload this. It doesnt open in dreamweaver and i inserted and tried different things, but it doesnt work and i don't know how. Does anyone know how to upload this kind of docum
-
Passing Material text to BAPI BAPI_SALESORDER_CREATEFROMDATE2
Hi all, I am making use of BAPI_SALESORDERCREATE_FROMDAT2 for creating a sales order. for some orders i need to pass even the material text. I am not able to find the field in the BAPI structures to pass the material text. PLease help me solving this
-
I created a public folder, but when using MFCmapi and I try to access the public folder using the administrator account I get the following error: Error: Code: MAPI_E_FAILONEPROVIDER == 0x8004011D Function CallOpenMsgStore( lpMAPISession, (ULONG_PTR
-
HT5312 Security question reset and adding a rescue email
I do not see the link to have my security answers sent to my email, nor do I see the rescue email tab anywhere,can you please help me on this?
-
Until version 11, I was able to sync my iphone to my MBP and the Cloud for all my personal and internet calendars, and to my work PC's Outlook for my single work calendar. This option appears to have been removed. I can no longer select that singal