Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2015
    Posts
    1

    Unanswered: excel vba + DB2 + accelerator

    hi. i am creating a connection from excel to DB2. the code below succesfully connects to DB2 and imports data, but i can't get it to work with accelerator. so i have to put the code 'set current query acceleration = all' somewhere in there. any help please?

    Sub import_podatkov()
    'connection
    Dim sql_conn As Object
    Dim sql_data As Object
    Dim sql_header As Object
    Set sql_conn = CreateObject("ADODB.Connection")
    Set sql_data = CreateObject("ADODB.Recordset")
    sql_conn.ConnectionString = "Driver={IBM DB2 ODBC DRIVER};DBALIAS=***;Uid=***;Pwd=***;;"
    sql_conn.Open
    On errot GoTo close_connection
    With sql_data
    .ActiveConnection = sql_conn
    .Source = get_sql_stavek
    .LockType = 1
    .CursorType = 3
    .Open
    End With
    On Error GoTo close_record_set
    'import data into excel
    Worksheets("test").Activate
    [a1].Select
    For Each sql_header In sql_data.Fields
    ActiveCell.Value = sql_header.Name
    ActiveCell.Offset(0, 1).Offset.Select
    Next sql_header
    [a1].Select
    Range("a2").CopyFromRecordset sql_data
    Range("a1").CurrentRegion.EntireColumn.AutoFit
    Worksheets("test").Activate
    On Error GoTo 0
    'close connection
    close_record_set:
    sql_data.Close
    Set sql_data = Nothing
    close_connection:
    sql_conn.Close
    Set sql_conn = Nothing
    End Sub
    'sql import
    Function get_sql_stavek() As String
    Dim stevilo As String
    Dim sql_stavek As String
    sql_stavek = "select month, double(amount) slry from table_name where ip_id = 100 and month > 1300 order by month"
    get_sql_stavek = sql_stavek
    End Function


    thank you!

  2. #2
    Join Date
    May 2012
    Location
    Canberra, Australia
    Posts
    176
    Provided Answers: 6
    Are you referring to the DB2 Z/OS analytics accelerator? If so, you are in a primarily DB2 LUW forum.
    Andy

    "All parts should go together without forcing. You must remember that the parts you are reassembling were disassembled by you. Therefore, if you can’t get them together again, there must be a reason. By all means, do not use hammer.” — IBM maintenance manual, 1975 "

Posting Permissions

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