+ Reply to Thread
Results 1 to 2 of 2

Macro for running the SQL multiple times

  1. #1
    Registered User
    Join Date
    01-26-2013
    Location
    chennai
    MS-Off Ver
    Excel 2007
    Posts
    20

    Macro for running the SQL multiple times

    Currently the SQL will pick the value which is present in "Sheet2.Range("C2")" and execute the SQL and store the output into Selection.Offset(1, 1) = sourceRst.Fields("DT_KEY") .
    My requirement is i will be having values in Sheet2.C3, C4, C5,and goes on. So, the SQL should pick the value 1 by 1 and execute it and populate the data into the corresponding DB Output field.

    Kindly provide me the code which will make the SQL run 1 by 1 till it finds a NULL value in the Sheet2.C field.

    I am attaching the Sheet below, kindly look into Sheet2.B column and Sheet2.C column.
    Sheet2.C is the date which is passed into the SQL and Sheet2.B is the output from Database.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    09-21-2011
    Location
    Birmingham UK
    MS-Off Ver
    Excel 2003/7/10
    Posts
    2,188

    Re: Macro for running the SQL multiple times

    I would change your Ora_Connection to have an argument for dtDate, and then use this argument in the SQL query.

    I would then loop through a range,

    so

    Please Login or Register  to view this content.
    Something like that. I would also look at keeping the connection open, so have another sub say, Open_DB and Close_DB, so before this Open_DB and at the end Close_DB, saves the opening each time.

    Hope this helps

    Nathan.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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