473,386 Members | 1,757 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,386 software developers and data experts.

MSSQL Output Cursor Parameter

I have a stored procedure :

CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT
AS
set @RETCUR = CURSOR
FORWARD_ONLY STATIC FOR
SELECT ID,STORE_NAME FROM T_INF_STORE
ORDER BY STORE_NAME
OPEN @RETCUR

It has an output cursor variable.

How can i use it in .net?

There is no any sqldbtype.Cursor parameter

object my_DBNull;

my_DBNull = Convert.DBNull;

SqlParameter pm = new SqlParameter ( "@RETCUR",SqlDbType.Variant ,2000,
ParameterDirection.Output,true,0,0,"",DataRowVersi on.Default ,my_DBNull);

And above line is not working also.

I can do it in oracle with

create or replace procedure STP_GETSTORELIST(RETCUR out types.ref_cursor)
AS
begin
open RETCUR for
SELECT ID,STORE_NAME FROM T_INF_STORE;
end STP_GETSTORELIST;
OracleParameter pm = new OracleParameter ( "RETCUR",OracleType.Cursor,2000,
ParameterDirection.Output,true,0,0,"",DataRowVersi on.Default,my_DBNull);

Please send answer also to my e-mail too. (if exist)

Regards.

Nov 16 '05 #1
8 13958
Yusuf,

Do you have to have it return a cursor? Have you considered just
performing the select, and then checking the results of the select?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yusuf INCEKARA" <yi*******@mikrokom.com> wrote in message
news:eK**************@TK2MSFTNGP12.phx.gbl...
I have a stored procedure :

CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT
AS
set @RETCUR = CURSOR
FORWARD_ONLY STATIC FOR
SELECT ID,STORE_NAME FROM T_INF_STORE
ORDER BY STORE_NAME
OPEN @RETCUR

It has an output cursor variable.

How can i use it in .net?

There is no any sqldbtype.Cursor parameter

object my_DBNull;

my_DBNull = Convert.DBNull;

SqlParameter pm = new SqlParameter ( "@RETCUR",SqlDbType.Variant ,2000,
ParameterDirection.Output,true,0,0,"",DataRowVersi on.Default ,my_DBNull);

And above line is not working also.

I can do it in oracle with

create or replace procedure STP_GETSTORELIST(RETCUR out types.ref_cursor)
AS
begin
open RETCUR for
SELECT ID,STORE_NAME FROM T_INF_STORE;
end STP_GETSTORELIST;
OracleParameter pm = new OracleParameter (
"RETCUR",OracleType.Cursor,2000,
ParameterDirection.Output,true,0,0,"",DataRowVersi on.Default,my_DBNull);

Please send answer also to my e-mail too. (if exist)

Regards.


Nov 16 '05 #2
My application Architect :

User Interface Layer (UIL)
Business Layer (BL)
Service Layer (SL)
Generic Data Access Layer(GDAL)

GDAL decides which provider to use at runtime.
All sql statements are in stored procedures.
GDAL Can use MSSQL , ORACLE , OLEDB , ODBC ... and any .net managed
provider.
For coding transparency i need to use output cursor. In my codes there is a
line

GDal.ExecCursorStp("STP_GETSTORELIST",CommandType. StoredProcedure, pmi,ref
ds);
where pmi is parameter array and ds is a Dataset.
It works fine with Oracle. And all other parts that are not returning an
output cursor are working fine too with both MSSQL and Oracle.
----- Original Message -----
From: "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Monday, November 29, 2004 8:45 PM
Subject: Re: MSSQL Output Cursor Parameter

Yusuf,

Do you have to have it return a cursor? Have you considered just
performing the select, and then checking the results of the select?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yusuf INCEKARA" <yi*******@mikrokom.com> wrote in message
news:eK**************@TK2MSFTNGP12.phx.gbl...
I have a stored procedure :

CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT
AS
set @RETCUR = CURSOR
FORWARD_ONLY STATIC FOR
SELECT ID,STORE_NAME FROM T_INF_STORE
ORDER BY STORE_NAME
OPEN @RETCUR

It has an output cursor variable.

How can i use it in .net?

There is no any sqldbtype.Cursor parameter

object my_DBNull;

my_DBNull = Convert.DBNull;

SqlParameter pm = new SqlParameter ( "@RETCUR",SqlDbType.Variant ,2000,
ParameterDirection.Output,true,0,0,"",DataRowVersi on.Default ,my_DBNull);
And above line is not working also.

I can do it in oracle with

create or replace procedure STP_GETSTORELIST(RETCUR out types.ref_cursor) AS
begin
open RETCUR for
SELECT ID,STORE_NAME FROM T_INF_STORE;
end STP_GETSTORELIST;
OracleParameter pm = new OracleParameter (
"RETCUR",OracleType.Cursor,2000,
ParameterDirection.Output,true,0,0,"",DataRowVersi on.Default,my_DBNull);

