Free Pascal이나 Lazarus에 기본으로 있는 sqlite 관련 컴포넌트를 리눅스 환경에서 사용할 경우 Close나 Free를 호출할 경우 알 수 없는 에러가 발생하더군요. 그래서 sqlite 라이브러리를 직접 호출하는 방법을 사용했습니다. 아래는 소스 코드입니다.
uses sqlite3;
procedure TAlertD.InsertMessageToDB(email, contents, ip: string); var rc: longint; db: Psqlite3; query: string; stmt: Psqlite3_stmt; idx0, idx1, idx2, idx3: Integer; begin rc := sqlite3_open(PChar(ExpandFileName(ChangeFileExt(ParamStr(0), '.db3'))), @db); if (rc <> SQLITE_OK) then begin WriteLn('Can''t open database'); sqlite3_close(db); Exit; end;
rc := sqlite3_exec(db, 'BEGIN', nil, nil, nil); if rc <> SQLITE_OK then begin WriteLn('Can''t begin Transaction: ', sqlite3_errmsg(db)); sqlite3_close(db); Exit; end;