[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 211
  • Last Modified:

shadow an array

I would like to shadow an array using transcode

for each array listed below the trans code will be different, therefore when the values are inserted I need the transcode to be unique to the array value.  How would I write this procedure


Dim Amount(3)
 
   amount(0) = "<<chargeamount1>>"
   amount(1) = "<<chargeamount2>>"
   amount(2) = "<<chargeamount3>>"
   amount(3)= "<<chargeamount3>>"                
         
For Each x In amount
             
                  sql = "insert into " & table & " ( TRANS_CODE, ACCOUNT, AMOUNT, PRIN) & _
        "values ('" & TransCode & ",'" & Account & "'," & x & ",'"   & Prin & "') "
                 
                         Call WriteLog("sql = " & sql)
     
                                      Call WriteLog("sql = " & sql)
     
          Next 'x
Tags:
0
codefnder
Asked:
codefnder
  • 2
1 Solution
 
WikkardCommented:
Im not sure if this is what you mean, but instead of using a for each loop try using this:
for loopCnt = 0 to 3      
'do you sql here
next

This way the loopCnt will be unique for each sql statement.

If this isnt what you mean could you clarify what is stored in the array ? do you want to put a value from the array into the sql ? or do you just need the trancode value to be unique (in which case use the loopCnt  variable as shown above)

0
 
codefnderAuthor Commented:
Hi,

The code above works as expected.  dollar amounts are stored in the array.  

'here is the insert statement. Currently the transcode is hardcoded in the script but I need it to be unique to the array. for example  chargeamount1  transcode is " 25", Chargeamount2 transcode  is "30"
so I think I would need a second array
Dim Amount(3)
   amount(0) = "<<chargeamount1>>"
   amount(1) = "<<chargeamount2>>"
   amount(2) = "<<chargeamount3>>"
   amount(3)= "<<chargeamount3>>"                
         
For Each x In amount


 sql = "insert into " & table & " ( TRANS_CODE, ACCOUNT, AMOUNT, PRIN) & _
        "values ('" & TransCode & ",'" & Account & "'," & x & ",'"   & Prin & "') "
                 
                         Call WriteLog("sql = " & sql)
     
                                      Call WriteLog("sql = " & sql)


0
 
WikkardCommented:
Hi I think you need a more complex data structure to store this info, or some way to calculate the TransCode.

Try putting an array within your ammount array.

ie.
dim currRecord(3) '4 fields
currRecord(0) = "$1.00"
currRecord(1) = "Product 1"
currRecord(2) = "Product Description"
currRecord(3) = "123" 'id

dim Records(4) '5 records each holding the 4 fields defined above.
Records(0) = currRecord
etc.

This way you can access the data you need by indexing the fields within the Records array.
ie.
strPrice = Records(0)(0)
strProductName = Records(0)(1)
strProductDesc = Records(0)(2)
etc etc.
'
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now