How to use REF cursor with toplink
Hi,
I have a stored proc has a out variable which is a REF CURSOR.
How to read my cursor with toplink?
I have got it. Here is the solution.
UnitOfWork uow= dbSession.acquireUnitOfWork();
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("smart.getCompanyStruct");
call.addNamedArgument("xnrid");
call.useNamedCursorOutputAsResultSet("cpy");
DataReadQuery query = new DataReadQuery();
query.setCall(call);
Vector parameters = new Vector();
query.addArgument("xnrid");
parameters.add(new Long(5009L));
Vector obj = (Vector) uow.executeQuery(query, parameters);
Vector contains result ser of the cursor
Gurcan
Similar Messages
-
How to use join queries with toplink
Hi there
I'm using toplink within the JDeveloper 10.1.3.3. with great success.
Now, I need to query multiple tables using a join SQL.
How do you configure toplink now without creating database views?
I could not find an easy with within the JDev IDE or from google search.
Any help please?
Thanks
HenkieIn a TopLink query you can query across any relationship to another object. You can also join or batch read the object's relationship using the ObjectLevelReadQuery and ReadAllQuery API (see TopLink documentation).
You can also map a class to multiple tables.
-- James : http://www.eclipselink.org -
How to use aggregate function with Toplink
Hi
My question is how can I get the following select when using Toplink-EJB.3:
SELECT MAX(fieldname) FROM tablename;
ThanasiHi KAVI PRIYA,
if date is not in cannonical format, how can we change it in BI publisher, then how to calcualte minimum and as well as maximum.
please advise me,
Thanks,
Sri -
Difference Ref cursor with/with out using clause
Hi everyone,
When I am using dynamic sql with USING clause ,the results are not sorted in Ascending order.
DECLARE
TYPE emp_refcursor IS REF CURSOR;
emp_rc emp_refcursor;
TYPE v_emp_id IS TABLE OF number INDEX BY PLS_INTEGER;
TYPE v_last_name IS TABLE OF varchar2(50) INDEX BY binary_integer;
V_empno v_emp_id;
v_ename v_last_name;
p_deptno number := &U_DEPTNO;
v_limit number := 10;
v_ordcolumn varchar2(20) := 'employee_id';
v_stmt varchar2(1000);
BEGIN
v_stmt :=
'select employee_id,last_name from employees
where department_id = :x order by :y ';
dbms_output.put_line(v_stmt);
OPEN emp_rc FOR v_stmt USING p_deptno,v_ordcolumn;
LOOP
FETCH emp_rc BULK COLLECT INTO v_empno,v_ename LIMIT v_limit;
EXIT WHEN v_empno.count = 0;
FOR I IN v_empno.first .. v_empno.last
LOOP
dbms_output.put_line(v_empno(i)||' '||v_ename(i));
END LOOP;
END LOOP;
END;
When I use dynamic sql with out USING cluase,results are sorted in Ascending order.
DECLARE
TYPE emp_refcursor IS REF CURSOR;
emp_rc emp_refcursor;
TYPE v_emp_id IS TABLE OF number INDEX BY PLS_INTEGER;
TYPE v_last_name IS TABLE OF varchar2(50) INDEX BY binary_integer;
V_empno v_emp_id;
v_ename v_last_name;
p_deptno number := &U_DEPTNO;
v_limit number := 10;
v_ordcolumn varchar2(20) := 'employee_id';
v_stmt varchar2(1000);
BEGIN
v_stmt :=
'select employee_id,last_name from employees
where department_id = '||p_deptno ||
' order by '||v_ordcolumn;
dbms_output.put_line(v_stmt);
OPEN emp_rc FOR v_stmt;
LOOP
FETCH emp_rc BULK COLLECT INTO v_empno,v_ename LIMIT v_limit;
EXIT WHEN v_empno.count = 0;
FOR I IN v_empno.first .. v_empno.last
LOOP
dbms_output.put_line(v_empno(i)||' '||v_ename(i));
END LOOP;
END LOOP;
END;
P.S :---- department_id (used) = 50;
Please can some one explain why this is happening like this.
Thanks
Raghu
--------------------------------------------------------------------------------Hi sundar,
I am new to oracle and learning/trying to get the same output by using differnt methods,rather than using FOR LOOP ,I tried to use ref cursor with dynamic sql.I am in a belief that ref cursor's with dynamic sql are faster than FOR LOOP,irrespective of the size of data.Can you correct me if I am wrong.
Coming back to ur reply,how should my statement look like,when using ref cursor
with USING claus to sort data by asc/desc order.
Thanks in advance
Raghu -
How to update data returned using REF CURSOR
Hi all,
I am trying to update updated data in a gridview but the update button seem to do nothing as i retrieve data using REF CURSOR.
Let me describe the architecture of my application first. I'm trying to implement best practice whenever possible. I am following the data access tutorial published in www.asp.net , the only difference is that i have an Oracle (10g) database. So I split my application into three layers, data access, business logic, and presentation layer. I'm also writing all queries in an Oracle package.
So I have my Oracle packages that perform CRUD operations. Then I have an xsd file that define dataTable based on the package procedure. My business logic layer then calls functions defined in the xsd file. And finally a detailsView control that uses an ObjectDataSource to call business logic functions.
In a nutshell, I am just trying to update records retrieved using REF CURSOR. Your help is very much appreciated. Please let me know if further details are required. Cheers,In the DataSet (xsd) where your DataTable is defined, you just need to add additional methods to the TableAdapter to handle insert, update and delete, either with SQL or by mapping to stored procedures.
Alternatively in code, create an OracleDataAdapter and supply its InsertCommand, UpdateCommand and DeleteCommand.
David -
How to access variable number of columns using ref cursor !
Hi,
I am trying to get variable number of columns using ref cursor.
Declare
mySzSql varchar2(2000);
Type dynSqlRC is Ref cursor;
current_cur dynSqlRC;
tbl_rec alt_42_consolidated%Rowtype;
Begin:
/* This works */
mySzSql := 'select *
from
Table1
Where
rowid = ''AAEWNEABXAAAAkxAAA''';
/* i want something like this to work, this is not working, giving missing variable name error */
mySzSql := 'select col1, col2, col3
from
Table1
Where
rowid = ''AAEWNEABXAAAAkxAAA''';
open current_cur for mySzSql;
fetch current_cur into tbl_rec;
close current_cur;
End;
I do have the list of desired columns which I am looking to fetch, so after taking that in the record type, how should i get their values. Is it possible to traverse tbl_rec declared above and if column name matches then I will store the value in the array and finally return this array.
Can somebody please tell me how to do this.
ThanksIt appears that this is a followup to How to loop through columns selected by select clause which is itself a followup to [url="
How to execute dynamic sql"]this earlier thread.
Assuming these are intended to be followup questions, can we please stick to a single thread? That makes it a lot easier to understand the situation and follow the conversation. Starting multiple threads makes it harder to follow the conversation.
Thanks,
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
How to give ref cursor in VB procedure call
This is my Oracle Sp
CREATE OR REPLACE PROCEDURE CRD_DMAN.infy_usp_trades_by_broker_bkr
** Procedure name: CRD_DMAN.USP_TRADES_BY_BROKER
** Author's name: Infosys
** Date written: 04/11/07
** Description: Compliance Trade by Borker
** Maintenance history:
** Date Chg req# Name Remarks
** 04/11/07 Infosys Created
p_ordercursor IN OUT infy_pkg_compliance_transact.cur_compliancetrade,
p_startdate IN VARCHAR,
p_enddate IN VARCHAR,
p_fundcode IN cs_fund_config.parent_acct_cd%TYPE,
p_clientcode IN ts_order_alloc.acct_cd%TYPE,
p_brokercode IN ts_order_alloc.exec_broker%TYPE,
p_reportname IN report_log.report_name%TYPE,
p_callingapplication IN report_log.calling_application%TYPE,
p_callinguser IN report_log.calling_user%TYPE
IS
--Declaring Local Variables
v_owner VARCHAR2 (30);
v_startdate VARCHAR2 (10);
v_enddate VARCHAR2 (10);
v_rowcount NUMBER:=0;
v_logrec base_util_pkg.crd_log_record;
exp_error EXCEPTION;
v_fundcodevalue NUMBER;
BEGIN
BEGIN
/*checking if the start date and end date are null and
assigning the sysdate accordingly*/
IF (TRIM(p_startdate) IS NULL )
THEN
v_startdate := TO_CHAR (SYSDATE, 'mm/dd/yy');
ELSE
v_startdate := p_startdate;
END IF;
IF (TRIM(p_enddate) IS NULL )
THEN
v_enddate := TO_CHAR (SYSDATE, 'mm/dd/yy');
ELSE
v_enddate := p_enddate;
END IF;
/*checking if fund code is null and assigning value accordingly*/
IF TRIM (p_fundcode) IS NULL
THEN
v_fundcodevalue := 0;
ELSE
v_fundcodevalue := 1;
END IF;
/*checking if the reportname or calling user or calling
application name*/
IF (p_reportname IS NULL OR p_callinguser IS NULL
OR p_callingapplication IS NULL)
THEN
RAISE exp_error;
END IF;
END;
--opening and fetching the data into cursor
v_logrec.start_time := SYSDATE;
BEGIN
OPEN p_ordercursor
FOR
SELECT
oa.exec_broker EXEC_BROKER_CODE,
b.bkr_name EXEC_BROKER_NAME,
oa.acct_cd CLIENT_CODE,
f.acct_name CLIENT_NAME,
CASE WHEN (Exists (SELECT 1
FROM cs_fund_broker fb
WHERE rel_typ_cd IN('P','M')
AND oa.exec_broker=fb.BKR_CD
AND oa.acct_cd =fb.acct_cd))
THEN 'Y'
ELSE 'N' END DIRECTED_BROKER,
COUNT ( distinct o.order_id) COUNT_TICKNUM,
MAX (o.trade_date) TRADE_DATE,
SUM (oa.exec_amt) BASE_COST,
SUM (oa.commision_amt) TOTAL_COMMISSION,
(SELECT ab.bkr_typ_cd FROM au_broker ab
WHERE ab.au_change_date =(SELECT TO_TIMESTAMP(MAX(ab.au_change_date))
FROM au_broker ab WHERE b.bkr_typ_cd != ab.bkr_typ_cd AND b.bkr_cd = ab.bkr_cd))
BROKER_HISTORY
FROM
ts_order o
JOIN ts_order_alloc oa ON (o.order_id = oa.order_id)
JOIN cs_broker b ON(oa.exec_broker = b.bkr_cd)
JOIN cs_fund f ON(oa.acct_cd = f.acct_cd)
WHERE
o.status = 'ACCT'
AND oa.exec_broker = CASE WHEN TRIM (p_brokercode) IS NULL
THEN oa.exec_broker
ELSE TRIM(p_brokercode) END
AND oa.acct_cd = CASE WHEN TRIM(p_clientcode) IS NULL
THEN oa.acct_cd
ELSE TRIM(p_clientcode) END
AND ((0 = v_fundcodevalue) OR EXISTS (SELECT 1 FROM crd.cs_fund_config cf
WHERE cf.parent_acct_cd =TRIM (p_fundcode)
AND oa.acct_cd = cf.child_acct_cd))
AND o.trade_date BETWEEN TO_DATE (v_startdate, 'mm/dd/yy')
AND TO_DATE (v_enddate, 'mm/dd/yy')
GROUP BY oa.exec_broker, b.bkr_name ,oa.acct_cd ,f.acct_name,oa.directed_broker,b.bkr_typ_cd,b.bkr_cd;
END;
BEGIN
SELECT
owner
INTO
v_owner
FROM
all_objects
WHERE
object_name = 'INFY_USP_TRADES_BY_BROKER_BKR';
v_logrec.end_time := SYSDATE;
v_logrec.user_code := v_owner;
v_logrec.input_param_values := 'INFY_USP_TRADES_BY_BROKER_BKR,'
|| v_startdate
|| ','
|| v_enddate
|| ','
|| p_fundcode
|| ','
|| p_clientcode
|| ','
|| p_brokercode;
v_logrec.report_name := p_reportname;
v_logrec.object_name := 'INFY_USP_TRADES_BY_BROKER_BKR';
v_logrec.rows_returned := v_rowcount;
v_logrec.calling_application := p_callingapplication;
v_logrec.calling_user := p_callinguser;
END;
BEGIN
--calling the procedure to insert values into the report_log table
COMMIT;
SET TRANSACTION READ WRITE;
base_util_pkg.crd_base_util_proc (v_logrec);
SET TRANSACTION READ ONLY;
END;
EXCEPTION
WHEN exp_error
THEN
DBMS_OUTPUT.put_line ('ERROR');
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line ('ERROR OCCURED' || SQLCODE);
DBMS_OUTPUT.put_line (SQLERRM);
END infy_usp_trades_by_broker_bkr;
END OF CRD_DMAN.USP_TRADES_BY_BROKER
This is my Pakage from where i am using ref cursor
CREATE OR REPLACE PACKAGE CRD_DMAN.infy_pkg_compliance_transact
AS
** Package name : CRD.INFY_PKG_COMPLIANCE_TRANSACTIONS
** Author's name : Infosys
** Date written : 06/11/07
** Project/System : CRD
** Description : Compliance Trades By Borker Package
** Maintenance history:
** Date Chg req# Name Remarks
** 06/11/07 CRD Infosys Created
--Defining The ComplianceTrade Record DataType
TYPE rec_compliancetrade IS RECORD (
exec_broker_code crd.ts_order_alloc.exec_broker%TYPE,
exec_broker_name crd.cs_broker.bkr_name%TYPE,
client_code crd.ts_order_alloc.acct_cd%TYPE,
client_name crd.cs_fund.acct_name%TYPE,
directed_broker crd.ts_order_alloc.directed_broker%TYPE,
count_ticknum crd.ts_order.order_id%TYPE,
trade_date crd.ts_order.trade_date%TYPE,
base_cost crd.ts_order_alloc.cur_base_mkt_val%TYPE,
total_commission crd.ts_order_alloc.commision_amt%TYPE,
broker_history crd.au_broker.bkr_typ_cd%TYPE
--Declaring a variable of rec_auditdata data type
TYPE cur_compliancetrade IS REF CURSOR
RETURN rec_compliancetrade;
END infy_pkg_compliance_transact;
END OF CRD.INFY_PKG_COMPLIANCE_TRANSACTIONS
How to call this SP from VB code with ref cursor parameter?I'm fairly sure that's not possible, since there's nothing in the ODBC spec to allow for ref cursors. The driver has built in support to check for ref cursors that are returned via a stored procedure call, but there's nothing built into the driver to pass one IN. Since a ref cursor can't be constructed on the client side, you'd have to have some sort of structure that allowed you to reference the ref cursor directly in order to be able to pass one back to the database.
Since you're using VB.NET anyway, the better solution is probably just to use ODP.NET instead, which DOES allow you to reference a ref cursor directly, and there are samples that install with ODP.NET that show you how to do that.
Greg -
I am working with a procedure which is returning a ref-cursor to a Java Call. Inside the procedure I see a statment like
Open t_results for
with rfq_companies AS
select statement1),
rfq_hierarchies AS
select statement2),
rfq_relnhierarchies AS
select statement 3);
Can anybody explain such an usage for opening a ref cursor ('WITH' clause)?. What is the effect of using this and how Java will interpret this?The procedure is still returning a REF CURSOR, regardless of the way the SELECT statements is created. There is no effect as far as Java is concerned.
Read more on the WITH clause:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#sthref9697
in the section: Subquery Factoring -
REF cursor with special characters
Hi all,
I want to display the record set using ref cursor. I am passing varchar field as parameter. How to give this in where cluase of select statement.
i want to use like %parameter_name% in where condition. How to use it in ref cursor.
Thanks in advance,
Paluser546710 wrote:
Hi all,
I want to display the record set using ref cursor. I am passing varchar field as parameter. How to give this in where cluase of select statement.
i want to use like %parameter_name% in where condition. How to use it in ref cursor.
Thanks in advance,
PalWhy using a ref cursor? Do you understand the purpose of ref cursors and how to use them?
Perhaps take a read of the following to get to grips with the basics...
PL/SQL 101 : Understanding Ref Cursors
PL/SQL 101 : Understanding Ref Cursors -
Report using ref cursor or dynamic Sql
Hi,
I never create a report using a ref cursor or a dynamic sql. Could any one help me to solve the below issue.
I have 2 tables.
1. Student_Record
2. Student_csv_help
Student_Record the main table where the data is stored.
Student_csv_help will contain the all the column names of the Student_record.
CREATE TABLE Student_CSV_HELP
ENTRY_ID NUMBER,
RAW_NAME VARCHAR2(40 BYTE),
DESC_NAME VARCHAR2(1000 BYTE),
IN_OUTPUT_LIST VARCHAR2(1 BYTE)
SET DEFINE OFF;
Insert into TOA_CSV_HELP
(ENTRY_ID, RAW_NAME, DESC_NAME, IN_OUTPUT_LIST)
Values
(1, 'S_ID', 'Student ID', 'Y');
Insert into TOA_CSV_HELP
(ENTRY_ID, RAW_NAME, DESC_NAME, IN_OUTPUT_LIST)
Values
(2, 'S_Name', 'Student Name', 'Y');
Insert into TOA_CSV_HELP
(ENTRY_ID, RAW_NAME, DESC_NAME, IN_OUTPUT_LIST)
Values
(3, 'S_Join_date', 'Joining Date', 'Y');
Insert into TOA_CSV_HELP
(ENTRY_ID, RAW_NAME, DESC_NAME, IN_OUTPUT_LIST)
Values
(4, 'S_Address', 'Address', 'Y');
Insert into TOA_CSV_HELP
(ENTRY_ID, RAW_NAME, DESC_NAME, IN_OUTPUT_LIST)
Values
(5, 'S_Fee', 'Tution Fee', 'N');
commit;
CREATE TABLE Student_record
S_ID NUMBER,
S_Name VARCHAR2(100 BYTE),
S_Join_date date,
S_Address VARCHAR2(360 BYTE),
S_Fee Number
Insert into Student_record
(S_ID, S_Name, S_Join_date, S_Address,S_Fee)
Values
(101, 'john', TO_DATE('12/17/2009 08:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'CA-94777', 2000);
Insert into Student_record
(S_ID, S_Name, S_Join_date, S_Address,S_Fee)
Values
(102, 'arif', TO_DATE('12/18/2009 08:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'CA-94444', 3000);
Insert into Student_record
(S_ID, S_Name, S_Join_date, S_Address,S_Fee)
Values
(103, 'raj', TO_DATE('12/19/2009 08:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'CA-94555', 2500);
Insert into Student_record
(S_ID, S_Name, S_Join_date, S_Address,S_Fee)
Values
(104, 'singh', TO_DATE('12/20/2009 08:00:00', 'MM/DD/YYYY HH24:MI:SS'), 'CA-94666', 2000);
Commit;
Now my requirement is:
I have a form with Student_record data block. When i Click on print Button on this form. It will open another window which has Student_CSV_HELP.DESC_NAME and a check box before this.
The window look like as below:
check_box DESC_NAME+
X S_ID+
-- S_Name+
X S_Join_date+
X S_Address+
-- S_Fee+
X means check box checked.+
-- means check box Unchecked.+
After i selected these check boxes i will send 2 parameters to the report server
1. a string parameter to the report server which has the value 'S_ID,S_Join_date,S_Address' (p_column_name := 'S_ID,S_Join_date,S_Address');
2. the s_id value from the student_record block (p_S_id := '101');
Now my requirement is when i click on run. I need a report like as below:
Student ID : 101+
Joining Date : 12/17/2009 08:00:00+
Address : CA-94777+
This is nothing but the ref cursor should run like as below:
Select S_id from student_record block S_id = :p_S_id;
Select S_Join_date from student_record block S_id = :p_S_id;
Select S_Address from student_record block S_id = :p_S_id;
So, according to my understanding i have to select the columns at the run time. I dont have much knowledge in creating reports using ref cursor or dynamic sql.
So please help me to solve this issue.
Thanks in advance.Plain sql should satisfy your need. Try ....
Select S_id, S_Join_date, S_Address
from student_record
where S_id = :p_S_id -
Cursors are not closed when using Ref Cursor Query in a report ORA-01000
Dear Experts
Oracel database 11g,
developer suite 10.1.2.0.2,
application server 10.1.2.0.2,
Windows xp platform
For a long time, I'm hitting ORA-01000
I have a 2 group report (master and detail) using Ref Cusor query, when this report is run, I found that it opens several cursors (should be only one cursor) for the detail query although it should not, I found that the number of these cursors is equal to the number of master records.
Moreover, after the report is finished, these cursors are not closed, and they are increasing cumulatively each time I run the report, and finally the maximum number of open cursors is exceeded, and thus I get ORA-01000.
I increased the open cursors parameter for the database to an unbeleivable value 30000, but of course it will be exceeded during the session because the cursors are increasing cumulatively.
I Found that this problem is solved when using only one master Ref Cursor Query and create a breake group, the problem is solved also if we use SQL Query instead of Ref Query for the master and detail queries, but for some considerations, I should not use neither breake group nor SQL Query, I have to use REF Cursor queries.
Is this an oracle bug , and how can I overcome ?
Thanks
Edited by: Mostafa Abolaynain on May 6, 2012 9:58 AMThank you Inol for your answer, However
Ref Cursor give me felxibility to control the query, for example see the following query :
function QR_1RefCurDS return DEF_CURSORS.JOURHEAD_REFCUR is
temp_JOURHEAD DEF_CURSORS.JOURHEAD_refcur;
v_from_date DATE;
v_to_date DATE;
V_SERIAL_TYPE number;
begin
SELECT SERIAL_TYPE INTO V_SERIAL_TYPE
FROM ACC_VOUCHER_TYPES
where voucher_type='J'
and IDENT_NO=:IDENT
AND COMP_NO=TO_NUMBER(:COMPANY_NO);
IF :no_date=1 then
IF V_SERIAL_TYPE =1 THEN
open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
FROM JOURHEAD
WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
AND IDENT=:IDENT
AND ((TO_NUMBER(VOCH_NO)=:FROM_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NULL)
OR (TO_NUMBER(VOCH_NO) BETWEEN :FROM_NO AND :TO_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NOT NULL )
OR (TO_NUMBER(VOCH_NO)<=:TO_NO and :FROM_NO IS NULL AND :TO_NO IS NOT NULL )
OR (:FROM_NO IS NULL AND :TO_NO IS NULL ))
ORDER BY TO_NUMBER(VOCH_NO);
ELSE
open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
FROM JOURHEAD
WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
AND IDENT=:IDENT
AND ((VOCH_NO=:FROM_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NULL)
OR (VOCH_NO BETWEEN :FROM_NO AND :TO_NO and :FROM_NO IS NOT NULL AND :TO_NO IS NOT NULL )
OR (VOCH_NO<=:TO_NO and :FROM_NO IS NULL AND :TO_NO IS NOT NULL )
OR (:FROM_NO IS NULL AND :TO_NO IS NULL ))
ORDER BY VOCH_NO;
END IF;
ELSE
v_from_date:=to_DATE(:from_date);
v_to_date:=to_DATE(:to_date);
IF V_SERIAL_TYPE =1 THEN
open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
FROM JOURHEAD
WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
AND IDENT=:IDENT
AND ((voch_date between v_from_date and v_to_date and :from_date is not null and :to_date is not null)
OR (voch_date <= v_to_date and :from_date is null and :to_date is not null)
OR (voch_date = v_from_date and :from_date is not null and :to_date is null)
OR (:from_date is null and :to_date is null ))
ORDER BY VOCH_DATE,TO_NUMBER(VOCH_NO);
ELSE
open temp_JOURHEAD for select VOCH_NO, VOCH_DATE
FROM JOURHEAD
WHERE COMP_NO=TO_NUMBER(:COMPANY_NO)
AND IDENT=:IDENT
AND ((voch_date between v_from_date and v_to_date and :from_date is not null and :to_date is not null)
OR (voch_date <= v_to_date and :from_date is null and :to_date is not null)
OR (voch_date = v_from_date and :from_date is not null and :to_date is null)
OR (:from_date is null and :to_date is null ))
ORDER BY VOCH_DATE,VOCH_NO;
END IF;
END IF;
return temp_JOURHEAD;
end; -
How to write REF-CURSOR Query in Oracle Reports
Hello Guys!!
I have a form in which you can select regions/divisions/locations etc by the use of check boxes. And the selected values will be inserted into a table, and based on the selected values of the table the report is run.
The issue I have is with the query inside the Oracle reports(attached to this file).
The query works fine until the last two EXISTS conditions.
IF a region exists In the table report_param then it works fine but if there are no divisions in it , then the query returns no values, which is not correct.
Someone has advised me to use a ref-cursor query inside reports tool, which I am not aware off. So, anykind of suggestions or advises are welcome. Please let me know about it as it is very urgent issue for me. Anykind of help would be greatly
appreciated.
Thanks,
Vishal
-------------------------------------------------------Query in Oracle Reports---------------------------------------------------------
select c.key_segment, p.supplier_id,
decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>')) COL_NM,
sum(a.ext_price) sales_dols,
sum(comp_allow_pkg.get_comp_allow_stddiv(a.control_loc_id, a.product_id, a.sold_to_customer_id,
a.doc_dt, a.ext_price, a.units)) cust_reb_dols,
sum(a.units) units,
sum(a.ext_cost) cost_dols
from sales a, key_segment_plns c, product p, rep_wrtr_dw_cust h
where a.doc_dt between :in_start_dt and :in_end_dt
and a.customer_oc = h.control_loc_id
and a.sold_to_customer_id = h.sold_to_cust_id
and a.ship_to_customer_id = h.ship_to_cust_id
and ((:in_dg_cd = 'B' and h.dealer_grower_cd in ('D','G')) or h.dealer_grower_cd = :in_dg_cd)
and a.product_id = p.product_id
and p.product_gl_class_cd = 'CHEM'
and p.product_legal_name = c.product_legal_name
and c.key_segment in ('GLYPHOSATE','PLANT HEALTH/RUST FUNGICIDES','PYRETHROIDS','STROBI FUNGICIDES')--&IN_KEY_SEGMENTS
-- and (:in_oc = 'ALL' or (a.control_loc_id in (select control_loc from control_loc_comb_ocs where control_loc_comb = :in_oc)))
-- SALES DATA FILTERS TO MATCH ACCUM_SALES_DG_MV
and a.sale_type_cd in ('02','08')
and a.document_type_cd in ('I','C','D')
and (substr(a.product_id,-1) in ('0','1') OR nvl(upper(trim(p.product_brand)),'X') = 'TECH FEE')
and a.units <> 0
and a.unit_cost <> 0
and a.unit_price <> 0
-- NEW FILTERS ADDED 9/11/07: LOCATION(BRANCH), BUSINESS TYPE, RSM/ASM/REP
and ((:in_loc = 'ALL') or (nvl(a.warehouse_id,'<blank>') in (SELECT param_value
FROM report_param
WHERE report_id = :IN_REPORT_ID
AND session_id= :IN_SESSION_ID
AND USER_ID = :IN_USER_ID
AND param_name='LOCATION_TYPE')))
and ((:in_uhs_ag = 'ALL') or (:in_uhs_ag = 'NA' and p.product_uhs_ag != 'A') or (p.product_uhs_ag = :in_uhs_ag))
and ((:in_sales_rep = 'ALL') or (nvl(a.territory_id,'<blank>') in (SELECT param_value
FROM report_param
WHERE report_id = :IN_REPORT_ID
AND session_id= :IN_SESSION_ID
AND USER_ID = :IN_USER_ID
AND param_name='SALES_REP_TYPE')))
and EXISTS
(SELECT '1'
FROM locations l, report_param rp
WHERE rp.report_id = :IN_REPORT_ID
AND rp.session_id= :IN_SESSION_ID
AND rp.user_id = :IN_USER_ID
AND rp.param_value = l.region
AND rp.param_name = 'REGION_TYPE'
AND a.warehouse_id = L.ARS_LOCATION)
and EXISTS
(SELECT '1'
FROM locations l, report_param rp
WHERE rp.report_id = :IN_REPORT_ID
AND rp.session_id= :IN_SESSION_ID
AND rp.user_id = :IN_USER_ID
AND rp.param_value = l.region
AND rp.param_name = 'DIVISION_TYPE'
AND a.warehouse_id = L.ARS_LOCATION)
group by c.key_segment, P.supplier_id,
decode(:in_col_nm, 'BRAND',nvl(p.product_brand,'<Unknown Brand>'), 'PLN',nvl(p.product_legal_name,'<Unknown Legal Name>'))Hi,
I need your help to create a report using Ref-Cursor. please see the below thread
Report using ref cursor or dynamic Sql -
How to use the namespace with a parser?
I want to use the namespace in my project. For this reason, I use a sample
from
http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/sax/7b_pe.html
http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/dom/5_ns.html
to test my understanding.
The slideshow2.dtd refer to the definition in 'xhtml.dtd'. Because in these
two files, they all use the 'title' as the element names. To solve these
conflicts, The namespace is used to qualified the one in slideshow2.dtd.
But the parser still complain that the 'title' in slideshow2.dtd is declared
more than once.
I use apache's Xerces.
I want to know if Xereces realy support namespace spec. now, or how to use
the namespace with a parser. Can anyone kindly tell me where to find some
material that demo the use of namespace in Java program.
Thanks for any help!!!
#############FILE: slideshow2.dtd ###############
<?xml version='1.0' encoding='us-ascii'?>
<!ELEMENT slideshow (slide+)>
<!ELEMENT slide (title?, item*)>
<!ENTITY % xhtml SYSTEM "xhtml.dtd">
%xhtml;
<!ELEMENT title (#PCDATA)*>
<!ATTLIST title
xmlns CDATA #FIXED "http://www.example.com/slideshow"
>
<!ELEMENT item (#PCDATA)>
##############FILE: xhtml.dtd #########################
<?xml version='1.0' encoding='us-ascii'?>
<!ELEMENT html (head)>
<!ATTLIST html
xmlns CDATA #FIXED "http://www.example.com/xhtml"
>
<!ELEMENT head (title,style*)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT style (#PCDATA)>
#############FILE: slideshow.xml ####################
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE slideshow SYSTEM "slideshow2.dtd">
<slideshow>
<slide>
<title xmlns="http://www.example.com/slideshow">Wake up to
products!</title>
</slide>
</slideshow>I want to use the namespace in my project. For this reason, I use a sample
from
http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/sax/7b_pe.html
http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/dom/5_ns.html
to test my understanding.
The slideshow2.dtd refer to the definition in 'xhtml.dtd'. Because in these
two files, they all use the 'title' as the element names. To solve these
conflicts, The namespace is used to qualified the one in slideshow2.dtd.
But the parser still complain that the 'title' in slideshow2.dtd is declared
more than once.
I use apache's Xerces.
I want to know if Xereces realy support namespace spec. now, or how to use
the namespace with a parser. Can anyone kindly tell me where to find some
material that demo the use of namespace in Java program.
Thanks for any help!!!
#############FILE: slideshow2.dtd ###############
<?xml version='1.0' encoding='us-ascii'?>
<!ELEMENT slideshow (slide+)>
<!ELEMENT slide (title?, item*)>
<!ENTITY % xhtml SYSTEM "xhtml.dtd">
%xhtml;
<!ELEMENT title (#PCDATA)*>
<!ATTLIST title
xmlns CDATA #FIXED "http://www.example.com/slideshow"
>
<!ELEMENT item (#PCDATA)>
##############FILE: xhtml.dtd #########################
<?xml version='1.0' encoding='us-ascii'?>
<!ELEMENT html (head)>
<!ATTLIST html
xmlns CDATA #FIXED "http://www.example.com/xhtml"
>
<!ELEMENT head (title,style*)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT style (#PCDATA)>
#############FILE: slideshow.xml ####################
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE slideshow SYSTEM "slideshow2.dtd">
<slideshow>
<slide>
<title xmlns="http://www.example.com/slideshow">Wake up to
products!</title>
</slide>
</slideshow> -
How to use Mulitple DAQs with a single triggered event on only one of the DAQs
I have three PXI6115 and would like to tie all these to a single triggered event on one of the DAQs. I've scaned the examples and any assistance would be greatly appreciated....
TCjr,
Please refer to your other post:
How to use Multiple DAQs with a single triggered event on only one of the DAQs -
How to use parrallel cursor in this code
hi can anyone expalin me how to use parallel cursor for this code ...
loop at itabkpf.
read table ibsegpar_fu with key
belnr = itabkpf-belnr
gjahr = itabkpf-gjahr
bschl = '25' .
Start insert by Pradeep 20082008
sort: itabkpf by belnr,
itabsegpar by belnr.
End insert by Pradeep 20082008
if sy-subrc = 0. "Deleted by pradeep 20082008
select bukrs belnr gjahr bschl koart lifnr wrbtr
wskto pswbt zfbdt augbl augdt sgtxt rebzg rebzj
into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = itabkpf-bukrs and
belnr = itabkpf-belnr and
gjahr = itabkpf-gjahr and
augbl <> itabkpf-belnr and
rebzg <> space and
bschl = '25'.
loop at ibsegpar_fu_1.
Start insert by Pradeep 20082008
sort ibsegpar_fu_1 by belnr.
End insert by Pradeep 20082008
move-corresponding ibsegpar_fu_1 to itabseg.
move ibsegpar_fu_1-belnr to itabseg-augbl.
move ibsegpar_fu_1-rebzg to itabseg-belnr.
move ibsegpar_fu_1-rebzj to itabseg-gjahr.
*********to include code to pick the description for partical payment
select single * from bseg where
bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-belnr and
gjahr = ibsegpar_fu_1-gjahr and
augbl <> ibsegpar_fu_1-belnr and
rebzg = space and
bschl <> '25'.
move bseg-sgtxt to itabseg-sgtxt.
clear bseg.
*********end of code
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-rebzg and
gjahr = ibsegpar_fu_1-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
endloop.
endif. "Deleted by Pradeep 20082008
endloop.
loop at ibsegpar_fu.
sort ibsegpar_fu by belnr. " insert by pradeep
move-corresponding ibsegpar_fu to itabseg.
select bukrs belnr gjahr bschl koart lifnr wrbtr
rebzg rebzj sgtxt into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = ibsegpar_fu-bukrs and
gjahr = ibsegpar_fu-gjahr and
augbl = ibsegpar_fu-belnr and " Pradeep 20082008 Delete
augbl <> ibsegpar_fu-belnr and " Pradeep 20082008 Insert
rebzg = space and
bschl = '25'.
if sy-subrc = 0.
loop at ibsegpar_fu_1.
move ibsegpar_fu_1-rebzg to itabseg-rebzg.
move ibsegpar_fu_1-rebzj to itabseg-rebzj.
endloop.
move ibsegpar_fu-belnr to itabseg-augbl.
move itabseg-rebzg to itabseg-belnr.
move itabseg-rebzj to itabseg-gjahr.
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu-bukrs and
belnr = itabseg-rebzj and
gjahr = itabseg-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
read table itabseg with key
belnr = itabseg-rebzg
gjahr = itabseg-rebzj
bschl = '31' .
if sy-subrc = 0.
delete itabseg index sy-tabix. "Deleted by Pradeep 20082108
endif.
endif.
endloop.
Start insert by Pradeep 20082008
loop at itabseg.
if itabseg-belnr = itabseg-augbl.
delete itabseg.
elseif itabseg-belnr = ' '.
delete itabseg.
endif.
endloop.
End insert by Pradeep 20082008hi can anyone expalin me how to use parallel cursor for this code ...
loop at itabkpf.
read table ibsegpar_fu with key
belnr = itabkpf-belnr
gjahr = itabkpf-gjahr
bschl = '25' .
Start insert by Pradeep 20082008
sort: itabkpf by belnr,
itabsegpar by belnr.
End insert by Pradeep 20082008
if sy-subrc = 0. "Deleted by pradeep 20082008
select bukrs belnr gjahr bschl koart lifnr wrbtr
wskto pswbt zfbdt augbl augdt sgtxt rebzg rebzj
into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = itabkpf-bukrs and
belnr = itabkpf-belnr and
gjahr = itabkpf-gjahr and
augbl <> itabkpf-belnr and
rebzg <> space and
bschl = '25'.
loop at ibsegpar_fu_1.
Start insert by Pradeep 20082008
sort ibsegpar_fu_1 by belnr.
End insert by Pradeep 20082008
move-corresponding ibsegpar_fu_1 to itabseg.
move ibsegpar_fu_1-belnr to itabseg-augbl.
move ibsegpar_fu_1-rebzg to itabseg-belnr.
move ibsegpar_fu_1-rebzj to itabseg-gjahr.
*********to include code to pick the description for partical payment
select single * from bseg where
bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-belnr and
gjahr = ibsegpar_fu_1-gjahr and
augbl <> ibsegpar_fu_1-belnr and
rebzg = space and
bschl <> '25'.
move bseg-sgtxt to itabseg-sgtxt.
clear bseg.
*********end of code
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu_1-bukrs and
belnr = ibsegpar_fu_1-rebzg and
gjahr = ibsegpar_fu_1-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
endloop.
endif. "Deleted by Pradeep 20082008
endloop.
loop at ibsegpar_fu.
sort ibsegpar_fu by belnr. " insert by pradeep
move-corresponding ibsegpar_fu to itabseg.
select bukrs belnr gjahr bschl koart lifnr wrbtr
rebzg rebzj sgtxt into corresponding
fields of table ibsegpar_fu_1 from bseg
where bukrs = ibsegpar_fu-bukrs and
gjahr = ibsegpar_fu-gjahr and
augbl = ibsegpar_fu-belnr and " Pradeep 20082008 Delete
augbl <> ibsegpar_fu-belnr and " Pradeep 20082008 Insert
rebzg = space and
bschl = '25'.
if sy-subrc = 0.
loop at ibsegpar_fu_1.
move ibsegpar_fu_1-rebzg to itabseg-rebzg.
move ibsegpar_fu_1-rebzj to itabseg-rebzj.
endloop.
move ibsegpar_fu-belnr to itabseg-augbl.
move itabseg-rebzg to itabseg-belnr.
move itabseg-rebzj to itabseg-gjahr.
itabseg-wrbtr = itabseg-wrbtr * -1.
itabseg-pswbt = itabseg-pswbt * -1.
select single budat into lsdat from
bkpf where bukrs = ibsegpar_fu-bukrs and
belnr = itabseg-rebzj and
gjahr = itabseg-rebzj.
if sy-subrc = 0.
move lsdat to itabseg-zfbdt.
endif.
append itabseg.
read table itabseg with key
belnr = itabseg-rebzg
gjahr = itabseg-rebzj
bschl = '31' .
if sy-subrc = 0.
delete itabseg index sy-tabix. "Deleted by Pradeep 20082108
endif.
endif.
endloop.
Start insert by Pradeep 20082008
loop at itabseg.
if itabseg-belnr = itabseg-augbl.
delete itabseg.
elseif itabseg-belnr = ' '.
delete itabseg.
endif.
endloop.
End insert by Pradeep 20082008
Maybe you are looking for
-
How I can stop the combo box with list of values from fireing validations
Hi I'm using Jdeveloper 11.1.2.3.0 Using Hr Schema employees table I Display employees data in af:table and I make List Of values on Department_id filed to easy change the employee department and another one on Job_id filed and Imake them UI Hints as
-
Podcast episode description not showing up in iTunes
Hi I've got just an audio version of my podcast and as I wanted a bit more flexibility and statistics I started using Feedburner for the audio version. The only bad thing that I've found is that the individual episode description is just the descript
-
Javax.mail does not exist
I would like to thank warnerja for your advise about the classpath. Thanks for the classpath information regarding the .jar files. Now when I start tomcat cat it runs appropriately. However I am still having a problem when i try to compile the messag
-
Create organization structure in WD ABAP
Hi I want to use table UI element displaying the organization structure hierarchy. as displayed in PPMDT or in any other HR transaction. How we can do it ??? Thanks Vishal Kapoor
-
My MacBook Pro is fully charged and won't turn on. Any suggestions?