Skip to content
Advertisement

How can I resolve “The cursor was not declared” from SQL Server

I am connecting to SQL Server via Spring in WebSphere. I have a piece of pretty simple dynamic SQL (below) that is throwing “The cursor was not declared.”

SELECT TOP 1
    short_desc shortDescription
FROM
    product.prs.PRODUCT_SKN (nolock)
WHERE
    prod_sales_div_code = 'XXX'
    AND product_nbr = ?

One of the settings for the data source that seems relevant is the “select mode” is “cursor”. I’m not really sure what I need to do to resolve the error.

edit The calling code is: findShortDescriptionQuery.get().findObjectByNamedParam(of("productNumber", productId))

Advertisement

Answer

I removed the “nolock” directive altogether, along with the “TOP 1”, and the problem went away. This makes me suspect it is related to the JDBC driver.

This workaround is less than ideal, but will work just fine for my purpose.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement