How to set a view as Read only

  • Hi,

    I have got a view in Sql Server 2000 which is a union of 2 select statements.

    EX:

    CREATE VIEW VTEST AS

    SELECT A,B FROM TABLE1

    UNION

    SELECT A,B FROM TABLE2

    When I do a query on this view VTEST, it is setting it in Update Mode.

    Could you please let me know how to set this as READ ONLY.

    Thanks & Regards,

    Shailaja

  • SHAILAJA_SOMISETTY (11/28/2008)


    When I do a query on this view VTEST, it is setting it in Update Mode.

    Please explain in more detail what this means and how you can tell it.

    That View is certainly not updateable.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • CREATE VIEW VTEST AS

    SELECT A,B FROM TABLE1

    UNION

    SELECT A,B FROM TABLE2

    This view cant do update :D, it is read only 🙂

  • CrazyMan (11/28/2008)


    CREATE VIEW VTEST AS

    SELECT A,B FROM TABLE1

    UNION

    SELECT A,B FROM TABLE2

    This view cant do update :D, it is read only 🙂

    Ummm... not if it's a partitioned view which IS fully updateable. Otherwise, I agree.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff Moden (11/28/2008)


    CrazyMan (11/28/2008)


    CREATE VIEW VTEST AS

    SELECT A,B FROM TABLE1

    UNION

    SELECT A,B FROM TABLE2

    This view cant do update :D, it is read only 🙂

    Ummm... not if it's a partitioned view which IS fully updateable. Otherwise, I agree.

    Partitoned Views have to be UNION ALL, IIRC.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • Dang... some of the things I forget... thanks Barry.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Actually - one way to make sure that the recordset is read only is to use something like DISTINCT in there (assuming that in itself doesn't alter your query in an undesirable way). Which is essentially the same reason why the original query is read only....

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

  • Hi,

    I have created a DB Link 'testsqlserver' from Oracle to Sql Server.

    I am doing a query from a view vcustomers which is the Sql Server database:

    SELECT * FROM vcustomers@testsqlserver.

    I am doing this query from TOAD.

    When I close the TOAD session, it asks me:

    ********************************************************

    ' A session that has pending transactions is about to close'

    Commit or Rollback.

    ********************************************************

    I am unable to understand why this is happening as I am just doing a select query.

    Please advise.

    Thanks & Regrads,

    Shailaja

  • This is an entirely different question and should be re-posted as a new thread, probably under "Working with Oracle".

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • OK. Will do.

    Thanks & Regards,

    Shailaja

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply