T-SQL: Cursor is not advancing to next record
SQL Version: 2008 R2
Problem: I have the code below which uses a cursor. The cursor keeps returning the first record and does not advance to the next record in the cursor. It appears as if the Fetch Next is not being recognized. The Select
Statement in the cursor declaration returns two records which is the result set I expect to be contained in the cursor record set.
...bob sutor
SQL CODE:
DECLARE
@ProcessGroupID nchar(4)
, @RemoveAuditUser nchar(128)
DECLARE CertGroupCursor CURSOR FOR
SELECT DISTINCT CertGroups.GroupCode, CertGroups.RemoveAuditUser
--, UserControl.ProcessGroupID, UserControl.VPUserName
FROM udCertGroups AS CertGroups
LEFT JOIN udAuditUsers AS UserControl
ON CertGroups.GroupCode = UserControl.ProcessGroupID
WHERE CertGroups.GroupCode = UserControl.ProcessGroupID
AND CertGroups.RemoveAuditUser = UserControl.VPUserName
OPEN CertGroupCursor
FETCH NEXT FROM CertGroupCursor INTO @ProcessGroupID, @RemoveAuditUser
WHILE @@FETCH_STATUS = 0
Print @ProcessGroupID + '-' + @RemoveAuditUser
DELETE FROM udAuditUsers
WHERE ProcessGroupID = @ProcessGroupID
AND VPUserName = @RemoveAuditUser
FETCH NEXT FROM CertGroupCursor INTO @ProcessGroupID, @RemoveAuditUser
CLOSE CertGroupCursor
DEALLOCATE CertGroupCursor
Bob Sutor
The real question is how to get rid of this mess. Think about the local “@remove_audit_user” as a variable; it's name is a verb, not a noun! and the NVARCHAR(n) lets you use Chinese Unicode. Why? In ISO-11179 rules , “remove_” is a called a role, and the
audit user would be the attribute with the attribute property “_user” in a valid data model. Where is the table that models “audit_users”? It has to be here by definition.
One of the first rules of data modeling is that a data element has one and only one name. This is a results of the Law of Identity in Logic (A is A: to be is to be something in particular, to be nothing in particular or many things in general is to be nothing
at all).
So how did “G.remove_audit_user = U.vp_user_name” occur?? ANSWER: lack of a design!
Your “G.group_code = U.process_group_id” is wrong. An identifier is not a code! TOTALLY DIFFERENT type of data elements! Do you have a postal code or a postal id? Blood_type or blood_id? Etc.? Have you ever read a book on basic data modeling?
The purpose of PRINT is debugging and not output. We had joke in the ANSI X3H2 Committee that SQL means “scarcely Qualified as a Language” because there is no I/O. PRINT will screw up performance in so many ways.
In a properly designed schema, we seldom use SELECT DISTINCT; we have keys and a valid schema that does not produce redundant duplicate rows. It might be valid, but after 30+ years of SQL, I would bet against it.
Your statement would use an EXISTS() predicate to handle multiple columns and conditions. But you did not bother with DDL, as required by basic Netiquette, so here is the skeleton I can give you.
DELETE FROM UD_Audit_Users
WHERE EXIST
(SELECT *
FROM UD_Cert_Groups AS G
WHERE G.process_group_id = ??
AND G.vp_user_name = ??;
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL
Similar Messages
-
My ipod will not advance to next song, how can I fix this?
My ipod nano will not advance to next song, neither in regular play or shuffle. Any ideas on how to get it to work?
Lilly.Love wrote:
Hi, I'm new to this and for some reason my images are not appearing to full scale on adobe premiere cs6. This is really annoying as I am trying to make a stop motion video but I can't see what I'm doing. Please reply soon, this is an important project. Thanks
Your sequence settings and clip settings are not matching. To make them match, right click on a clip and choose New Sequence from Clip and a new sequence will be created based on your clip settings. -
Itouch keeps repeating same song - will not advance to next song
Hi,
My itouch, after working fine for over one year, now will not advance to the next song automatically. It keeps repeating the next song.you haven't got the repeat button 'on' by accident have you
http://i19.photobucket.com/albums/b159/LUFCRACE/photo.jpg
the arrows on the left under the scroll bar. if they are blue then they are 'on'
(sounds obvious, but i solved this exact problem for someone this way only yesterday)
Message was edited by: Anna Sandham
Message was edited by: Anna Sandham -
Setting it up so that after a song finishes it does not advance to next????
I have many files that I need to play, though I want it setup so that after a song is done playing it does not advance to the next track. Is there anyway to do this? The only way I have found to do this is by making each and every song a separate playlist, however this will take a LONG time.
Thanks.So if I create a playlist with songs that I want to play and place tracks in between each song and uncheck the ones that are in between, will it play the song that I want to play and stop when it gets to the unchecked song and then wait until I skip to the next song that is checked to play?
No. iTunes doesn't stop when it reaches an unchecked song, it skips over it. So in your scenario it will skip over the unchecked song, go to the next checked song and play that. If you want to play one song and then stop, uncheck all the songs. Then there are no other songs for iTunes to play next and it will stop after playing the one you specifically selected. -
when listening to audiobooks, when a part finishes, i.e., part 1, ipod starts over at beginning of part just finished instead of advancing to the next part, i.e., part 2. Is there some setting I can change so it advances to next part instead of repeating the part I just finished?
iPod Nano 5th Gen. User Manual
-
Entering values in TableMaintenance,cursor does not stop at error record ?
Hello,
Very Good Morning!
When creating new entries in Table Maintenance, Cursor does not stop at the error record. It display's an error where the error is. But, cursor will skip to the first field of the record.
Ex : Sales Org, Mater, Sales Obj %, Frist arr date.
Suppose these are the fields available and I want to create a new entry.
When i enter incorrect value in Sales Obj %, it is displaying error message saying that i need to enter correct value. But the Cursor is skipping away to the first field Sales Org.
PLease help what to do...I tried using set cursor. But, I am not sure how to excatly use it and it was not working.
Any help will be appreciated.....
Thanks & Regards,
Krishna ChaitanyaHello,
This question is not answered.
I want to close this question. -
Text Entry with Tab Key not advancing to next slide
I am using Captivate 1 to create a screen that has a text
entry requiring the user to press the Tab key as the Shortcut Key.
The users are having to press the Tab key multiple times to get the
course to advance to the next slide. There does not seem to be a
rhyme or reason to which text entries this occurs in, nor does
there seem to be a pattern to the number of times or forcefulness
in which the Tab key must be pressed, though more aggressive key
presses have yielded better results. Sadly, requesting the users
bang the Tab key with as much force as they can muster is not a
viable option.
Here are things I have tried:
Decrease length of slide
Increasing active time of the text entry
Adding/removing playback control
Deleting and recreating text entries
If anyone has any idea what can be done to correct this
problem, it would be much appreciated.Hi berrylicious877
The following has worked for me in Cap1, so try it and see:
Add the text entry box and include the submit button.
Make the submit button transparent and edit text to a full
stop at the smallest available font size (Captivate won't accept a
submit button without something typed in and a full stop is the
smallest thing available display wise)
On the submit button, set the shortcut key to "Tab".
My reasoning was that the shortcut key on the text entry box
"activates" the box, thus allowing input and the shortcut key on
the "submit" button "deactivates" the box so that the slide can
move on as required.
Please let us know if this helps.
Andrew -
Hi,
Pls take a look at http://apex.oracle.com/pls/otn/f?p=30495:2:1313228760030470:::::
username is test
pwd is test
There are two buttons on it Previous and Next.
When I click on these buttons I want it to advance to next record (next button) . How can that be done? What kind of coding is requried?
Thanks
MunishHi,
For the next button you need a page process (conditional on the button ebing pressed ) something like:
select min(release_id) into :P1_RELEASE_ID from tpa_rel_releases
where
release_number = (select
min(release_number)
from tpa_rel_releases
where release_status !='C'
and release_number > (select release_number from tpa_rel_releases where release_id = :P1_RELEASE_ID));for the prev button use:
select min(release_id) into :P1_RELEASE_ID from tpa_rel_releases
where
release_number = (select
max(release_number)
from tpa_rel_releases
where release_status !='C'
and release_number < (select release_number from tpa_rel_releases where release_id = :P1_RELEASE_ID));Hope this helps,
Martin -
Problem in SQL with CURSOR( ) ,Why the CURSOR did not work?
hi All:
I have a problem in SQL with CURSOR.
The data is as the attachments.
Here is the SQL statement as follow:
SELECT A.WADCTO,A.WADOCO,B.IGCOST,CURSOR (SELECT X.IGLITM
FROM F3102 X
WHERE X.IGDOCO=A.WADOCO
AND X.IGCOST IN ('B1','D1','C3')) AS DETAIL
FROM F4801 A INNER JOIN F3102 B ON A.WADOCO=B.IGDOCO AND A.WADCTO=B.IGDCTO AND B.IGCOST>' '
WHERE A.WADOCO='10004'
The statement above returns records as follow:
WADC WADOCO IGCOST DETAIL
WO 10004 A1 CURSOR STATEMENT : 4
CURSOR STATEMENT : 4
IGLITM
1KV90CPG2
1KV90CPG2
1KV90CPG2
But, after I add one statement in the subquery, there is no record returned from CURSOR.
Here is the SQL statement:
SELECT A.WADCTO,A.WADOCO,B.IGCOST,CURSOR (SELECT X.IGLITM
FROM F3102 X
WHERE X.IGDOCO=A.WADOCO
AND X.IGCOST=B.IGCOST
AND X.IGCOST IN ('B1','D1','C3')) AS DETAIL
FROM F4801 A INNER JOIN F3102 B ON A.WADOCO=B.IGDOCO AND A.WADCTO=B.IGDCTO AND B.IGCOST>' '
WHERE A.WADOCO='10004'
The statement above returns records as follow:
WADC WADOCO IGCOST DETAIL
WO 10004 A1 CURSOR STATEMENT : 4
CURSOR STATEMENT : 4
no rows selected
Why the CURSOR did not work?
The database version is Oracle Database 10g Release 10.2.0.4.0 - 64bit Production.
F3102 DATA:
IGDOCO IGDCTO IGLITM IGCOST
10004 WO 1KV90CPG2 A1
10004 WO 1KV90CPG2 B1
10004 WO 1KV90CPG2 C3
10004 WO 1KV90CPG2 D1
F4801 DATA:
WADCTO WADOCO
WO 10004
Edited by: user2319139 on 2010/3/2 上午 1:17
Edited by: user2319139 on 2010/3/2 上午 1:20Why this structure and not a join?
The cursor() function returns a cursor handle that needs to be processed - in other words, the client needs to fetch data from it. The Oracle® Database SQL Reference+ (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/expressions005.htm#i1035107) describes it as being equivalent to a ref cursor handle.
Thus why are you creating ref cursor handles as a column in a SQL projection - where each row will have a "+nested+" ref cursor handle to process. What problem are you attempting to hack solve this way? -
Hello all,
We have configured JDBC Sender Adapter which fetches around 10K records with poll interval 1hr from DB2 System .
It was working fine,suddenly it started throwing an exception in Adapter Monitoring :
Error during conversion of query result to XML: java.sql.SQLException: Cursor state not valid.
It is not fetching any records.
Without changing any configurations when we tried to fetch to around 1000 records it's working fine.
For 10K records same exception persists
What could be the reason ?How to resolve this issue?
regards
GangaPrasadHello Christophe ,
Trace in VA :::
Date : 05/09/2008
Time : 11:45:57:750
Message : Unexpected error converting database resultset to XML, reason: java.sql.SQLException: Cursor state not valid.
at java.lang.Throwable.<init>(Throwable.java:194)
at java.lang.Exception.<init>(Exception.java:41)
at java.sql.SQLException.<init>(SQLException.java:40)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:389)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:366)
at com.ibm.as400.access.AS400JDBCResultSet.getValue(AS400JDBCResultSet.java:3580)
at com.ibm.as400.access.AS400JDBCResultSet.getString(AS400JDBCResultSet.java:3223)
at sun.reflect.GeneratedMethodAccessor459222074.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:309)
at com.sap.aii.adapter.jdbc.sql.jdbctrace.TraceInvocationHandler.invoke(TraceInvocationHandler.java:45)
at com.sap.aii.adapter.jdbc.sql.jdbctrace.$Proxy254.getString(Unknown Source)
at com.sap.aii.adapter.jdbc.JDBC2XI.convert2XML(JDBC2XI.java:954)
at com.sap.aii.adapter.jdbc.JDBC2XI.invoke(JDBC2XI.java:492)
at com.sap.aii.af.service.scheduler.JobBroker$Worker.run(JobBroker.java:475)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:99)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:119)
Severity : Error
Category : /Applications/ExchangeInfrastructure/AdapterFramework/Services/ADAPTER/ADMIN/JDBC
Location : com.sap.aii.adapter.jdbc.JDBC2XI.convert2XML(ResultSet, ResultSetMetaData)
Application :
Thread : XI JDBC2XI[JDBC_SND_DB2_VehicleReceiving/DB2PRD00/]_170
Datasource : 12428950:/usr/sap/PXI/DVEBMGS01/j2ee/cluster/server0/log/applications/com.sap.xi/xi.log
Message ID : 00145E742794005E0014980B000000BE00044CC763766C4F
Source Name : /Applications/ExchangeInfrastructure/AdapterFramework/Services/ADAPTER/ADMIN/JDBC
Argument Objs : java.sql.SQLException: Cursor state not valid.
at java.lang.Throwable.<init>(Throwable.java:194)
at java.lang.Exception.<init>(Exception.java:41)
at java.sql.SQLException.<init>(SQLException.java:40)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:389)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:366)
at com.ibm.as400.access.AS400JDBCResultSet.getValue(AS400JDBCResultSet.java:3580)
at com.ibm.as400.access.AS400JDBCResultSet.getString(AS400JDBCResultSet.java:3223)
at sun.reflect.GeneratedMethodAccessor459222074.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:309)
at com.sap.aii.adapter.jdbc.sql.jdbctrace.TraceInvocationHandler.invoke(TraceInvocationHandler.java:45)
at com.sap.aii.adapter.jdbc.sql.jdbctrace.$Proxy254.getString(Unknown Source)
at com.sap.aii.adapter.jdbc.JDBC2XI.convert2XML(JDBC2XI.java:954)
at com.sap.aii.adapter.jdbc.JDBC2XI.invoke(JDBC2XI.java:492)
at com.sap.aii.af.service.scheduler.JobBroker$Worker.run(JobBroker.java:475)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:99)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:119)
Arguments : java.sql.SQLException: Cursor state not valid.
at java.lang.Throwable.<init>(Throwable.java:194)
at java.lang.Exception.<init>(Exception.java:41)
at java.sql.SQLException.<init>(SQLException.java:40)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:389)
at com.ibm.as400.access.JDError.throwSQLException(JDError.java:366)
at com.ibm.as400.access.AS400JDBCResultSet.getValue(AS400JDBCResultSet.java:3580)
at com.ibm.as400.access.AS400JDBCResultSet.getString(AS400JDBCResultSet.java:3223)
at sun.reflect.GeneratedMethodAccessor459222074.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:309)
at com.sap.aii.adapter.jdbc.sql.jdbctrace.TraceInvocationHandler.invoke(TraceInvocationHandler.java:45)
at com.sap.aii.adapter.jdbc.sql.jdbctrace.$Proxy254.getString(Unknown Source)
at com.sap.aii.adapter.jdbc.JDBC2XI.convert2XML(JDBC2XI.java:954)
at com.sap.aii.adapter.jdbc.JDBC2XI.invoke(JDBC2XI.java:492)
at com.sap.aii.af.service.scheduler.JobBroker$Worker.run(JobBroker.java:475)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:99)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:119)
Dsr Component :
Dsr Transaction : d1f629d01d9b11dd984200145e742794
Dsr User :
Indent : 0
Level : 0
Message Code :
Message Type : 1
Relatives : com.sap.aii.adapter.jdbc.JDBC2XI
Resource Bundlename :
Session : 0
Source : /Applications/ExchangeInfrastructure/AdapterFramework/Services/ADAPTER/ADMIN/JDBC
ThreadObject : XI JDBC2XI[JDBC_SND_DB2_VehicleReceiving/DB2PRD00/]_170
Transaction : SAP J2EE Engine JTA Transaction : [0ffffffbdffffffa6ffffff960086]
User : J2EE_GUEST
Regards
Ganga Prasad -
When I am playing my music it will not advance to the next song, it just keeps repeating the song. The only way to go to the next song is to do it manually. It just started this after the last update. How do I fix it, hard to listen to at the gym.
Check the song and see if repeat is activated. Down in the bottom left corner is repeat when the music is running. It would have a colored box around it if it is active. It would either read Repeat Song, or Repeat Playlist.
-
ITunes 8 does not automatically advance to next track in album or playlist
iTunes 8 was recently installed for me by the company on my company laptop. This was done automatically by LANDesk. (We call this being LANDesked. I was forced by LANDesk to reboot my computer twice yesterday, but I digress.)
iTunes does not automatically advance to the next track in an album or playlist, either in list view or grid view.
List View: I can play any song in an album by double-clicking it or by selecting the track and pressing the play button. When it gets to the end of that track, it does not automatically advance to playing the next track. Pressing Ctrl-Right stops the current track and does not play the next track. The Next button is active and it, too, stops the current track and does not play the next track.
Grid View: Play Album button appears to be active but does nothing.
Is there some setting I'm missing that was set to do this in iTunes 7 but not in 8?Thanks. That fixes the problem. I'm an idiot.
I thought the check boxes were for selecting which tracks get synced to my iPod or iPhone. I must have unchecked them all (before the installation of iTunes 8) when I was trying to figure out how to sync a 2nd computer (this one) to my iPhone.
I can't find anything in the iTunes help about this necessary fact for playing your albums and playlists. If you look on the Index tab of the help, neither check nor uncheck are found in the list. If you search for check, you eventually find, amongst all the pages, that you need to have tracks checked in order to burn them to a CD and to import them from a CD, but I find nothing about checking to play tracks. Also, the help is very confusing on the difference between selecting one or more songs and checking the check boxes of one or more song. These seem to be used interchangeably occasionally. -
Submit button in Cap 7 quiz does not advance learner to next quiz slide
I created a 5 question MC quiz in Cap 7. When I take the quiz in the preview mode, I am able to advance to the next slide by clicking on the submit button. Well, when I click on the submit button, a pop up appears that says: Correct - click anywhere or press 'y' to continue. Once I click anywhere, *then* I am taken to the next question.
However, when I take the quiz in a web browser, I cannot advance to the next slide, even when I answer the question correctly. I click the submit button. The same pop up appears as in the preview mode: Correct - click anywhere or press 'y' to continue. So, I click anywhere but nothing happens. The slide does not advance.
I've created a few quizzes before in Cap 7 using the same settings so I was stumped when the quiz didn't work this time. Maybe I accidentally changed a setting??The jump to slide works great. Yes, the user goes right back to the quiz after remediation. The user can then change her answer and click submit. However, she can not advance forward. Sigh.
I am a freelancer who inherited the template from the former freelancer. I was told to use her template to create the trainings. So I am. I was supposed to use all the settings she used, too. That's why the Required is set to: User must answer every question'
I can try your idea and the Requirements in the settings.
What's odd, though, is that I've developed a Quiz using these same exact settings and it worked perfectly. That's why it's odd that the Quiz is no longer working correctly.
Okay, let me try to change the Required settings.
By the way, the submit button works fine in the Preview mode, just not the Web Browser mode. -
After entering "Country or Region" United States, I do not get a next button to advance through the process. What might be the cause?
Try This...
Close All Open Apps... Sign Out of your Account... Perform a Reset... Try again...
Reset ( No Data will be Lost )
Press and hold the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Release the Buttons.
http://support.apple.com/kb/ht1430 -
My ipod nano 7th gen. will not advance to the next song, it will keep playing the current song until manually changed. All updates are current.
I had this issue with my 6th generation nano. It was driving me nuts, until I realized that somehow locked the repeat button on. Selecting one song rather than a selection will cause whatever song you have selected to play over and over and over and over..
Maybe you are looking for
-
Printing to printer on windows xp computer, only prints first page
hey all, I need some help. i just switched to a mac and I am loving it, but in my small office, I am having trouble printing. Two printers are connected to a Windows XP computer. I can connect to them via the network and print, but it only prints the
-
When Trying to install the newest Flash player, Im asked to fill in my login. I have no clue what my login is. (It happened very rarely that I was asked to fill in this when installing a new program, and the login I have used before are not valid now
-
How to play my itunes library on my pc or external hard drive?
How can I import and play my ITunes library on my pc and external storage device?
-
Cisco Works - Campus Data Collection
Cisco Works - Common Services 3.0.3, Campus Manager 4.0.3, RME 4.0.3 I have devices that are "discovered" via Device Discovery, but do not show up in Campus Data Collection. The devices that do not show up, are "reachable" in Device Discovery. I thou
-
HI All, I want to roll up values @ Acct name level. If the account name is same for two different accounts then I want two entries for the same account name as mentioned in third table below. This indicated us that this is an data issue. CAn it be ac