Hi All,
I am new to hibernate.
Can somebody please tell me in simple steps how can I call a oracle procedure with a out parameter as a oracle type from java:
CREATE OR REPLACE TYPE user_type as object(
User_id Number(38),
title_name VARCHAR2(255),
FIRST_NAME VARCHAR2(255),
LAST_NAME VARCHAR2(255),
POSTAL_CODE VARCHAR2(255),
email VARCHAR2(255),
DOB Date);
/
Here's the procedure I want to call-
CREATE OR REPLACE procedure user_details(User_Type_Table OUT User_Type_Tab)
as
TYPE UserCurTyp IS REF CURSOR;
User_cv UserCurTyp;
v_User_id Number(38);
v_title_name VARCHAR2(255);
v_FIRST_NAME VARCHAR2(255);
v_LAST_NAME VARCHAR2(255);
v_POSTAL_CODE VARCHAR2(255);
v_email VARCHAR2(255);
v_DOB Date;
i Number;
v_max_sent_date Date;
v_max_Mod_date Date;
v_count Number;
BEGIN
OPEN User_cv FOR select
EUID.User_ID,
NTL.title_name,
EAPD.first_name,
EAPD.last_name,
EAPD.postal_code,
EUID.email,
EUID.dob
from NI_Title_Lookup NTL,
ERSMD_Address_Physical_Data EAPD,
ERSMD_User_Info_Data EUID
where NTL.title_id = EAPD.Title_id
and EAPD.ID = EUID.ID
and euid.user_id = 50
and (EUID.User_ID in (select user_id
from NI_USER_EMR_AUDIT NUEA
where EUID.User_id = NUEA.User_id
and status ='N'
and nvl(DELETED_IND,0) = 0
and sent_date =(select Max(sent_date)
from NI_USER_EMR_AUDIT NUEA1
where NUEA1.User_id = NUEA.User_id))
or EUID.User_ID not in (select user_id
from NI_USER_EMR_AUDIT NUEA
where EUID.User_id = NUEA.User_id));
i := 1;
User_Type_Table := User_Type_Tab();
Loop
Fetch User_cv into
v_User_id, v_title_name, v_FIRST_NAME, v_LAST_NAME, v_POSTAL_CODE, v_email, v_DOB;
exit when User_cv%notFound;
Select nvl(Max(sent_date), sysdate) into v_max_sent_date
from NI_USER_EMR_AUDIT NUEA
where NUEA.User_id = v_User_id;
Select Count(1) into v_count
from NI_USER_Bulletin_Info NUBI
where User_id = v_user_id;
If v_count > 0 Then
Select Greatest(Date_Created, Date_Modified, Date_Deleted) into v_max_Mod_date
from NI_USER_Bulletin_Info NUBI
where User_id = v_user_id;
else
v_max_Mod_date := v_max_sent_date+1;
end if;
If v_max_Mod_date > v_max_sent_date Then
User_Type_Table.extend;
User_Type_Table(i) := User_Type(v_User_id, v_title_name, v_FIRST_NAME, v_LAST_NAME, v_POSTAL_CODE, v_email, v_DOB);
i := i+1;
End if;
End loop;
Close user_cv;
End;
/
Please be as elaborate as possible.
Thanks in advance!
|