T-SQL Table variable and %ROWTYPE in Oracle

  • Is their any thing that does the same as Oracle %ROWTYPE that create the record type as the same as the table.

     

    I want to avoid this T-SQL code :

    DECLARE @myTable TABLE

    ( @field1 VARCHAR(10), @field2 VARCHAR(10), ..... )

    and have something like Oracle PL/SQL :

    DECLARE

         TYPE curtype IS REF CURSOR

              RETURN myTable%ROWTYPE

         -- Then declare a Cursor as same as curtype

    ....

     

    Any Ideas?

  • Yes, there is, kind of, but I don't know if it will work with a cursor (I avoid cursors) and it uses a temp table (no so bad if proper resources allocated to TempDB) instead of a table variable... here's an oversimplified example...

    SELECT *
      INTO #MyTemp
      FROM yourtable

    --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)

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

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