[Info-vax] Pascal & MySQL

Arne Vajhøj arne at vajhoej.dk
Fri Dec 21 14:27:27 EST 2018


I have started creating a Pascal wrapper for MySQL C API.

Just a simple conversion of data types from C'ish to
Pascal'ish.

Example:

procedure test_getone(con : mysql_ptr; f1 : integer);

var
    stmt : mysql_stmt_ptr;
    stat : integer;
    inparam : array[1..1] of mysql_bind;
    outparam : array[1..1] of mysql_bind;
    f2 : longpstr(255);

begin
    stmt := pmysql_stmt_init(con);
    checkstmt(stmt, con);
    stat := pmysql_stmt_prepare(stmt, 'SELECT f2 FROM t1 WHERE f1 = ?');
    checkstat(stat, stmt);
    pmysql_init_bind_integer(inparam[1], f1);
    stat := pmysql_stmt_bind_param(stmt, inparam);
    checkstat(stat, stmt);
    stat := pmysql_stmt_execute(stmt);
    checkstat(stat, stmt);
    pmysql_init_bind_string_out(outparam[1], f2);
    stat := pmysql_stmt_bind_result(stmt, outparam);
    checkstat(stat, stmt);
    stat := pmysql_stmt_store_result(stmt);
    checkstat(stat, stmt);
    if pmysql_stmt_fetch(stmt) = 0 then begin
       writeln(stdstr(f2));
    end;
    pmysql_stmt_free_result(stmt);
end;

If there is interest then I will try and complete
it and make it available.

Anyone want to see the code now as it is then
just drop me an email.

Arne




More information about the Info-vax mailing list