Please send answer also to my e-mail too. (if exist)

Regards.



Nov 16 '05 #3
Yusef,

If you want transparency, then you aren't going to be able to return the
cursor from SQL server like that, as I am not sure it is supported by the
framework.

I still don't understand why you can't just declare your stored
procedure like this:

CREATE PROCEDURE STP_GETSTORELIST
AS
SELECT ID,STORE_NAME FROM T_INF_STORE
ORDER BY STORE_NAME

This would make it more universally accessible, no?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yusuf INCEKARA" <yi*******@mikrokom.com> wrote in message
news:eG**************@TK2MSFTNGP11.phx.gbl...
My application Architect :

User Interface Layer (UIL)
Business Layer (BL)
Service Layer (SL)
Generic Data Access Layer(GDAL)

GDAL decides which provider to use at runtime.
All sql statements are in stored procedures.
GDAL Can use MSSQL , ORACLE , OLEDB , ODBC ... and any .net managed
provider.
For coding transparency i need to use output cursor. In my codes there is
a
line

GDal.ExecCursorStp("STP_GETSTORELIST",CommandType. StoredProcedure, pmi,ref
ds);
where pmi is parameter array and ds is a Dataset.
It works fine with Oracle. And all other parts that are not returning an
output cursor are working fine too with both MSSQL and Oracle.
----- Original Message -----
From: "Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Monday, November 29, 2004 8:45 PM
Subject: Re: MSSQL Output Cursor Parameter

Yusuf,

Do you have to have it return a cursor? Have you considered just
performing the select, and then checking the results of the select?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yusuf INCEKARA" <yi*******@mikrokom.com> wrote in message
news:eK**************@TK2MSFTNGP12.phx.gbl...
>I have a stored procedure :
>
> CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT
> AS
> set @RETCUR = CURSOR
> FORWARD_ONLY STATIC FOR
> SELECT ID,STORE_NAME FROM T_INF_STORE
> ORDER BY STORE_NAME
> OPEN @RETCUR
>
> It has an output cursor variable.
>
> How can i use it in .net?
>
> There is no any sqldbtype.Cursor parameter
>
> object my_DBNull;
>
> my_DBNull = Convert.DBNull;
>
> SqlParameter pm = new SqlParameter ( "@RETCUR",SqlDbType.Variant ,2000,
> ParameterDirection.Output,true,0,0,"",DataRowVersi on.Default ,my_DBNull); >
> And above line is not working also.
>
> I can do it in oracle with
>
> create or replace procedure STP_GETSTORELIST(RETCUR out types.ref_cursor) > AS
> begin
> open RETCUR for
> SELECT ID,STORE_NAME FROM T_INF_STORE;
> end STP_GETSTORELIST;
>
>
> OracleParameter pm = new OracleParameter (
> "RETCUR",OracleType.Cursor,2000,
> ParameterDirection.Output,true,0,0,"",DataRowVersi on.Default,my_DBNull);
>
> Please send answer also to my e-mail too. (if exist)
>
> Regards.
>
>
>
>
>



Nov 16 '05 #4
Well this is the code where i call database :

MWSNS.ParamStruct[] pmi = new MWSNS.ParamStruct[1];
pmi[0].Direction = ParameterDirection.Output ;

pmi[0].ParamName = "@RETCUR";

pmi[0].DataType = DbType.Object ;

pmi[0].Value = DBNull.Value;

DAL Dal=new DAL();

Dal.ExecCursorStp("STP_GETSTORELIST",CommandType.S toredProcedure, pmi,ref
ds);
In GDAL if DataType is object it convert it to Oracle.Cursor (if provider is
Oracle) or to SqlDbType.Variant (if provider is MSSQL)

return true;

It works with Oracle. If it works with MSSQL too i won't need any
customization in my project.

If not i have to customize code like this :

if (provider==EnumProviders.ORACLE)

{

MWSNS.ParamStruct[] pmi = new MWSNS.ParamStruct[1];

pmi[0].Direction = ParameterDirection.Output ;

pmi[0].ParamName = "@RETCUR";

pmi[0].DataType = DbType.Object ;

pmi[0].Value = DBNull.Value;

GDAL Dal=new GDAL();

Dal.ExecCursorStp("STP_GETSTORELIST",CommandType.S toredProcedure, pmi,ref
ds);
}

else

{

GDAL Dal=new GDAL();

dsMenu =Dal.ExecDataSet ("STP_GETSTORELIST",
System.Data.CommandType.Text);

}

