+ Reply to Thread
Results 1 to 6 of 6

Returning multiple recordsets from teradata database

  1. #1
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Returning multiple recordsets from teradata database

    Hi all,

    I have the below code to connect to a Teradata database and run an SQL statement to get a record set.
    It works great, but I need to get data from different tables that are not related with eachother, but still are needed.
    To get from 5 different record sets, I need to run 5 similar code like below, just the SQL will be different.

    How could I re-use the below code to include 5 instead of one SQL request for record set without clossing the connection till all 5 did run?


    Please Login or Register  to view this content.
    Greetings.

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Returning multiple recordsets from teradata database

    You could use the GoSub...Return feature. Just list your 5 thissql assignments and evoke the GoSub to a procedure name such as "ProcessSql" you should have the procedure insulated with an Exit Sub - like this:

    Please Login or Register  to view this content.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Returning multiple recordsets from teradata database

    Hi,

    I tried it out, but get error: "Compile error: label not defined" on this line: GoSub PrcessSql

    Any clue where it goes wrong?

    Greetings.

    (I'm using Excel 2003 at work and 2013 at home, maybe there could be a difference)
    Last edited by Megatronixs; 05-01-2016 at 05:52 AM.

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Returning multiple recordsets from teradata database

    It may very well be the speling - PrcessSql v ProcessSql

    It looks like it's my fault - sorry

    Please Login or Register  to view this content.
    And - thanks for the rep!

    *You'll need to bump up your LastCol and LastCol2 before the return!
    Last edited by xladept; 05-01-2016 at 01:05 PM.

  5. #5
    Forum Contributor
    Join Date
    08-02-2012
    Location
    Austria
    MS-Off Ver
    Excel 2007
    Posts
    457

    Re: Returning multiple recordsets from teradata database

    Hi,

    Thanks a lot :-)
    I did not see it myself either, so, maybe it is my fault :-)

    It works really great and I don't have to run separate macros to get the same done and then open the connections for each one and then close again.

    Actually, my next step will be to tray to put the recordset inside a word document :-)

    Greetings.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Returning multiple recordsets from teradata database

    Hi Megatronixs,

    I'm glad to hear that it works (that was sloppy work by me). Lot's of luck with WORD

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 12-05-2014, 03:47 PM
  2. Embedded Query - Teradata Database ODBC - Create Table
    By Jennasis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-10-2013, 08:55 AM
  3. Passing a Date via a variable from Excel VBA to Teradata
    By teb1212 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-24-2013, 05:45 PM
  4. ADODB Recordsets
    By cosmarchy in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-24-2010, 04:53 PM
  5. Speed up VBA recordsets
    By Slyone2 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-04-2010, 09:28 PM
  6. Excel Recordsets
    By Kix_N_Grins in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-02-2007, 04:42 AM
  7. [SOLVED] Excel connecting to Teradata
    By Bill in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-31-2005, 04:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1