brgdotnet
asked on
Need help understanding some cursor code
I need help understanding some sql which uses Cursors. Look at lines 7 and 8 below. What is this code doing? Is it selecting the very first row of the cursor and storing it in the variables (@lchCountryCode, @lchPrefix, @lchSuffix), or is it selecting the last row? I need some help understanding this and am seeking expert help please.
1 DECLARE CURS_COUNTRY
2 FOR
3 SELECT COPAL_COUNTRY_CD, COPAL_PREFIX, COPAL_SUFFIX
4 FROM TBL_FCTS_COPAL_STATE_CDS COPAL
5 WHERE COPAL.COPAL_ACTIVE = 1
6 ORDER BY COPAL_STATE_CD
7 OPEN CUR_COUNTRY
8 FETCH NEXT FROM CURS_COUNTRY
9 INTO @lchCountryCode, @lchPrefix, @lchSuffix
1 DECLARE CURS_COUNTRY
2 FOR
3 SELECT COPAL_COUNTRY_CD, COPAL_PREFIX, COPAL_SUFFIX
4 FROM TBL_FCTS_COPAL_STATE_CDS COPAL
5 WHERE COPAL.COPAL_ACTIVE = 1
6 ORDER BY COPAL_STATE_CD
7 OPEN CUR_COUNTRY
8 FETCH NEXT FROM CURS_COUNTRY
9 INTO @lchCountryCode, @lchPrefix, @lchSuffix
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.