SQL Server Performance

FOR BROWSE

Discussion in 'SQL Server 2005 General Developer Questions' started by geofrey, Aug 4, 2006.

  1. geofrey New Member

    Hi

    I got the following error message (only sql 2005) when I make the query: Select maximo from cont_moviment_bancaria FOR BROWSE

    Microsoft SQL Server:16907[Microsoft][ODBC SQL Server Driver][SQL
    Server]'FOR BROWSE' is not allowed in cursor statements.Microsoft SQL
    Server:8180[Microsoft][ODBC SQL Server Driver][SQL Serve

    What am I suppose to do?
    Can someone help Me?


    Thanks
  2. satya Moderator

    quote: select_statement is a standard SELECT statement that defines the result set of the cursor. The keywords COMPUTE, COMPUTE BY, FOR BROWSE, and INTO are not allowed within a select_statement of a cursor declaration. SQL Server implicitly converts the cursor to another type if clauses in select_statement conflict with the functionality of the requested cursor type. For more information, see Implicit Cursor Conversions.

    Satya SKJ
    Microsoft SQL Server MVP
    Contributing Editor & Forums Moderator
    http://www.SQL-Server-Performance.Com
    This posting is provided AS IS with no rights for the sake of knowledge sharing.
  3. FrankKalis Moderator

    If this is your whole statement, just leave out the FOR BROWSE. If it isn't the complete statement, please post it here, so it will become clearer.

    --
    Frank Kalis
    Moderator
    Microsoft SQL Server MVP
    Webmaster:http://www.insidesql.de
  4. geofrey New Member

    hi,

    It can be used for the concurrence control

    I found this in the sql help:
    "Cursors declared with FOR BROWSE must wait for uncommitted changes (made by anyone, including the cursor owner) only during the OPEN CURSOR operation. After the cursor is open, subsequent changes do not cause the cursor to wait. When a cursor is reopened, it can be blocked by uncommitted changes."

    complete statement:

    my function fPegaContador():

    Select maximo from sTabela FOR BROWSE

    Select maximo from sTabela into :nMax

    If nMax = NUMBER_Null
    Set sSql = Insert into sTabela (maximo) values (1)

    Else
    Set sSql = Update sTabela set maximo = maximo + 1

    FOR BROWSE ensure that the same code will not be introduced if 2 or more users try to insert data at the same time

    I'm wrong?

    thank's.

  5. Adriaan New Member

    If you check the DECLARE CURSOR syntax, you will notice that the SELECT statement for the cursor cannot include FOR BROWSE. But of course the script you posted doesn't declare a cursor ...

    Not sure about your syntax here:
    Select maximo from sTabela into :nMax
    Is this SQL 2005-specific?
  6. geofrey New Member

    so, if I don't declare a cursor why I receive the error message: 'FOR BROWSE' is not allowed in cursor statements?

    And "Select maximo from sTabela" is a common query, no specific.
    maximo is a column. sTabela is a variable.

    but the error message is specific from sql 2005, in the sql 2000 is working!
  7. Adriaan New Member

    I was wondering about the "INTO :nMax" bit, which is not quite T-SQL as I know it.
  8. geofrey New Member

    I'm sorry, this syntax belong to programming language Centura or SqlWindow
  9. Adriaan New Member

    Apparently the library that your program is using to connect to the SQL Server backend changes your SELECT statement into a cursor operation. If you put a trace on SQL Server, you can catch the actual statements issued by the library against SQL Server.

    Not sure I've heard Centura or SqlWindow mentioned on this forum before, so you might get better suggestions on forums for Centura or SqlWindow.

    [edit:]It could also be that SQL Server decides by itself that it has to use a cursor, because of the statement issued by the library.
  10. geofrey New Member

    Ok.
    thanks everybody for helping me.

Share This Page