Obviously i don't want to do this.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:#r**************@TK2MSFTNGP09.phx.gbl...
Yusef,

If you want transparency, then you aren't going to be able to return the cursor from SQL server like that, as I am not sure it is supported by the
framework.

I still don't understand why you can't just declare your stored
procedure like this:

CREATE PROCEDURE STP_GETSTORELIST
AS
SELECT ID,STORE_NAME FROM T_INF_STORE
ORDER BY STORE_NAME

This would make it more universally accessible, no?

Nov 16 '05 #5
Yusuf,

Right, but SQL Server doesn't support this construct, so if the oracle
SP was in this format as well, you could just wire up the SelectCommand
property of a DataAdapter with the command for the stored procedure, and
then populate a data set based on that.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com


"Yusuf INCEKARA" <yi*******@mikrokom.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Well this is the code where i call database :

MWSNS.ParamStruct[] pmi = new MWSNS.ParamStruct[1];
pmi[0].Direction = ParameterDirection.Output ;

pmi[0].ParamName = "@RETCUR";

pmi[0].DataType = DbType.Object ;

pmi[0].Value = DBNull.Value;

DAL Dal=new DAL();

Dal.ExecCursorStp("STP_GETSTORELIST",CommandType.S toredProcedure, pmi,ref
ds);
In GDAL if DataType is object it convert it to Oracle.Cursor (if provider
is
Oracle) or to SqlDbType.Variant (if provider is MSSQL)

return true;

It works with Oracle. If it works with MSSQL too i won't need any
customization in my project.

If not i have to customize code like this :

if (provider==EnumProviders.ORACLE)

{

MWSNS.ParamStruct[] pmi = new MWSNS.ParamStruct[1];

pmi[0].Direction = ParameterDirection.Output ;

pmi[0].ParamName = "@RETCUR";

pmi[0].DataType = DbType.Object ;

pmi[0].Value = DBNull.Value;

GDAL Dal=new GDAL();

Dal.ExecCursorStp("STP_GETSTORELIST",CommandType.S toredProcedure, pmi,ref
ds);
}

else

{

GDAL Dal=new GDAL();

dsMenu =Dal.ExecDataSet ("STP_GETSTORELIST",
System.Data.CommandType.Text);

}

Obviously i don't want to do this.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:#r**************@TK2MSFTNGP09.phx.gbl...
Yusef,

If you want transparency, then you aren't going to be able to return

the
cursor from SQL server like that, as I am not sure it is supported by the
framework.

I still don't understand why you can't just declare your stored
procedure like this:

CREATE PROCEDURE STP_GETSTORELIST
AS
SELECT ID,STORE_NAME FROM T_INF_STORE
ORDER BY STORE_NAME

This would make it more universally accessible, no?


Nov 16 '05 #6

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:#z**************@TK2MSFTNGP09.phx.gbl...
Yusuf,

Right, but SQL Server doesn't support this construct, so if the oracle
SP was in this format as well, you could just wire up the SelectCommand
property of a DataAdapter with the command for the stored procedure, and
then populate a data set based on that.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

SQL server supports this construct.
CREATE PROCEDURE STP_GETSTORELIST_CURSOR_VERSION
@RETCUR CURSOR VARYING OUTPUT
AS
set @RETCUR = CURSOR
FORWARD_ONLY STATIC FOR
SELECT ID,STORE_NAME FROM T_INF_STORE
ORDER BY STORE_NAME
OPEN @RETCUR
it works fine. But this is not working in .net. I am harding to understand
why?
Also Oracle SP is not is this format too in native. You cannot do anyting in
oracle with returning cursor .
It is for supporting Java Developers. And .net is supporting this construct
too.
I just wondering why Microsoft support output cursors in Oracle but not in
their own database product .
Nov 16 '05 #7
And also i change my GDAL. If provider is MSSQL
it just ignore cursor output parameters.
Entire project does not need to change. I have solve it in GDAL.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:#z**************@TK2MSFTNGP09.phx.gbl...
Yusuf,

Right, but SQL Server doesn't support this construct, so if the oracle
SP was in this format as well, you could just wire up the SelectCommand
property of a DataAdapter with the command for the stored procedure, and
then populate a data set based on that.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com


"Yusuf INCEKARA" <yi*******@mikrokom.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Well this is the code where i call database :

MWSNS.ParamStruct[] pmi = new MWSNS.ParamStruct[1];
pmi[0].Direction = ParameterDirection.Output ;

pmi[0].ParamName = "@RETCUR";

pmi[0].DataType = DbType.Object ;

pmi[0].Value = DBNull.Value;

DAL Dal=new DAL();

