EzDevInfo.com

cursor interview questions

Top cursor frequently asked interview questions

Why is it considered bad practice to use cursors in SQL Server?

I knew of some performance reasons back in the SQL 7 days, but do the same issues still exist in SQL Server 2005? If I have a resultset in a stored procedure that I want to act upon individually, are cursors still a bad choice? If so, why?


Source: (StackOverflow)

How to get the focused element with jQuery?

Using jQuery, how can I get the input element that has the caret's (cursor's) focus?

Or in other words, how to determine if an input has the caret's focus?


Source: (StackOverflow)

Advertisements

Eclipse cursor changes to crosshair

I was working in Eclipse Java EE IDE. While using it, mouse cursor changes to cross-hair. Now its displaying as cross-hair in editors. Where to change it?


Source: (StackOverflow)

chrome sets cursor to text while dragging, why?

My application has many drag and drop features. While dragging I want the cursor to change to some grab cursor. Internet Explorer and Firefox work fine for this, but Chrome always changes the cursor to the text cursor.


Source: (StackOverflow)

What's the best way to iterate an Android Cursor?

I frequently see code which involves iterating over the result of a database query, doing something with each row, and then moving on to the next row. Typical examples are as follows.

Cursor cursor = db.rawQuery(...);
cursor.moveToFirst();
while (cursor.isAfterLast() == false) 
{
    ...
    cursor.moveToNext();
}
Cursor cursor = db.rawQuery(...);
for (boolean hasItem = cursor.moveToFirst(); 
     hasItem; 
     hasItem = cursor.moveToNext()) {
    ...
}
Cursor cursor = db.rawQuery(...);
if (cursor.moveToFirst()) {
    do {
        ...                 
    } while (cursor.moveToNext());
}

These all seem excessively long-winded to me, each with multiple calls to Cursor methods. Surely there must be a neater way?


Source: (StackOverflow)

Caret position in textarea, in characters from the start

How do you get the caret position in text area using JavaScript?

For example:
This is| a text

This should return 7.

How would you get it to return the strings surrounding the cursor/selection? eg:

'This is', '', ' a text'
If the word "is" is highlighted, then it would return 'This ', 'is', ' a text'


Source: (StackOverflow)

How can I make the cursor turn to the wait cursor?

I have a C# application that has users login to it, and because the hashing algorithm is expensive, it takes a little while to do. How can I display the Wait/Busy Cursor (usually the hourglass) to the user to let them know the program is doing something?

The project is in C#.


Source: (StackOverflow)

Why do people hate SQL cursors so much? [closed]

I can understand wanting to avoid having to use a cursor due to the overhead and inconvenience, but it looks like there's some serious cursor-phobia-mania going on where people are going to great lengths to avoid having to use one.

For example, one question asked how to do something obviously trivial with a cursor and the accepted answer proposed using a common table expression (CTE) recursive query with a recursive custom function, even though this limits the number of rows that could be processed to 32 (due to recursive function call limit in sql server). This strikes me as a terrible solution for system longevity, not to mention a tremendous effort just to avoid using a simple cursor.

What is the reason for this level of insane hatred? Has some 'noted authority' issued a fatwa against cursors? Does some unspeakable evil lurk in the heart of cursors that corrupts the morals of children or something?

Wiki question, more interested in the answer than the rep.

Related Info:

SQL Server Fast Forward Cursors

EDIT: let me be more precise: I understand that cursors should not be used instead of normal relational operations; that is a no-brainer. What I don't understand is people going waaaaay out of their way to avoid cursors like they have cooties or something, even when a cursor is a simpler and/or more efficient solution. It's the irrational hatred that baffles me, not the obvious technical efficiencies.


Source: (StackOverflow)

Usage CursorLoader without ContentProvider

Android SDK documentation says that startManagingCursor() method is depracated:

This method is deprecated. Use the new CursorLoader class with LoaderManager instead; this is also available on older platforms through the Android compatibility package. This method allows the activity to take care of managing the given Cursor's lifecycle for you based on the activity's lifecycle. That is, when the activity is stopped it will automatically call deactivate() on the given Cursor, and when it is later restarted it will call requery() for you. When the activity is destroyed, all managed Cursors will be closed automatically. If you are targeting HONEYCOMB or later, consider instead using LoaderManager instead, available via getLoaderManager()

So I would like to use CursorLoader. But how can I use it with custom CursorAdapter and without ContentProvider, when I needs URI in constructor of CursorLoader?


Source: (StackOverflow)

Change UITextField and UITextView Cursor / Caret Color

I'm wondering about changing the color of the cursor / caret in a UITextField (And UITextView if its the same answer) in iOS. I've seen answers for OSX development, but nothing for iOS.

Is this even possible?


Source: (StackOverflow)

SQL Call Stored Procedure for each Row without using a cursor

How can one call a stored procedure for each row in a table, where the columns of a row are input parameters to the sp without using a Cursor?


Source: (StackOverflow)

How can I increase the cursor speed in terminal? [closed]

How can I increase the cursor speed in terminal? I have Mac OS X by the way. It would also be interesting to know it for Linux.

I don't know what I should search for in Google (or what you like).


Source: (StackOverflow)

how to set cursor style to pointer for links without hrefs

I have a lot of <a> html tags without the href attribute for making onclick javascript calls. These links do not have a pointer style of cursor. They have text style cursor.

How can I set the cursor style to pointer for links without using the href attribute?

I know I can add rel='nofollow' href="#". I have this in a lot of places in the html document, and would like to know how to make cursor style pointer for links without using the href attribute.


Source: (StackOverflow)

How to get a word under cursor using JavaScript?

If I for example have

<p> some long text </p>

on my HTML page, how can I know that cursor of mouse is for example above the word 'text'?


Source: (StackOverflow)

jQuery - Follow the cursor with a DIV

How can I use jQuery to follow the cursor with a DIV?


Source: (StackOverflow)