Toad World® Forums

Associating each user in a multi-user profile with its own databank


#1

I have a profile with ten users. In the SQL these run, I want each to get a value to use in the where clause from a file - each user has its own file, so user A has C:\A.txt, B has C:\B.txt, etc. I came up with this

select …
from table1
where id=$BFFileArray($BFConcat(“C:”,$BFProfile(USERNAME) ,".txt"),RANDOM)

The $BFConcat function constructs the filename from the username, and $BFFileArray gets a single value from the file to complete the condition.

But the syntax of the $BFFileArray function does not allow a function as one of its parameters, because when I test this I get

“Parameter 1 of script FileArray must not be an embedded script”

Does anyone know of a workaround for this?


#2

As you have found out BMF does not allow scripting of the filename of the BFFileArray function. We have create a enhancement request to enable this in a future release.

As a possible work around you could put all the information of the 10 user files into one file so that each users data is in a single column. So, all ids for user A would be in column 1, user B would be column 2. Then the script would be;

$BFFileArray(“C:\alluserdata.txt”, RANDOM, $BFUserID())

Now if you want to maintain the individual user data files, you could write a batch or VBScript file which would create the alluserdata.txt files by combining all the individual user data files. Then this file could be call before each test by using the ExecuteFile item. (See attached image)

I hope this helps.
ExecuteFileExample.jpeg


#3

Thank you for your suggestion. Can I just ask about the implications for the profile? If as you suggest I use

$BFFileArray(“C:\alluserdata.txt”, RANDOM, $BFUserID())

to get an id from the databank, then the profile must ensure that A is selected first (has $BFUserID() of 1), B second, and so on. In other words the user name in the profile is provided by

$BFFileArray(“C:\profile.txt”, SEQUENTIAL, 1)

where the file has “A” in column 1 of row 1, “B” in row 2, “C” in row 3, … and I can’t use

$BFFileArray(“C:\profile.txt”, RANDOM, 1)

because the first user selected ($BFUserID() = 1) could be C, for example?


#4

Well there is a problem with using;

$BFFileArray(“C:\profile.txt”, SEQUENTIAL, 1)

in the profile which has to do with the way the BFScripting engine is instantiated. Each virtual user gets it own copy of the BFScripting engine, therefore each virtual user will keep it’s own place of what row should be read from the file. Therefore using the above BFScript, each virtual user will login as “A”.

A better scripting function would be

$BFFileArray(“C:\profile.txt”, SELECTION, 1, $BFUserID())

BFUserID will always return the virtual user number, so VU 1 will return 1, VU 2 will return 2, etc. That way you ensure that VU 1 will always read the first row.

I hope this makes sense.