Dal.ExecCursorStp("STP_GETSTORELIST",CommandType.S toredProcedure, pmi,ref ds);
In GDAL if DataType is object it convert it to Oracle.Cursor (if provider is
Oracle) or to SqlDbType.Variant (if provider is MSSQL)

return true;

It works with Oracle. If it works with MSSQL too i won't need any
customization in my project.

If not i have to customize code like this :

if (provider==EnumProviders.ORACLE)

{

MWSNS.ParamStruct[] pmi = new MWSNS.ParamStruct[1];

pmi[0].Direction = ParameterDirection.Output ;

pmi[0].ParamName = "@RETCUR";

pmi[0].DataType = DbType.Object ;

pmi[0].Value = DBNull.Value;

GDAL Dal=new GDAL();

Dal.ExecCursorStp("STP_GETSTORELIST",CommandType.S toredProcedure, pmi,ref ds);
}

else

{

GDAL Dal=new GDAL();

dsMenu =Dal.ExecDataSet ("STP_GETSTORELIST",
System.Data.CommandType.Text);

}

Obviously i don't want to do this.
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:#r**************@TK2MSFTNGP09.phx.gbl...
Yusef,

If you want transparency, then you aren't going to be able to return
the
cursor from SQL server like that, as I am not sure it is supported by

the framework.

I still don't understand why you can't just declare your stored
procedure like this:

CREATE PROCEDURE STP_GETSTORELIST
AS
SELECT ID,STORE_NAME FROM T_INF_STORE
ORDER BY STORE_NAME

This would make it more universally accessible, no?



Nov 16 '05 #8
Yusef,

Yes, SQL Server supports it, but the provider for SQL Server in .NET
doesn't support it. To that end, you will have to use something else if you
want to access it in .NET.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Yusuf INCEKARA" <yi*******@mikrokom.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in
message news:#z**************@TK2MSFTNGP09.phx.gbl...
Yusuf,

Right, but SQL Server doesn't support this construct, so if the
oracle
SP was in this format as well, you could just wire up the SelectCommand
property of a DataAdapter with the command for the stored procedure, and
then populate a data set based on that.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

SQL server supports this construct.
CREATE PROCEDURE STP_GETSTORELIST_CURSOR_VERSION
@RETCUR CURSOR VARYING OUTPUT
AS
set @RETCUR = CURSOR
FORWARD_ONLY STATIC FOR
SELECT ID,STORE_NAME FROM T_INF_STORE
ORDER BY STORE_NAME
OPEN @RETCUR
it works fine. But this is not working in .net. I am harding to understand
why?
Also Oracle SP is not is this format too in native. You cannot do anyting
in
oracle with returning cursor .
It is for supporting Java Developers. And .net is supporting this
construct
too.
I just wondering why Microsoft support output cursors in Oracle but not in
their own database product .

Nov 16 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Philip Mette | last post by:
I am in a crunch and need to covert this Oracle statement to MSSQL. Is there any Oracle/MSSQL experts out there that can help me? I do not understand the syntax enough to modify this. Thanks so...
0
by: Yusuf INCEKARA | last post by:
I have a stored procedure : CREATE PROCEDURE STP_GETSTORELIST @RETCUR CURSOR VARYING OUTPUT AS set @RETCUR = CURSOR FORWARD_ONLY STATIC FOR SELECT ID,STORE_NAME FROM T_INF_STORE ORDER BY...
11
by: Axel | last post by:
Hi, I am currently creating an ASP page that returns a recordset of search result based on multiple keywords. The where string is dynamically built on the server page and that part work quite...
4
by: infidel | last post by:
I have a stored procedure that has a single output parameter. Why do I have to pass it a string big enough to hold the value it is to receive? Why can't I pass an empty string or None? >>>...
1
by: a | last post by:
how to send an xml dataset to a Stored Procedure in mssql I have an xml file that I read into a dataset. and I'm trying to use a stored procedure (see SPROC #1 below) that inserts this xml...
0
by: itamar82 | last post by:
I have a SP running on mssql server 2005. When I try to execute the SP through asp I receive back an error that the parameter @City is not supplied, although I clearly do supply it. Here is my...
4
by: sujiforsql | last post by:
i have a stored procedure like below CREATE PROCEDURE display_Products @CategoryID int AS BEGIN DECLARE @authors_cursor CURSOR SET @authors_cursor =CURSOR FAST_FORWARD FOR SELECT TOP 10...
1
by: Mike P | last post by:
I am trying to return an output parameter to my code on executing a stored procedure. In Query Analyzer, it works with no problem, but when I run my ASP code below, the output parameter never...
3
by: leesquare | last post by:
Hello, I need some help getting output values from my stored procedures when using adodbapi. There's an example testVariableReturningStoredProcedure in adodbapitest.py, and that works for my...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.