Sequential read from table

  • TheSQLGuru (6/8/2016)


    tomd-982312 (6/8/2016)


    Guys, this topic is not about efficiency, or RBAR, or order by, or dbms_output.put_line().

    I'm just trying to find simple code that reads sequentially row by row from table. It's a one-time job.

    Thom A, thank you, I'll try with your suggestion.

    Regards,

    Tom

    Thom A's sample code WILL NOT PROCESS THE DATA IN ANY PARTICULAR, GUARANTEED ORDER!! His SELECT to populate the cursor does NOT have an ORDER BY clause. Without that, as I very pointedly said, there is NO ORDER GUARANTEED.

    Also, if you need a cursor to be efficient and it only goes through the data forward one record at a time you should use a FAST_FORWARD cursor.

    I will take care of exact order but that is not what is my question

    ----------------------------------------
    I miss SQL Server so much. Now I'm working on Oracle and hate it

  • Luis Cazares (6/8/2016)


    For a fast sequential read of a table to move data from one system to another, you could also use SSIS.

    You're doing ETL work, use the ETL tool.

    Don't have ETL tool.

    :angry:

    ----------------------------------------
    I miss SQL Server so much. Now I'm working on Oracle and hate it

  • tomd-982312 (6/9/2016)


    Luis Cazares (6/8/2016)


    For a fast sequential read of a table to move data from one system to another, you could also use SSIS.

    You're doing ETL work, use the ETL tool.

    Don't have ETL tool.

    :angry:

    SSIS (SQL Server Integration Services) comes with your SQL Server license ...

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • A cursor or any other "sequential row by row" construct to isn't needed to insert rows from one source table to a destination table, and it's actually the least efficient method, but it sounds like what you're specifically requesting is how to write a cursor. I've found a couple of guides that not only describe how to construct a cursor but also cover the issues of when you don't want them and how to construct a read-only forward-only cursor for performance.

    SQL Server Cursor Example

    https://www.mssqltips.com/sqlservertip/1599/sql-server-cursor-example/

    Define the Steps for SQL Server Cursor - SQL Server / TSQL Tutorial (YouTube presentation by Kevin Kline)

    https://youtu.be/C_kXO_v8N7U

    "Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho

Viewing 4 posts - 16 through 18 (of 18 total)

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