Loadrunner?????????????
???????????? ???????[ 2013/5/15 11:47:54 ] ????????
????Loadrunner??????????????????SQL??????????????
??????????Loadrunner 8 ???C API?????Vuser ????MySQL????????????sql????????????
?????????????????????????????????????B/S????
view plaincopy to clipboardprint?
/*???????????
CREATE TABLE `test_data` (
`order_id` BIGINT UNSIGNED NOT NULL COMMENT 'Order numbers. Must be unique.'??
`status` BOOL NOT NULL DEFAULT '0' COMMENT 'Whether data has been used or not. A value of 0 means FALSE.'??
`date_used` DATETIME NULL COMMENT 'Date/time that the data was used.'??
UNIQUE (
`order_id`
)
) ENGINE = innodb COMMENT = 'LoadRunner test data';
*/
Action()
{
int rc;
int db_connection; // ?????????
int query_result; // ???????? MYSQL_RES
char** result_row; // ??????????
char *server = "localhost";
char *user = "root";
char *password = "123456";
char *database = "test";
int port = 3306;
int unix_socket = NULL;
int flags = 0;
// ???libmysql.dll??????λ??.
rc = lr_load_dll("C:\Program Files\MySQL\MySQL Server 5.1\bin\libmysql.dll");
if (rc != 0) {
lr_error_message("Could not load libmysql.dll");
lr_abort();
}
// ????MySQL????
db_connection = mysql_init(NULL);
if (db_connection == NULL) {
lr_error_message("Insufficient memory");
lr_abort();
}
// ?????MySQL?????
rc = mysql_real_connect(db_connection?? server?? user?? password?? database?? port?? unix_socket?? flags);
if (rc == NULL) {
lr_error_message("%s"?? mysql_error(db_connection));
mysql_close(db_connection);
lr_abort();
}
// ??????????????
// ????? {ORDER_ID} ???????????????????????????????????
lr_save_string (lr_eval_string("INSERT INTO test_data (order_id) VALUES ({ORDER_ID})")??"paramInsertQuery");
rc = mysql_query(db_connection?? lr_eval_string("{paramInsertQuery}"));
if (rc != 0) {
lr_error_message("%s"?? mysql_error(db_connection));
mysql_close(db_connection);
lr_abort();
}
// ????????????????????
rc = mysql_query(db_connection?? "SELECT order_id FROM test_data WHERE status IS FALSE LIMIT 1");
if (rc != 0) {
lr_error_message("%s"?? mysql_error(db_connection));
mysql_close(db_connection);
lr_abort();
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11