Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 data type of SQL server cursor

Author  Topic 

vinayakshukre
Starting Member

11 Posts

Posted - 2008-12-13 : 01:52:22
what is the data type of the cursor in SQL server ?
is it always int ?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-13 : 02:01:48
what do you mean by datatype of cursor? cursor by itself is a datatype

http://doc.ddart.net/mssql/sql70/cr-cz_2.htm
Go to Top of Page

vinayakshukre
Starting Member

11 Posts

Posted - 2008-12-13 : 02:06:35
Thanks visakh for taking time on my issue.
I understand cursor is itself a data type. But when get the data type of cursor column using
java.sql.DatabaseMetadata.getProcedureColumn() method, I get it as int.
so the confusion.
Even if you look at the procedure from SQL server management studio express - > Programmability - >Stored Procedures -> dbo.myproc - > parameters ....cursor is shown as int.

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-13 : 02:09:41
cursor column? you mean a column defined in cursor? are you trying to get return value from procedure?
Go to Top of Page

vinayakshukre
Starting Member

11 Posts

Posted - 2008-12-13 : 02:13:59
My procedure is here

create procedure myproc
@c1 cursor varying output
as
set @c1 = cursor for select * from employee;
open @c1

I want to execute this procedure from java program.
If i try to get the information of procedure's columns....i.e. @c1 I get it as int.

Go to Top of Page

vinayakshukre
Starting Member

11 Posts

Posted - 2008-12-13 : 02:19:14
Java code to get the info is here...
Connection con = DriverManager.getConnection(url,user,password) ;
DatabaseMetaData meta = con.getMetaData();
ResultSet rs = meta.getProcedureColumns(null, "dbo","myproc", null);
ResultSetMetaData rsmd = rs.getMetaData();
int iTotal = rsmd.getColumnCount();
while(rs.next()){

for(int i=1 ;i <= iTotal;i++){
System.out.print(rsmd.getColumnName(i) + " = " + rs.getObject(i) + " \t\t\t");
}
System.out.println();
}


and output is here

COLUMN_NAME = @RETURN_VALUE COLUMN_TYPE = 5 DATA_TYPE = 4 TYPE_NAME = int PRECISION = 10 LENGTH = 4 SCALE = 0 RADIX = 10 NULLABLE = 0 REMARKS = null



COLUMN_NAME = @c1 COLUMN_TYPE = 2 DATA_TYPE = 4 TYPE_NAME = int PRECISION = 10 LENGTH = 4 SCALE = 0 RADIX = 10 NULLABLE = 1 REMARKS = null
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-13 : 02:27:04
http://www.groupsrv.com/dotnet/about50204.html
Go to Top of Page

vinayakshukre
Starting Member

11 Posts

Posted - 2008-12-13 : 03:42:22
Thanks once again visakh for this usefull information.
I too had almost reached to the same conclusion that SQL server's cursor are not supported though JDBC.

Thanks again.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-13 : 03:58:04
welcome
Go to Top of Page
   

- Advertisement -