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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to read dynamically column names from a cursor

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-10-17 : 07:50:58
Santosh writes "Normally when we open a cursor, we access the column values like mycursor.column_name.

Here we use the column name, but i want to access the column values without using the name of the column...

something like mycursor.columns(1), mycursor.columns(2) etc.

is it possible in any way ?

Thanks,
Santosh."

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2006-10-17 : 09:45:42
A dynamic cursor...how intriguing...

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-10-17 : 09:57:16
First of all, you can't read cursor like cursorname.column. You must be talking about ORACLE there. In SQL, you have to fetch values from cursor into local variables using FETCH statment. Your case is only possible when you use Recordset object from client side and use Recordset.Fields(0).

Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-17 : 12:16:24
>>but i want to access the column values without using the name of the column...

Why?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2006-10-17 : 15:48:46
quote:
Why?
Cause I don't want to actually do it correctly, so I can keep my job security fixing it for the next 10 years.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-10-17 : 16:11:30
I actually saw this in Java to DB2 where the columns where referenced as offsets...but that was because DB2 wasn't configured correctly

We fixed that



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-18 : 09:24:07
>>Cause I don't want to actually do it correctly, so I can keep my job security fixing it for the next 10 years.



I think the questioner tries to use the same method of how he/she does in front end like rs(0), rs(1), etc

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -