| || |
I am trying to use a DB to drive a set of load tests and am having issues getting it to work. I have tried both an MS Access and a MYSQL Database and each one halts at a different point during the script. The database consists of 5 columns each of type Text. What I am attempting to do is use a record from the DB as input for a search function in the AUT.
My approach is such : Query the DB in while loop that tests for the value of column 5. If Column 5 = 'X' then query again until Column 5 = 'Y'. Once true, store the record in variables for form submission, then lock the current DB record and update Column 5 to = 'X'. I am doing this to prevent other VUsers from processing data on the same record.
When I use a MYSQL Data source, I am able to query and get a valid record set, however an error occurs when I attempt to lock the record for updating. The error messages vary from Invalid Cursor State to Optional feature not implemented. This changes according to the parameters I pass to the OdbcSetPos function in the nOperation and nLockType positions. The Performer help file doesn't indicate what these various parameters accomplish so I am just guessing I have the correct values...
When I use an MS Acess data source, I am unable to even query for a valid record. When I attempt to either prepare/execute or execdirect, I get this error message :
Too few parameters. Expected 1
I know the query is valid, it works in the Access SQL editor. I am at a loss as to what's wrong.
Here's the block of code that I am trying to execute :
</font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">
OdbcAlloc(SQL_HANDLE_DBC, hOutDB, hEnv);
hWebStoredCtx_Time_Period_Selection : number;
iRow : number;
sUpdated : string;
//Start at row zero
iRow := 0;
// Redirecting -> http://apptest2/ms/
WebPageUrl("http://apptest2/ms", "ConneXion - Home"
WebPageLink("login", "ACS Login" // Link 1
WebPageSubmit("loginForm", LOGINFORM, "ConneXion - Home (#1)" // Form 1
//Prep the bits we need for DB access
//Define the placeholders for the data coming from the DB
OdbcDefine(cDBCursor, "1", SQL_C_CHAR, 32);
OdbcDefine(cDBCursor, "2", SQL_C_CHAR, 32);
OdbcDefine(cDBCursor, "3", SQL_C_CHAR, 32);
OdbcDefine(cDBCursor, "4", SQL_C_CHAR, 32);
OdbcDefine(cDBCursor, "5", SQL_C_CHAR, 32);
While sUpdated <> "TRUE" do
//Get the applicant to search for from the DB
sFirstName := OdbcGetString(cDBCursor, "1"
sLastName := OdbcGetString(cDBCursor, "2"
sMedicaidID := OdbcGetString(cDBCursor, "3"
sUpdated := OdbcGetString(cDBCursor, "5"
//Increment the row counter so we can tell where we need to set the cursor for the update
iRow := iRow + 1;
if sUpdated = "FALSE" then
OdbcSetPos(cDBCursor, iRow, SQL_UPDATE, SQL_LOCK_EXCLUSIVE);
OdbcSetString(cDBCursor, ":1", sFirstName, 1);
OdbcSetPos(cDBCursor, iRow, SQL_POSITION, SQL_LOCK_UNLOCK);
sUpdated := "FALSE";
SELECT * FROM Applicant WHERE Updated <> "TRUE";
UPDATE Applicant set Updated = "TRUE" where FirstName = ?;</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">Any idea what's wrong?
Re: ODBC Woes...
Put the parm of your update into ' '.
Hope this helps
Re: ODBC Woes...
If you are using SP6 make sure that you have the latest service pack. There were some similar ODBC problems in the initial release of SP6 that have been fixed in the latest build.
Re: ODBC Woes...
Thanks for the replies. I was able to solve the issues I had. However, now I am having other issues with the ODBCSetPos function.
I absolutely need a way to prevent vusers from pulling the same record from the source db. I am attempting to do this using record locking of the current record, which I assume prevents any access by other vusers. While the record is locked, the conditional field is updated so it will be ignored by other vusers.
What ends up happening is that they end up pulling the same record from the DB, which causes them to load the same individual in the AUT and attempt to conduct processing on that individual. The concurrency measures in the AUT then cause page not found errors because the AUT will not allow the same individual to be processed by two different users at the same time.
Summary of steps :
1. Query DB for a 'non-processed' record. Record contains first name, last name, Id, and a 'Processed' column.
2. Lock the record to prevent other vusers from pulling/updating the record.
2. Update the 'processed' value, indicating this record is done.
4. Unlock the record.
5. Conduct AUT processig on the record returned in step 1.
6. Repeat until done.
The record will now be ignored since it meets the 'already been processed' condition.
I am having issues locking the record, getting a function sequence error when I attempt to set the db cursor to the row that needs updating.
If I don't explicitly lock the record, it gets pulled by two different vusers and errors occur.
I am not sure what to do at this point. Is there any reference script that accomplishes this?
Re: ODBC Woes...
Have you tried SP synchronization like GlobalResourceEnter instead of locking the db ?