473,394 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

return a variable value in a cursor

I am trying to return a variable value in a cursor below but I get the following error. I am not very familiar with PL/SQL so any help would be great. It compiles fine

System.Data.OleDb.OleDbException: ORA-00900: invalid SQL statement

SQL call is as below

Dim sql As String = "{call LOGIN_APPLICATION_INTERFACE.CHECK_USERUNIT(" & unitID & _
", '" & unit & "', {resultset 0, IO_CURSOR})}"

Here is the procedure body...

PROCEDURE CHECK_USERUNIT(UNITID IN INTEGER, UNIT IN VARCHAR2, IO_CURSOR OUT T_CURSOR) IS
UNIT_COUNT INTEGER;
RETURNVAL VARCHAR2 (1);
BEGIN

IF UPPER(UNIT) = 'RISK' THEN
SELECT COUNT(*) INTO UNIT_COUNT
FROM LOGIN_UNIT
WHERE UNIT_DESC = 'Risk Management' and UNIT_ID = UNITID;

IF UNIT_COUNT > 0 THEN
RETURNVAL := 'Y';
ELSE
RETURNVAL := 'N';
END IF;

OPEN IO_CURSOR FOR
RETURNVAL;

ELSIF UPPER(UNIT) = 'FRONTOFFICE' THEN
SELECT COUNT(*) INTO UNIT_COUNT
FROM LOGIN_UNIT
WHERE unit_desc='BZWBK' OR unit_desc='Wholesale Treasury'
OR unit_desc='New York' AND UNIT_ID = UNITID;

IF UNIT_COUNT > 0 THEN
RETURNVAL := 'Y';
ELSE
RETURNVAL := 'N';
END IF;

OPEN IO_CURSOR FOR
RETURNVAL;

END IF;
END;

Thanks in advance
May 10 '07 #1
6 2677
Saii
145 Expert 100+
What are you trying to do? Open cursor for Y and N? why do u need a cursor to return a Y or N value?
May 10 '07 #2
What are you trying to do? Open cursor for Y and N? why do u need a cursor to return a Y or N value?
I don't have to do it this way, but I want to know is it possible and if so, how?

I am mostly from a SQL server background and it is very easy to do in SQL server.

Thanks
May 11 '07 #3
frozenmist
179 Expert 100+
Hi,
You have to give create or replace procedure.
And could you give an input on what T_CURSOR is?

Cheers
May 11 '07 #4
T_CURSOR is declared in Package spec as below

TYPE T_CURSOR IS REF CURSOR;

I have no problems creating a new proc, I just need to know the syntax and if possible to return a variable in a cursor?

Thanks
May 11 '07 #5
frozenmist
179 Expert 100+
Hi Shay,

It is possible to return.
Though I am not sure of the syntax.
May be some of the other Experts may be able to help you with the syntax

Cheers
May 11 '07 #6
Saii
145 Expert 100+
hi,

Cursors/Ref cursors in Pl/SQL are used to handle resultsets(multiple records dataset). Say for example, you want to pass output of "select * from emp" to some outer code/ application, then you can simply use open cursor for select * from emp and pass the cursor as OUT parameter.
For passing variables like Y and N in your case, you can simply have an OUT varchar2 type parameter.
Hope that helps!!!
May 11 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: RayP | last post by:
I'd appreciate some help I'm having trying to run a cursor. First, some background. The Status field of all records on Table A needs changing from 1 to 0 where there is no corresponding record...
3
by: r rk | last post by:
I am trying to write a utility/query to get a report from a table. Below is the some values in the table: table name: dba_daily_resource_usage_v1...
4
by: ronloxton | last post by:
Hi All: I am attemting to write some Visual Basic Scripts that will call a DB2 stored procedure and get the return value. The test scripts are shown below. Not sure why I cannot get the...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
1
by: Grzegorz Smith | last post by:
Hi all. I'm trying get data from text field in MySQl 5.0 with my National characters. Data are stored in utf8 encodings. Here is the script: import MySQLdb, MySQLdb.cursors conn =...
1
by: Ergates | last post by:
I'm sure I'm just being thick, but I just can't get the following to work. I have loaded an XSD file into an Oracle xmltype table (called xsd_table here). The xsd looks roughly like this: ...
3
by: mckbill | last post by:
Is there a way I can direct the cursor to a specific field (variable) in a form by typing the field name while in form view? I have a form with many fields, and it would be nice if there were...
12
by: Dooza | last post by:
I have a stored procedure that takes a number of inputs, does a bulk insert, and then outputs a recordset. When I run the stored procedure in Server Management Studio I also get a return value from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.