How to return a cursor containing a CLOB
We can insert, update and delete a single row from the database using a stored
procedure with clob out parameters. Also, a single row containing a CLOB can
be retrieved using a cursor from a stored procedure. However, an attempt to
return multiple rows using a cursor fails. The application hangs on the call
to QueryDataSet.fetchRecords or ResultSet.next depending on how the fetch
is implemented in the java code. Has anyone had any success doing this?
We are using WL51 sp8 with the jdbc20 drivers on NT.
Oracle Client version 8.1.6 accessing Oracle Server 8.1.6.
I recognize we could use embedded sql and a result set. However, that is
not preferable.
We can insert, update and delete a single row from the database using a stored
procedure with clob out parameters. Also, a single row containing a CLOB can
be retrieved using a cursor from a stored procedure. However, an attempt to
return multiple rows using a cursor fails. The application hangs on the call
to QueryDataSet.fetchRecords or ResultSet.next depending on how the fetch
is implemented in the java code. Has anyone had any success doing this?
We are using WL51 sp8 with the jdbc20 drivers on NT.
Oracle Client version 8.1.6 accessing Oracle Server 8.1.6.
I recognize we could use embedded sql and a result set. However, that is
not preferable.
Similar Messages
-
How to return a resultset in a stored procedure without using Cursor
Dear all,
I need to return a resultset in a stored procedure.
I know I can return a Cursor.
But because there are many complicate logics I need to carry out,
so I can finish all the logic in a SINGLE SQL select statement, so I think it can't
use Cursor as return value.
Does anybody know other approaches? Please help.
Thanks!Some basic techniques that one can use in SQL. These are merely to illustrate (simplistically) different approaches.
> field3 = select count(*) from table2,table1 where table2.id = table1.id
This can be done via an analytical function (refer to the SQL Reference) or very simply, as an in-line select as follows:
SQL> select
2 o.object_name,
3 (select count(*) from user_objects u where u.object_type = o.object_type) as "ONE OF",
4 o.object_type
5 from user_objects o
6 where o.object_name = 'LISTFILES';
OBJECT_NAME ONE OF OBJECT_TYPE
LISTFILES 8 PROCEDURE
So LISTFILE is "one of 8" procedures. I would however rather so this via an analytic function as these are a lot more flexible. Note the WITH clause that allows "modularisation" of SQL - kind of like creating "sub-SQL results" in a single SQL statement:
SQL> with DATASET1 as(
2 select
3 object_name,
4 count(distinct object_name) over (partition by object_type) as TOTAL_TYPES,
5 object_type
6 from user_objects
7 ),
8 DATASET2 as(
9 select
10 name,
11 text as SOURCE_LINE,
12 line as LINE_NO,
13 count(line) over (partition by name) as TOTAL_LINES
14 from user_source
15 )
16 select
17 object_name,
18 '1 of '||total_types||' '||object_type as "TYPE",
19 source_line as "1st LINE",
20 total_lines as "TOTAL LINES"
21 from DATASET1 ds1,
22 DATASET2 ds2
23 where ds1.object_name = ds2.name
24 and ds1.object_name = 'LISTFILES'
25* and ds2.line_no = 1
SQL> /
OBJECT_NAME TYPE 1st LINE TOTAL LINES
LISTFILES 1 of 8 PROCEDURE procedure ListFiles( cDirectory in varchar2 ) 3
SQL>
SQL is quite powerful and analytical functions allows all kinds of aggregation processing per row, accessing the leading or lagging rows' data, etc.
You need to play around with this to get to grips with it and how to apply it. -
How to read my cursor that is ref cursor returning user defined type
Hi
I have types defined as follows:
TYPE MY_RECORD IS RECORD (
COL1 TABLE1.COL1%TYPE,
COL2 TABLE1.COL2%TYPE
TYPE MY_CURSOR IS REF CURSOR
RETURN MY_RECORD;This is used as return type in a stored procedure.
I have a pl/sql block where I make a call to the SP that returns this cursor.
How can I read individual values being returned from SP?SQL> create or replace package pkg
as
type my_record is record (col1 emp.empno%type, col2 emp.ename%type);
type my_cursor is ref cursor
return my_record;
procedure p (cur out my_cursor);
end pkg;
Package created.
SQL> create or replace package body pkg
as
procedure p (cur out my_cursor)
as
begin
open cur for
select empno, ename
from emp
where rownum <= 2;
end p;
end pkg;
Package body created.
SQL> declare
cur pkg.my_cursor;
e_rec pkg.my_record;
begin
pkg.p (cur);
loop
fetch cur into e_rec;
exit when cur%notfound;
dbms_output.put ('Empno: ' || e_rec.col1);
dbms_output.put_line ('; Ename: ' || e_rec.col2);
end loop;
close cur;
end;
Empno: 7369; Ename: SMITH
Empno: 7499; Ename: ALLEN
PL/SQL procedure successfully completed. -
I need to know how many lines a cursor returns
Hi,
I need to know how many lines a cursor will return without counting it within a loop or putting a count clause within the cursor . Is there a way to do ?Please post this question in the database forum for an appropriate response: General Database Discussions
Regards,
OTN -
How to return a table to ref cursor?
My client has created a package stored procedure that takes in 2 parameters of VarChar2 and an out parameter which is a table
Following is the package header
CREATE OR REPLACE PACKAGE "PKG_TRAVEL_NEW_SUND" IS
---RECORD TYPE DELARATION
TYPE DIRECT_ALT_REC IS RECORD (SERVICE_NO CBG_DISTANCE_FARE.SERVICE_NO%TYPE,
DISTANCE CBG_DISTANCE_FARE.DISTANCE%TYPE,
CASH_FARE_AC CBG_DISTANCE_FARE.CASH_FARE_AC%TYPE,
CASH_FARE_NON_AC CBG_DISTANCE_FARE.CASH_FARE_NON_AC%TYPE,
CARD_FARE_AC CBG_DISTANCE_FARE.CARD_FARE_AC%TYPE,
CARD_FARE_NON_AC CBG_DISTANCE_FARE.CARD_FARE_NON_AC%TYPE,
EZLINK_FARE_AC CBG_DISTANCE_FARE.EZLINK_FARE_AC%TYPE,
EZLINK_FARE_NON_AC CBG_DISTANCE_FARE.EZLINK_FARE_NON_AC%TYPE,
AVG_RUNTIME CBG_DISTANCE_FARE.AVG_RUNTIME%TYPE,
ALTERNATIVE_NO CBG_DIRECT_ALT.ALTERNATIVE_NO%TYPE,
MAX_FREQ_AM CBG_SVC.MAX_FREQ_AM%TYPE,
MIN_FREQ_AM CBG_SVC.MIN_FREQ_AM%TYPE,
ADVANTAGE_CODE CBG_DIRECT_ALT.ADVANTAGE_CODE%TYPE,
DIST_FARE_CODE_1 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
DIST_FARE_CODE_2 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
DIST_FARE_CODE_3 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
FROM_STOP_CODE CBG_DISTANCE_FARE.FROM_STOP_CODE%TYPE,
TO_STOP_CODE CBG_DISTANCE_FARE.TO_STOP_CODE%TYPE,
MIN_TIME CBG_DIRECT_ALT.MIN_TIME%TYPE,
MIN_FARE CBG_DIRECT_ALT.MIN_FARE%TYPE,
ACT_FARE CBG_DIRECT_ALT.MIN_FARE%TYPE,
TRAVEL_TYPE VARCHAR2(4),
TRANSFER_INFO VARCHAR2(1),
END_TRANSFER_INFO VARCHAR2(1));
--TABLE TYPE DECLARATION
TYPE BUS_INFO_TAB IS TABLE OF DIRECT_ALT_REC INDEX BY BINARY_INTEGER;
-- CURSOR TYPE DECLARATION
TYPE TEMP_REC_STRUCT1 IS RECORD (
RECORD_POSITION BINARY_INTEGER,
DIST_FARE_CODE1 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
DIST_FARE_CODE2 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
DIST_FARE_CODE3 CBG_DISTANCE_FARE.DIST_FARE_CODE%TYPE,
ADVANTAGE_CODE CBG_DIRECT_ALT.ADVANTAGE_CODE%TYPE,
MINIMUM_FARE CBG_DIRECT_ALT.MIN_FARE%TYPE,
MINIMUM_TIME CBG_DIRECT_ALT.MIN_TIME%TYPE,
TRAVEL_TYPE VARCHAR2(4) );
TYPE TEMP_TAB_STRUCT1 IS TABLE OF TEMP_REC_STRUCT1 INDEX BY BINARY_INTEGER;
TEMP_TABLE1 BUS_INFO_TAB;
G_RESULTSET_INDEX BINARY_INTEGER := 0 ;
G_TOT_RECS_IN_TAB1 BINARY_INTEGER := 0 ;
TYPE BUS_INFO_CUR IS REF CURSOR RETURN DIRECT_ALT_REC;
---PROCEDURE INSIDE THE PACKAGE
--- PROCEDURE TO SELECT THE RECORDS
PROCEDURE SEL_DIRECT_ALT(P_FROM_STOP_CODE IN VARCHAR2,
P_TO_STOP_CODE IN VARCHAR2,
RESULTSET IN OUT BUS_INFO_TAB);
I'm using ODP.net and here is my code
string storedprocedure = "PKG_TRAVEL_NEW_SUND.SEL_DIRECT_ALT";
//PKG_TRAVEL_NEW_SUND
//CBG003_XP_SP_TEST1
ArrayList retlist = new ArrayList();
OracleConnection curr_conn = this.GetOpenConnection();
OracleCommand cmd = curr_conn.CreateCommand();
cmd = new OracleCommand(storedprocedure, curr_conn);
cmd.CommandType = CommandType.StoredProcedure;
// input parameter
OracleParameter param1 = new OracleParameter();
OracleParameter param2 = new OracleParameter();
param1.ParameterName = "start_code";
param2.ParameterName = "end_code";
param1.OracleDbType = OracleDbType.Varchar2;
param2.OracleDbType = OracleDbType.Varchar2;
param1.Direction = ParameterDirection.Input;
param2.Direction = ParameterDirection.Input;
param1.Size = 5;
param2.Size = 5;
param1.Value = start_codes;
param2.Value = end_codes;
cmd.Parameters.Add(param1);
cmd.Parameters.Add(param2);
OracleParameter outputparam3 = new OracleParameter();
outputparam3.Direction = ParameterDirection.InputOutput;
outputparam3.ParameterName = "output";
outputparam3.OracleDbType = OracleDbType.RefCursor;
// output type
cmd.Parameters.Add(outputparam3);
cmd.ExecuteNonQuery();
At this point, when i execute Query, i get the message telling me that i could have the wrong number or type arguments for the procedure.
I've looked thru countless examples saying i should use a RefCursor, but what else could i miss out?Hi,
This is from Metalink NOTE.219191.1 How to return the values in a PL/SQL table to a ref cursor
Hope it helps,
Greg
This document gives details with an example on how to pass the values
in a PL/SQL table to a ref cursor.
SCOPE & APPLICATION
This document is useful for developers who are familiar with SQL & PL/SQL
How to return the values in a PL/SQL table to a ref cursor
This can be done by using a SQL Object type instead of a PL/SQL table.
Here is an example.
SQL> create or replace type ObjectType as object
2 ( x int,
3 y date,
4 z varchar2(25)
5 );
6 /
Type created.
SQL> create or replace type TabType as table of ObjectType;
2 /
Type created.
SQL> create or replace
2 function demo_function( p_start_row in number,
3 p_end_row in number )
4 return TabType
5 as
6 l_data TabType := TabType();
7 l_cnt number default 0;
8 begin
9 for x in ( select * from emp order by sal desc )
10 loop
11 l_cnt := l_cnt + 1;
12 if ( l_cnt >= p_start_row )
13 then
14 l_data.extend;
15 l_data(l_data.count) :=
16 objectType( x.empno,
17 x.hiredate,
18 x.ename );
19 end if;
20 exit when l_cnt = p_end_row;
21 end loop;
22
23 return l_data;
24 end;
25 /
Function created.
SQL> select *
2 from the ( select cast( demo_function(3,7) as TabType )
3 from dual ) a;
X Y Z
7902 03-DEC-81 FORD
7566 02-APR-81 JONES
7698 01-MAY-81 BLAKE
7782 09-JUN-81 CLARK
7844 08-SEP-81 TURNER
By using a SQL object type, the table can be selected easily.
SQL> create or replace package demo_pkg
2 as
3 type rc is ref cursor;
4
5 procedure p( p_cursor in out rc );
6 end;
7 /
Package created.
SQL> create or replace package body demo_pkg
2 as
3
4 procedure p( P_cursor in out rc )
5 is
6 l_data TabType := TabType();
7 begin
8 for i in 1 .. 3 loop
9 l_data.extend;
10 l_data(i) :=
11 ObjectType( i, sysdate+i, i || ' data');
12 end loop;
13
14 open p_cursor for
15 select *
16 from TABLE ( cast ( l_data as TabType) );
17 end;
18
19 end;
20 /
Package body created.
SQL> set autoprint on
SQL> variable x refcursor
SQL> exec demo_pkg.p(:x)
PL/SQL procedure successfully completed.
X Y Z
1 15-NOV-02 1 data
2 16-NOV-02 2 data
3 17-NOV-02 3 data -
How to execute stored procedure that returns a cursor?
How to execute a stored procedure that returns a cursor?
Follow the code:
CREATE OR REPLACE PROCEDURE stp_cashin_grupo
(p_func IN VARCHAR
,p_cod_grup IN Integer
,p_des_grup IN VARCHAR
,p_logi IN VARCHAR
,p_curs_rset OUT infoc.pck_cashin_grupo.curs_rset
IS
BEGIN
if p_func = '1' then
OPEN p_curs_rset FOR
select
cod_grup
,des_grup
,dat_manu_grup
,des_logi_manu
from infoc.tbl_cashin_grupo
order by des_grup;
end if;
END stp_cashin_grupo;
and the package:
CREATE OR REPLACE PACKAGE pck_cashin_grupo
AS
TYPE curs_rset IS REF CURSOR;
END pck_cashin_grupo;
My question is how to execute in sql plus?
EXEC stp_cashin_grupo('1',0,'','465990', my doubt is how to pass the cursor as return
Thanksmy doubt is how to pass the cursor as returnExample :
TEST@db102 > var c1 refcursor;
TEST@db102 > create or replace procedure ref1 (
2 v1 in varchar2,
3 cur1 out sys_refcursor)
4 is
5 begin
6 open cur1 for 'select * from '||v1;
7 end;
8 /
Procedure created.
TEST@db102 > exec ref1('dept',:c1);
PL/SQL procedure successfully completed.
TEST@db102 > print c1
DEPTNO DNAME LOC
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
TEST@db102 > -
How to return a ref cursor from this dbms_sql?
Hi,
Can anyone show me how to return a ref cursor from this dbms_sql based procedure? I see 11g has a dbms_sql.to_refcursor(cursor_handle). How can this be done is 10g?
Thx.
CREATE OR REPLACE PROCEDURE Sample_Get_t
p_sample_id sample.sample_id%TYPE,
p_contract_id sample.contr_id%TYPE
IS
cursor_handle INT;
sql_stmnt varchar2(500);
rows_processed NUMBER;
BEGIN
sql_stmnt :=
'SELECT
sample_id,
contr_id,
rcpt_id
FROM
sample s
WHERE
s.contr_id = :1
and s.sample_id = :2
ORDER BY
sample_id';
cursor_handle := dbms_sql.open_cursor;
dbms_sql.parse(cursor_handle, sql_stmnt, dbms_sql.native);
dbms_sql.bind_variable(cursor_handle, ':1', p_contract_id);
dbms_sql.bind_variable(cursor_handle, ':2', p_sample_id);
rows_processed := dbms_sql.execute(cursor_handle);
dbms_sql.close_cursor(cursor_handle);
END Sample_Get_t;In 10 this cannot be done with dbms_sql (to my knowledge). There are a couple of other options.
1) open the ref cursor for the dynamic statement using bind variables (or SYS_CONTEXT variables, which i prefer since they are much easier to deal with when you are dynamically adding predicates).
declare
wRefCursor SYS_REFCURSOR;
begin
open wRefCursor for 'select * from all_objects where owner = :Logged_in_user' using user;
end;
/or using the context (the context will bind for you)
declare
wRefCursor SYS_REFCURSOR;
begin
open wRefCursor for 'select * from all_objects where owner = SYS_CONTEXT(''CONTEXT_NAME'', ''VARIABLE_NAME'') ';
end;
/Be aware that contexts ALWAYS return varchar values, so if you are comparing to a number you should wrap it in TO_NUMBER, a date, TO_DATE and so on....
2) change the DBMS_SQL to do an insert into a global temporary table and return the ref cursor which select's * from GTT;
3) upgrade to Oracle 11 :) -
How to do store with dynamic sql to return a cursor
i need to do a store that returns a cursor, but the expression of the cursor are genereted dynamicly. how can i do that?
something like this:
sql_stmt := 'SELECT * FROM ' || INTABLE || ' WHERE '|| inWhereClause;
EXECUTE IMMEDIATE sql_stmt into C1;
where c1 is a ref cursor( OUT variable of procedure)
it is possible or not?
Pedro CardosoThe syntax is something like
sql_stmt := 'Select * from '|| InTable||' WHERE '|| InWhereClause ;
OPEN C1 for Sql_Stmt ; -
How to return cursor from procedure to jdbc
plz help me through example of code as wl as procedure where.... return cursor from procedure to jdbc
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS OFF
GO
CREATE procedure anil3 @count INT OUT,@opcode INT OUT,@total_tiff INT OUT
as
declare @query2 varchar(300),@tiff_count int,@query1 varchar(300)
set @query1='declare move_cursor cursor forward_only static for
select count(opcode),opcode from TABLE1 group by opcode
open move_cursor'
exec(@query1)
fetch next from move_cursor into @count,@opcode
set @opcode="'"+@opcode+"'"
set @total_tiff=0
while (@@fetch_status=0)
begin
set @query2='declare move_cursor2 cursor static for '+
' select count(tiff) from TABLE2 where opcode='+@opcode+
' open move_cursor2 '
exec(@query2)
fetch next from move_cursor2 into @tiff_count
while (@@fetch_status=0)
begin
set @total_tiff=@total_tiff+@tiff_count
fetch next from move_cursor2 into @tiff_count
end
close move_cursor2
deallocate move_cursor2
print @total_tiff
print @count
print @opcode
fetch next from move_cursor into @count,@opcode
end
close move_cursor
deallocate move_cursor
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO******************************************************************************
above this is sql server 2000 PL/SQL and i hv to get the value
print @total_tiff
print @count
print @opcode
through JDBC
plz help me out how to return Cursor to JDBC and HOW toPRINT THESE THREE VALUE @total_tiff, @count, @opcode through JDBC
get this values through JDBC -
How to return Lis (contain async tag). ????
Thanks, I figured out this my ways to solve it.
I want ask you: How to return Lis<> (async).
Ex:
public async void loaddata(string id)
var httpClient = new HttpClient();
var srtHtml = await httpClient.GetStringAsync("http://dictionary.cambridge.org/dictionary/british/appeal");
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(srtHtml);
List<Models.EnglishDictionary> arrays = new List<Models.EnglishDictionary>();
var newsListNodehtml = htmlDoc.GetElementbyId("entryContent");
if (newsListNodehtml != null)
var senseblock = newsListNodehtml.Descendants("div").Where(x => x.GetAttributeValue("id", "") == id);
if (senseblock != null)
foreach (var node in senseblock)
Dictionaries = new Models.EnglishDictionary();
var def = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "def");
var examp = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "def-body");
//Dictionaries.Symbol = "/Photos/glasses-50.png";
if (def != null)
Dictionaries.Description = def.InnerText.Trim();
if (examp != null)
Dictionaries.Examp = examp.InnerText.Trim();
var hw = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "hw");
var prsgram = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "posgram");
var word = node.Descendants("span").FirstOrDefault(x => x.GetAttributeValue("class", "") == "guideword");
if (hw != null)
Dictionaries.Word = hw.InnerText.Trim();
if (word != null)
Dictionaries.GuideWord = word.InnerText.Trim();
if (prsgram != null)
Dictionaries.Grammar = prsgram.InnerText.Trim();
arrays.Add(Dictionaries);
else
// error = "No data";
Listview.itemsource=arrays;
I want on ousite it will called back into "itemsource" of lisview.
Ex:Listview.itemsource=loaddata("1-1");
How???arrays.Add(Dictionaries);You think of what is type??? string
Task<string>... -
How to use Execute Immediate to execute a procedure and return a cursor?
The procedure name is unknown until run time so I have to use Execute immediate to execute the procedure, the procedure return a cursor, but I can't figure out the right syntax to pass the cursor out.
To simplify the issue here, I create two procedures as examples.Assume I have a procedure called XDTest:
p_cur OUT SYS_REFCURSOR
IS
BEGIN
OPEN p_cur FOR
Select * from dummy_table;
END XDTest;
In another procedure, I want to use Execute Immediate to execute XDTest and obtain the result that return from the cursor into a local cursor so I can process the records:
p_cur OUT SYS_REFCURSOR
IS
l_cur SYS_REFCURSOR;
BEGIN
execute immediate 'BEGIN XDTest (:1); END;' using OUT l_cur;
END XDTest2;
However, this is not working, I get ORA-03113: end-of-file on communication channel error.
What syntax should I use here?
Cheerswell...
I update the XDTest2 procedure as below but when execute it get exceptions.I think the v_sqlstmt syntax is wrong, but I don't know what meant to be correct, please give some suggestions .
Cheers
-------------------- XDTest procedure --------------------------------------------------
p_cur OUT SYS_REFCURSOR
--AUTHID CURRENT_USER
IS
BEGIN
OPEN p_cur FOR
Select Table_Name from USER_Tables;
END XDTest;
-------------------- XDTest2 procedure --------------------------------------------------
p_cur OUT SYS_REFCURSOR
IS
TYPE T1 IS TABLE OF VARCHAR2(4000) INDEX BY BINARY_INTEGER ;
v_sqlstmt varchar2(1000):=null;
v_cursor number;
x_num number;
LN$Lig number := 0 ;
LN$MaxCol number := 0 ;
t T1 ;
v VARCHAR2(4000) ;
userTb User_Tables%ROWTYPE;
l_cur number;
BEGIN
LN$Lig := 0 ;
LN$MaxCol := 1 ;
--OPEN p_cur FOR
--execute immediate 'BEGIN XDTest (:1); END;' using OUT l_cur;
v_cursor:=dbms_sql.open_cursor;
v_sqlstmt:='begin :p_cur:="XDTest"(); END; ';
dbms_sql.parse(v_cursor,v_sqlstmt,DBMS_SQL.NATIVE);
dbms_sql.bind_variable(v_cursor,':p_cur',l_cur);
dbms_output.put_line('1');
-- Define the columns --
dbms_sql.DEFINE_COLUMN(v_cursor, 1, userTb.Table_Name, 30);
x_num:=dbms_sql.execute(v_cursor);
dbms_output.put_line('2');
-- Fetch the rows from the source query --
LOOP
IF dbms_sql.FETCH_ROWS(v_cursor)>0 THEN
-- get column values of the row --
dbms_sql.COLUMN_VALUE(v_cursor, 1,userTb.Table_Name);
dbms_output.put_line(userTb.Table_Name);
ELSE
-- No more rows --
EXIT;
END IF;
END LOOP;
dbms_sql.close_cursor(v_cursor);
END XDTest2;
---------------------- Error when execute ------------------------------------------------
1
BEGIN DevD0DB.XDTest2(:l_cur); END;
ERROR at line 1:
ORA-01007: variable not in select list
ORA-06512: at "SYS.DBMS_SYS_SQL", line 1010
ORA-06512: at "SYS.DBMS_SQL", line 212
ORA-06512: at "DEVD0DB.XDTEST2", line 35
ORA-06512: at line 1
---------------------------------------------------------------------------------------------------- -
ReadCursorResponse Items. How Do You Iterate Cursor Items?
I am working on some C# code that returns a cursor response. The cursor does have items in it. I can access them individually. How can I determine a "count" of items, or how do I control an interation loop of the items returned by the cursor? In other words, if I start reading items from the start of a cursor list, what is the best way to detemine the end of the list. Any help on controlling the loop starting at the cursor start through end would be appreciated.
Much of the code below is taken from the VB example in the documentation and converted to C#.
gwws.createCursorRequest gwCreateCursorReq = new gwws.createCursorRequest();
gwws.createCursorResponse gwCreateCursorResp = new gwws.createCursorResponse();
gwws.readCursorRequest gwReadCursorReq = new gwws.readCursorRequest();
gwws.readCursorResponse gwReadCursorResp = new gwws.readCursorResponse();
gwws.destroyCursorRequest gwDestroyCursorReq = new gwws.destroyCursorRequest();
gwws.destroyCursorResponse gwDestroyCursorResp = new gwws.destroyCursorResponse();
gwws.Filter gwFilter = new gwws.Filter();
gwws.FilterGroup gwFilterGroup = new gwws.FilterGroup();
gwws.FilterEntry[] gwfe = new gwws.FilterEntry[3];
string subject;
string location;
string edate;
string sdate;
string gwView;
// Filter for Appointment
gwfe[0] = new gwws.FilterEntry();
gwfe[0].op = gwws.FilterOp.eq;
gwfe[0].field = "@type";
gwfe[0].value = "Appointment";
// Filter for Date Range
gwfe[1] = new gwws.FilterEntry();
gwfe[1].op = gwws.FilterOp.gte;
gwfe[1].field = "startDate";
gwfe[1].value = "2012-01-01T00:00:00Z";
gwfe[2] = new gwws.FilterEntry();
gwfe[2].op = gwws.FilterOp.lte;
gwfe[2].field = "startDate";
gwfe[2].value = "2012-02-29T00:00:00Z";
// Use Filter
gwFilterGroup.op = gwws.FilterOp.and;
gwFilterGroup.element = gwfe;
gwFilter.element = gwFilterGroup;
gwView = "default peek id container @type message recipients attachments subject location startdate enddate place";
gwCreateCursorReq.view = gwView;
gwCreateCursorReq.container = "folders";
gwCreateCursorReq.filter = gwFilter;
gwCreateCursorResp = ws.createCursorRequest(gwCreateCursorReq);
if (gwCreateCursorResp.status.code != 0 || gwCreateCursorResp.cursorSpecified == false)
ofl.WriteLine("Problem creating cursor for: " );
// Read the items in the container
gwReadCursorReq.cursor = gwCreateCursorResp.cursor;
gwReadCursorReq.position = gwws.CursorSeek.start;
gwReadCursorReq.forward = true;
gwReadCursorReq.container = "folders";
gwReadCursorReq.count = 10;
gwReadCursorResp = ws.readCursorRequest(gwReadCursorReq);
int i = 1;
while ((gwReadCursorResp.items != null)) && (gwReadCursorReq.count > 0) && (gwReadCursorResp.status.code == 0))
gwReadCursorReq.position = gwws.CursorSeek.current;
gwReadCursorResp = ws.readCursorRequest(gwReadCursorReq);
if (gwReadCursorResp.status.code == 0)
gwws.Appointment c = (gwws.Appointment)gwReadCursorResp.items.item[i];
subject = c.subject;
sdate = c.startDate.ToString();
edate = c.endDate.ToString();
location = c.place;
ofl.WriteLine(subject + "," + location + "," + sdate + "," + edate + "," + gwReadCursorResp.status.code);
i++;
else
ofl.WriteLine("Cursor Status Problem" + " " + gwReadCursorResp.status.code);
MessageBox.Show("Appointments cCount " + gwReadCursorResp.items.count.ToString());
//' Make sure you destoy the cursors. The data in the cursor can go stale.
if (gwCreateCursorResp.cursorSpecified == true)
gwDestroyCursorReq.cursor = gwCreateCursorResp.cursor;
gwDestroyCursorResp = ws.destroyCursorRequest(gwDestroyCursorReq);
if (gwDestroyCursorResp.status.code != 0 )
MessageBox.Show("Problem destroying cursor for: " );If you are in the ide you can usually see what is available when you type
the '.' on an object.
For example, if you type:
gwReadCursorResp.items.
You should see:
gwReadCursorResp.items.Length
You should be able to do a normal for statement.
There should be a simple C# client example that might help you.
Preston
>>> On Tuesday, January 24, 2012 at 11:46 AM,
millerj0752<[email protected]> wrote:
> I am working on some C# code that returns a cursor response. The cursor
> does have items in it. I can access them individually. How can I
> determine a "count" of items, or how do I control an interation loop of
> the items returned by the cursor? In other words, if I start reading
> items from the start of a cursor list, what is the best way to detemine
> the end of the list. Any help on controlling the loop starting at the
> cursor start through end would be appreciated.
>
>
> Much of the code below is taken from the VB example in the
> documentation and converted to C#.
>
> gwws.createCursorRequest gwCreateCursorReq = new
> gwws.createCursorRequest();
> gwws.createCursorResponse gwCreateCursorResp = new
> gwws.createCursorResponse();
> gwws.readCursorRequest gwReadCursorReq = new
> gwws.readCursorRequest();
> gwws.readCursorResponse gwReadCursorResp = new
> gwws.readCursorResponse();
> gwws.destroyCursorRequest gwDestroyCursorReq = new
> gwws.destroyCursorRequest();
> gwws.destroyCursorResponse gwDestroyCursorResp = new
> gwws.destroyCursorResponse();
> gwws.Filter gwFilter = new gwws.Filter();
> gwws.FilterGroup gwFilterGroup = new gwws.FilterGroup();
> gwws.FilterEntry[] gwfe = new gwws.FilterEntry[3];
>
> string subject;
> string location;
> string edate;
> string sdate;
> string gwView;
>
> // Filter for Appointment
> gwfe[0] = new gwws.FilterEntry();
> gwfe[0].op = gwws.FilterOp.eq;
> gwfe[0].field = "@type";
> gwfe[0].value = "Appointment";
>
> // Filter for Date Range
> gwfe[1] = new gwws.FilterEntry();
> gwfe[1].op = gwws.FilterOp.gte;
> gwfe[1].field = "startDate";
> gwfe[1].value = "2012‑01‑01T00:00:00Z";
>
> gwfe[2] = new gwws.FilterEntry();
> gwfe[2].op = gwws.FilterOp.lte;
> gwfe[2].field = "startDate";
> gwfe[2].value = "2012‑02‑29T00:00:00Z";
>
> // Use Filter
> gwFilterGroup.op = gwws.FilterOp.and;
> gwFilterGroup.element = gwfe;
> gwFilter.element = gwFilterGroup;
>
> gwView = "default peek id container @type message recipients
> attachments subject location startdate enddate place";
> gwCreateCursorReq.view = gwView;
>
> gwCreateCursorReq.container = "folders";
> gwCreateCursorReq.filter = gwFilter;
>
> gwCreateCursorResp =
> ws.createCursorRequest(gwCreateCursorReq);
>
> if (gwCreateCursorResp.status.code != 0 ||
> gwCreateCursorResp.cursorSpecified == false)
> {
> {
> ofl.WriteLine("Problem creating cursor for: " );
> }
> }
> // Read the items in the container
> gwReadCursorReq.cursor = gwCreateCursorResp.cursor;
> gwReadCursorReq.position = gwws.CursorSeek.start;
> gwReadCursorReq.forward = true;
> gwReadCursorReq.container = "folders";
> gwReadCursorReq.count = 10;
> gwReadCursorResp = ws.readCursorRequest(gwReadCursorReq);
>
> int i = 1;
> while ((gwReadCursorResp.items != null)) &&
> (gwReadCursorReq.count > 0) && (gwReadCursorResp.status.code == 0))
> {
> gwReadCursorReq.position = gwws.CursorSeek.current;
> gwReadCursorResp = ws.readCursorRequest(gwReadCursorReq);
>
> if (gwReadCursorResp.status.code == 0)
> {
> {
> gwws.Appointment c =
> (gwws.Appointment)gwReadCursorResp.items.item[i];
> subject = c.subject;
> sdate = c.startDate.ToString();
> edate = c.endDate.ToString();
> location = c.place;
> ofl.WriteLine(subject + "," + location + "," +
> sdate + "," + edate + "," + gwReadCursorResp.status.code);
> i++;
> }
> }
> else
> {
> ofl.WriteLine("Cursor Status Problem" + " " +
> gwReadCursorResp.status.code);
> }
>
> }
>
> MessageBox.Show("Appointments cCount " +
> gwReadCursorResp.items.count.ToString());
>
> //' Make sure you destoy the cursors. The data in the cursor
> can go stale.
> if (gwCreateCursorResp.cursorSpecified == true)
> {
> gwDestroyCursorReq.cursor = gwCreateCursorResp.cursor;
> gwDestroyCursorResp =
> ws.destroyCursorRequest(gwDestroyCursorReq);
> if (gwDestroyCursorResp.status.code != 0 )
> {
> MessageBox.Show("Problem destroying cursor for: " );
> }
> }
>
> } -
Hello Guru's,
we are creating sales order in SAP from a quote created in .NET, through Web Service created in SAP, and consumed in .NET.
When ever a order is created in SAP for a given quote, SAP returns the sales order number to .NET.
Orders are getting created as expected, but once in a while we are getting the following error from webservice :
Web service processing error; more details in the web service error log on provider side (UTC timestamp 20140609173429; Transaction ID 4DFCEFE33301F1EBB5CE00155D0B4530)
But the problem is order is getting created in SAP for the perticular quote for which we are getting the above error and this order number is not getting returned to .NET.
Upon analysis in TCODE SRT_UTIL for the above transaction ID, has the following details , which are hardly help full to resolve the error.
----TYPE CX_SY_OPEN_SQL_DB
----ERROR_TEXT The database returned a value containing an error
----CX_SY_NO_HANDLER
-----CLASSNAME CX_SY_OPEN_SQL_DB
This Exception raised by Web Service application
Could you please help in resolving this issue or alteast provide an approach for the same.
Thank you,
Suresh.Thank you Bhaskar,
How can we clarify whether the error is from SAP or Web part.
I have checked ST22, but there is not entry for the perticular exception transaction ID
My exception time stamp is
-------------------START-------------6/9/2014 1:34:33 PM
Error :Web service processing error; more details in the web service error log on provider side (UTC timestamp 20140609173429; Transaction ID 4DFCEFE33301F1EBB5CE00155D0B4530)
-------------------END-------------6/9/2014 1:34:33 PM
In al11, i found the following for the perticular exception time stamp
**** Trace file opened at 20140609 133431 Eastern Daylight Time, by disp+work
**** Versions SAP-REL 720,0,500 RFC-VER U 3 1442251 MT-SL
XRFC> Begin of user trace
XRFC> ---------------------------------------------------------------------
XRFC> <
XRFC> TRACE SOAP RUNTIME - header <
XRFC> <
XRFC> ------------------------------------------------------------------ <
XRFC> REQ_SIZE : 2685 <
XRFC> RESP_SIZE : 0 <
XRFC> PARENT_ID : ROOT_CALL_ID <
XRFC> TRC_KEY : 40FCEFE3BD6EF184B5CE00155D0B4530 <
XRFC> REQ_BASED : <
XRFC> SESSION_ID : 0003925540FCEFE3BD6EF17DB5CE00155D0B4530 <
XRFC> TS_CALL : 20140609173408.2880000 <
XRFC> SY_UNAME : <
XRFC> HOSTNAME : <
XRFC> SY_SID : PRD <
XRFC> SY_MANDT : 300 <
XRFC> SYS_NR : 19 <
XRFC> APPLSERVER : <
XRFC> ISPRESCHED : X <
XRFC> DURATION : 21810 <
XRFC> NETHDRTIME : 21810 <
XRFC> CALL_STATE : 2 <
XRFC> ERRORTYPE : APPLFAIL <
XRFC> ERRORAREA : APPL <
XRFC> CTXDP_TYPE : SOAP_RUNTIME <
XRFC> SYNC_ASYNC : S <
XRFC> LOCATION : P <
XRFC> DIRECTION : I <
XRFC> REQ_ID : 91C57815916E421CA9F3D652FFACE9C7 <
XRFC> RESP_ID : 00155D0B45301EE3BBFF89A0267EB5CE <
XRFC> MSG_STATE : 114 <
XRFC> IF_NAME_I : ZSD_CS_CREATE_SALESORDER_SERVI <
XRFC> IF_NS_E : urn:sap-com:document:sap:soap:functions:mc-style <
XRFC> IF_NAME_E : ZSD_CS_CREATE_SALESORDER_SERVI <
XRFC> ISSHORTCUT : <
XRFC> TRC_PATT : WSTEST <
XRFC> TRC_SSID : PRD_19 <
XRFC> TRC_USER : <
XRFC> TRC_TS : 20140609173409 <
XRFC> TRC_COUNT : 99 <
XRFC> TRC_EXT : <
XRFC> COMPLETE : OK <
XRFC> CALLEDPROG : ZSD_CS_CREATE_SALESORDER_SERVI <
XRFC> SOAP_APPLI : urn:sap-com:soap:runtime:application:rfc:710 <
XRFC> CONF_ID : 00155D0B45301EE3AEFDAD78756555CE <
XRFC> BIND_ID : 00155D0B45301EE3AEFDAD787565B5CE <
XRFC> OP_NAME : ZsdCsCreateSalesorder <
XRFC> COMM_PATRN : Method:ZsdCsCreateSalesorder <
XRFC> OP_NS : urn:sap-com:document:sap:soap:functions:mc-style <
XRFC> REMADDRESS : 172.16.11.43 <
XRFC> DT_OBJ : ZSD_CS_CREATE_SALESORDER_SERVI <
XRFC> MEMCONSUMP : 296291 <
XRFC> WSHOST : <
XRFC> WSPORT : <
XRFC> WSPROT : <
XRFC> WSCLIENT : <
XRFC> WSPATH : <
XRFC> PXYHOST : <
XRFC> PXYPORT : <
XRFC> USEDRFCDES : <
XRFC> BONAME : <
XRFC> PROCCOMP : <
XRFC> DEPLOYUNIT : <
XRFC> ------------------------------------------------------------------ <
XRFC> <
XRFC> TRACE SOAP RUNTIME - trace records <
XRFC> <
XRFC> ------------------------------------------------------------------ <
XRFC> E SOAP_RUNTIME 20140609173429.7400000 : CL_SOAP_RUNTIME_SERVER <
XRFC> ->EXECUTE_PROCESSING Exception handling for IF "ZSD_CS_CREATE <
XRFC> _SALESORDER_SERVI" OP name "ZsdCsCreateSalesorder" MSG ID <
XRFC> "91C57815916E421CA9F3D652FFACE9C7" user "STULZWEBSERV" <
XRFC> <
XRFC> <
XRFC> E SOAP_RUNTIME 20140609173429.7240000 : CL_SOAP_RUNTIME_SERVER <
XRFC> ->EXECUTE_PROCESSING CX_SOAP_ROOT : An exception has occurred. | <
XRFC> program: CL_SOAP_RUNTIME_ROOT==========CP include: CL_SOAP <
XRFC> _RUNTIME_ROOT==========CM004 line: 120 <
XRFC> <
XRFC> <
XRFC> E SOAP_RUNTIME 20140609173429.7400000 : CL_SOAP_RUNTIME_SERVER <
XRFC> ->EXECUTE_PROCESSING CX_SY_NO_HANDLER : An exception with the type <
XRFC> CX_SY_OPEN_SQL_DB occurred, but was neither handled locally, nor <
XRFC> declared in a RAISING clause | program: SAPLSTXD include: LSTXDFDB <
XRFC> line: 200 <
XRFC> <
XRFC> <
XRFC> E SOAP_RUNTIME 20140609173429.7400000 : CL_SOAP_RUNTIME_SERVER <
XRFC> ->EXECUTE_PROCESSING CX_SY_OPEN_SQL_DB : The database returned a <
XRFC> value containing an error | program: SAPLSTXD include: LSTXDFDB <
XRFC> line: 227 <
XRFC> <
XRFC> ---------------------------------------------------------------------
XRFC> End of user trace -
How to return a html repsonse after form guide rendering in browser?
How to return a html repsonse after form guide rendering in browser indicating that server has recieved transmission and request is submitted succesfuly?
I am rendering the form guide in browser using guide invoke service and when i submit the data in browser to server through guide , it is displaying some random number in browser?
i need to display a resposne that request is submitted successfully?how could i define a variable with "html data" ?
Create a variable of type document and then a service to read the html from where ever it's located. If you put it in LiveCycle, you can use the ReadRessource service. If it's on the file system, you can use the Read Document. If it's in the database, you can use the JDBC service.
Also, one more doubt where should i use this variable in my process to get the same?
You want the response once you've submitted the data, so the html is really the result of calling the process that's processing the data. So I would create an output variable of type document on that process.
Right now it displays a random number in the browser because your submit process is long lived. When a process is long lived (asynchronous), you invoke it and then you get an identifier back. It's kind of a fire and forget. You can use that identifier to check the status of the long lived process, since long lived processes can take hours, days to complete. You don't want your browser to wait that long, hence the identifier.
However if you change the process to be short lived (synchronous), the browser will wait for the result of the process, which really means the output variables for that process. If your output variable contains html, it'll display html.
So the key is make you submit process short lived and populate the output variables appropriately.
Jasmin -
I need help in figuring out the best solution for returning data through a package which will contain repeating data from multiple tables. For example
I have two tables one and two
one(position,name) and contains
sales, david
sales, jane
marketing, jon
two (name, product_id) contains
david, 45
david, 68
david, 75
jane, 1
the user will input position and i need to return a cursor that will contain all the values in tables one and two where names equal each other. So if a person enters in sales i would need to return
sales, david, 45
68
75
sales, jane 1
without repeating position and name over and over.You may use two ref cursors
CREATE OR REPLACE PROCEDURE test_ps (
in_id NUMBER,
cur1 OUT sys_refcursor,
cur2 OUT sys_refcursor
AS
BEGIN
OPEN cur1 FOR
SELECT 1
FROM DUAL;
OPEN cur2 FOR
SELECT 2
FROM DUAL;
END;
Maybe you are looking for
-
Multiple (but separate) domain problem & Apple's slow and useless response
I am having problem with multiple (but separate) domain. I opened a ticket. Here is Apple's slow and useless response and my follow up. This follow up is not going to resolve the issues I am having. The sites are not in one domain file. I have split
-
Saved audio in ALU, though loop not appearing in loops browser
I am following David Dvorin's Beyond the Basics and am up to the part about Apple Loops Utility. In it he uses an imported audio file called Chimey Guitar, the whole point is to use ALU, use its functions and then save it as an Apple Loop. When I hav
-
Missing System under Product Version at Maintenance Optimizer
Hello Colleagues, We currently using SAP Solution Manager 4.0 SP11 for our SAP landscape. For upgrade our new PI 7.1 system with EHP1 we need to download respective files at SAP Solution Manager with the Maintenance Optimizer. Under Product Version (
-
I looked at the other posts regarding volume levels on the iPhone 4 but I don't see anything that applied to my issue, or offered a suggestion that I could try. Using the phone in hand-held mode the volume on the phone is okay, not as loud as I'd lik
-
Hi, I have Illustrator 10 and am working on a Windows Vista machine. I have had intermittant problems with this combination, but have been able to make it work. Up to yesterday, I was able to save for web using ctrl-alt-shift-s command to bring up th