mysqlconn.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673
  1. {$mode objfpc}{$H+}
  2. {$MACRO on}
  3. interface
  4. uses
  5. Classes, SysUtils,sqldb,db,
  6. {$IfDef mysql50}
  7. mysql50dyn;
  8. {$DEFINE TConnectionName:=TMySQL50Connection}
  9. {$DEFINE TTransactionName:=TMySQL50Transaction}
  10. {$DEFINE TCursorName:=TMySQL50Cursor}
  11. {$ELSE}
  12. {$IfDef mysql41}
  13. mysql41dyn;
  14. {$DEFINE TConnectionName:=TMySQL41Connection}
  15. {$DEFINE TTransactionName:=TMySQL41Transaction}
  16. {$DEFINE TCursorName:=TMySQL41Cursor}
  17. {$ELSE}
  18. {$IFDEF mysql4} // temporary backwards compatibility for Lazarus
  19. mysql40dyn;
  20. {$DEFINE TConnectionName:=TMySQLConnection}
  21. {$DEFINE TTransactionName:=TMySQLTransaction}
  22. {$DEFINE TCursorName:=TMySQLCursor}
  23. {$ELSE}
  24. mysql40dyn;
  25. {$DEFINE TConnectionName:=TMySQL40Connection}
  26. {$DEFINE TTransactionName:=TMySQL40Transaction}
  27. {$DEFINE TCursorName:=TMySQL40Cursor}
  28. {$EndIf}
  29. {$EndIf}
  30. {$EndIf}
  31. Type
  32. TTransactionName = Class(TSQLHandle)
  33. protected
  34. end;
  35. TCursorName = Class(TSQLCursor)
  36. protected
  37. FQMySQL : PMySQL;
  38. FRes: PMYSQL_RES; { Record pointer }
  39. FNeedData : Boolean;
  40. FStatement : String;
  41. Row : MYSQL_ROW;
  42. RowsAffected : QWord;
  43. LastInsertID : QWord;
  44. end;
  45. TConnectionName = class (TSQLConnection)
  46. private
  47. FDialect: integer;
  48. FHostInfo: String;
  49. FServerInfo: String;
  50. FMySQL : PMySQL;
  51. function GetClientInfo: string;
  52. function GetServerStatus: String;
  53. procedure ConnectMySQL(var HMySQL : PMySQL;H,U,P : pchar);
  54. protected
  55. function StrToStatementType(s : string) : TStatementType; override;
  56. Procedure ConnectToServer; virtual;
  57. Procedure SelectDatabase; virtual;
  58. function MySQLDataType(AType: enum_field_types; ASize: Integer; var NewType: TFieldType; var NewSize: Integer): Boolean;
  59. function MySQLWriteData(AType: enum_field_types; ASize: Integer; Source, Dest: PChar): Integer;
  60. // SQLConnection methods
  61. procedure DoInternalConnect; override;
  62. procedure DoInternalDisconnect; override;
  63. function GetHandle : pointer; override;
  64. Function AllocateCursorHandle : TSQLCursor; override;
  65. Procedure DeAllocateCursorHandle(var cursor : TSQLCursor); override;
  66. Function AllocateTransactionHandle : TSQLHandle; override;
  67. procedure PrepareStatement(cursor: TSQLCursor;ATransaction : TSQLTransaction;buf : string; AParams : TParams); override;
  68. procedure UnPrepareStatement(cursor:TSQLCursor); override;
  69. procedure FreeFldBuffers(cursor : TSQLCursor); override;
  70. procedure Execute(cursor: TSQLCursor;atransaction:tSQLtransaction;AParams : TParams); override;
  71. procedure AddFieldDefs(cursor: TSQLCursor; FieldDefs : TfieldDefs); override;
  72. function Fetch(cursor : TSQLCursor) : boolean; override;
  73. function LoadField(cursor : TSQLCursor;FieldDef : TfieldDef;buffer : pointer) : boolean; override;
  74. function GetTransactionHandle(trans : TSQLHandle): pointer; override;
  75. function Commit(trans : TSQLHandle) : boolean; override;
  76. function RollBack(trans : TSQLHandle) : boolean; override;
  77. function StartdbTransaction(trans : TSQLHandle; AParams : string) : boolean; override;
  78. procedure CommitRetaining(trans : TSQLHandle); override;
  79. procedure RollBackRetaining(trans : TSQLHandle); override;
  80. procedure UpdateIndexDefs(var IndexDefs : TIndexDefs;TableName : string); override;
  81. Public
  82. Property ServerInfo : String Read FServerInfo;
  83. Property HostInfo : String Read FHostInfo;
  84. property ClientInfo: string read GetClientInfo;
  85. property ServerStatus : String read GetServerStatus;
  86. published
  87. property Dialect : integer read FDialect write FDialect;
  88. property DatabaseName;
  89. property HostName;
  90. property KeepConnection;
  91. property LoginPrompt;
  92. property Params;
  93. property OnLogin;
  94. end;
  95. EMySQLError = Class(Exception);
  96. implementation
  97. uses dbconst;
  98. { TConnectionName }
  99. Resourcestring
  100. SErrServerConnectFailed = 'Server connect failed.';
  101. SErrDatabaseSelectFailed = 'failed to select database: %s';
  102. SErrDatabaseCreate = 'Failed to create database: %s';
  103. SErrDatabaseDrop = 'Failed to drop database: %s';
  104. SErrNoData = 'No data for record';
  105. SErrExecuting = 'Error executing query: %s';
  106. SErrFetchingdata = 'Error fetching row data: %s';
  107. SErrGettingResult = 'Error getting result set: %s';
  108. SErrNoQueryResult = 'No result from query.';
  109. SErrNotversion50 = 'TMySQL50Connection can not work with the installed MySQL client version (%s).';
  110. SErrNotversion41 = 'TMySQL41Connection can not work with the installed MySQL client version (%s).';
  111. SErrNotversion40 = 'TMySQL40Connection can not work with the installed MySQL client version (%s).';
  112. Procedure MySQlError(R : PMySQL;Msg: String;Comp : TComponent);
  113. Var
  114. MySQLMsg : String;
  115. begin
  116. If (R<>Nil) then
  117. begin
  118. MySQLMsg:=Strpas(mysql_error(R));
  119. DatabaseErrorFmt(Msg,[MySQLMsg],Comp);
  120. end
  121. else
  122. DatabaseError(Msg,Comp);
  123. end;
  124. function TConnectionName.StrToStatementType(s : string) : TStatementType;
  125. begin
  126. S:=Lowercase(s);
  127. if s = 'show' then exit(stSelect);
  128. result := inherited StrToStatementType(s);
  129. end;
  130. function TConnectionName.GetClientInfo: string;
  131. begin
  132. // To make it possible to call this if there's no connection yet
  133. InitialiseMysql;
  134. Result:=strpas(mysql_get_client_info());
  135. ReleaseMysql;
  136. end;
  137. function TConnectionName.GetServerStatus: String;
  138. begin
  139. CheckConnected;
  140. Result := mysql_stat(FMYSQL);
  141. end;
  142. procedure TConnectionName.ConnectMySQL(var HMySQL : PMySQL;H,U,P : pchar);
  143. begin
  144. HMySQL := mysql_init(HMySQL);
  145. HMySQL:=mysql_real_connect(HMySQL,PChar(H),PChar(U),Pchar(P),Nil,0,Nil,0);
  146. If (HMySQL=Nil) then
  147. MySQlError(Nil,SErrServerConnectFailed,Self);
  148. end;
  149. procedure TConnectionName.ConnectToServer;
  150. Var
  151. H,U,P : String;
  152. begin
  153. H:=HostName;
  154. U:=UserName;
  155. P:=Password;
  156. ConnectMySQL(FMySQL,pchar(H),pchar(U),pchar(P));
  157. FServerInfo := strpas(mysql_get_server_info(FMYSQL));
  158. FHostInfo := strpas(mysql_get_host_info(FMYSQL));
  159. end;
  160. procedure TConnectionName.SelectDatabase;
  161. begin
  162. if mysql_select_db(FMySQL,pchar(DatabaseName))<>0 then
  163. MySQLError(FMySQL,SErrDatabaseSelectFailed,Self);
  164. end;
  165. procedure TConnectionName.DoInternalConnect;
  166. begin
  167. InitialiseMysql;
  168. {$IFDEF mysql50}
  169. if copy(strpas(mysql_get_client_info()),1,3)<>'5.0' then
  170. Raise EInOutError.CreateFmt(SErrNotversion50,[strpas(mysql_get_client_info())]);
  171. {$ELSE}
  172. {$IFDEF mysql41}
  173. if copy(strpas(mysql_get_client_info()),1,3)<>'4.1' then
  174. Raise EInOutError.CreateFmt(SErrNotversion41,[strpas(mysql_get_client_info())]);
  175. {$ELSE}
  176. if copy(strpas(mysql_get_client_info()),1,3)<>'4.0' then
  177. Raise EInOutError.CreateFmt(SErrNotversion40,[strpas(mysql_get_client_info())]);
  178. {$ENDIF}
  179. {$ENDIF}
  180. inherited DoInternalConnect;
  181. ConnectToServer;
  182. SelectDatabase;
  183. end;
  184. procedure TConnectionName.DoInternalDisconnect;
  185. begin
  186. inherited DoInternalDisconnect;
  187. mysql_close(FMySQL);
  188. FMySQL:=Nil;
  189. ReleaseMysql;
  190. end;
  191. function TConnectionName.GetHandle: pointer;
  192. begin
  193. Result:=FMySQL;
  194. end;
  195. function TConnectionName.AllocateCursorHandle: TSQLCursor;
  196. begin
  197. Result:=TCursorName.Create;
  198. end;
  199. Procedure TConnectionName.DeAllocateCursorHandle(var cursor : TSQLCursor);
  200. begin
  201. FreeAndNil(cursor);
  202. end;
  203. function TConnectionName.AllocateTransactionHandle: TSQLHandle;
  204. begin
  205. // Result:=TTransactionName.Create;
  206. Result := nil;
  207. end;
  208. procedure TConnectionName.PrepareStatement(cursor: TSQLCursor;
  209. ATransaction: TSQLTransaction; buf: string;AParams : TParams);
  210. begin
  211. if assigned(AParams) and (AParams.count > 0) then
  212. DatabaseError('Parameters (not) yet supported for the MySQL SqlDB connection.',self);
  213. With Cursor as TCursorName do
  214. begin
  215. FStatement:=Buf;
  216. if FStatementType=stSelect then
  217. FNeedData:=True;
  218. ConnectMySQL(FQMySQL,FMySQL^.host,FMySQL^.user,FMySQL^.passwd);
  219. if mysql_select_db(FQMySQL,pchar(DatabaseName))<>0 then
  220. MySQLError(FQMySQL,SErrDatabaseSelectFailed,Self);
  221. end
  222. end;
  223. procedure TConnectionName.UnPrepareStatement(cursor: TSQLCursor);
  224. begin
  225. With Cursor as TCursorName do
  226. begin
  227. mysql_close(FQMySQL);
  228. FQMysql := nil;
  229. end;
  230. end;
  231. procedure TConnectionName.FreeFldBuffers(cursor: TSQLCursor);
  232. Var
  233. C : TCursorName;
  234. begin
  235. C:=Cursor as TCursorName;
  236. if c.FStatementType=stSelect then
  237. c.FNeedData:=False;
  238. If (C.FRes<>Nil) then
  239. begin
  240. C.FRes:=Nil;
  241. end;
  242. if (c.FQMySQL <> Nil) then
  243. begin
  244. mysql_close(c.FQMySQL);
  245. c.FQMySQL:=Nil;
  246. end;
  247. If (C.FRes<>Nil) then
  248. begin
  249. Mysql_free_result(C.FRes);
  250. C.FRes:=Nil;
  251. end;
  252. end;
  253. procedure TConnectionName.Execute(cursor: TSQLCursor;
  254. atransaction: tSQLtransaction;AParams : TParams);
  255. Var
  256. C : TCursorName;
  257. begin
  258. C:=Cursor as TCursorName;
  259. If (C.FRes=Nil) then
  260. begin
  261. if mysql_query(c.FQMySQL,Pchar(C.FStatement))<>0 then
  262. MySQLError(c.FQMYSQL,Format(SErrExecuting,[StrPas(mysql_error(c.FQMySQL))]),Self)
  263. else
  264. begin
  265. C.RowsAffected := mysql_affected_rows(c.FQMYSQL);
  266. C.LastInsertID := mysql_insert_id(c.FQMYSQL);
  267. if C.FNeedData then
  268. C.FRes:=mysql_use_result(c.FQMySQL);
  269. end;
  270. end;
  271. end;
  272. function TConnectionName.MySQLDataType(AType: enum_field_types; ASize: Integer;
  273. var NewType: TFieldType; var NewSize: Integer): Boolean;
  274. begin
  275. Result := True;
  276. case AType of
  277. FIELD_TYPE_TINY, FIELD_TYPE_SHORT, FIELD_TYPE_LONG, FIELD_TYPE_LONGLONG,
  278. FIELD_TYPE_INT24:
  279. begin
  280. NewType := ftInteger;
  281. NewSize := 0;
  282. end;
  283. FIELD_TYPE_DECIMAL, FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE:
  284. begin
  285. NewType := ftFloat;
  286. NewSize := 0;
  287. end;
  288. FIELD_TYPE_TIMESTAMP, FIELD_TYPE_DATETIME:
  289. begin
  290. NewType := ftDateTime;
  291. NewSize := 0;
  292. end;
  293. FIELD_TYPE_DATE:
  294. begin
  295. NewType := ftDate;
  296. NewSize := 0;
  297. end;
  298. FIELD_TYPE_TIME:
  299. begin
  300. NewType := ftTime;
  301. NewSize := 0;
  302. end;
  303. FIELD_TYPE_VAR_STRING, FIELD_TYPE_STRING, FIELD_TYPE_ENUM, FIELD_TYPE_SET:
  304. begin
  305. NewType := ftString;
  306. NewSize := ASize;
  307. end;
  308. else
  309. Result := False;
  310. end;
  311. end;
  312. procedure TConnectionName.AddFieldDefs(cursor: TSQLCursor;
  313. FieldDefs: TfieldDefs);
  314. var
  315. C : TCursorName;
  316. I, FC: Integer;
  317. field: PMYSQL_FIELD;
  318. DFT: TFieldType;
  319. DFS: Integer;
  320. begin
  321. // Writeln('MySQL: Adding fielddefs');
  322. C:=(Cursor as TCursorName);
  323. If (C.FRes=Nil) then
  324. begin
  325. // Writeln('res is nil');
  326. MySQLError(c.FQMySQL,SErrNoQueryResult,Self);
  327. end;
  328. // Writeln('MySQL: have result');
  329. FC:=mysql_num_fields(C.FRes);
  330. For I:= 0 to FC-1 do
  331. begin
  332. field := mysql_fetch_field_direct(C.FRES, I);
  333. // Writeln('MySQL: creating fielddef ',I+1);
  334. if MySQLDataType(field^.ftype, field^.length, DFT, DFS) then
  335. TFieldDef.Create(FieldDefs, field^.name, DFT, DFS, False, I+1);
  336. end;
  337. // Writeln('MySQL: Finished adding fielddefs');
  338. end;
  339. function TConnectionName.Fetch(cursor: TSQLCursor): boolean;
  340. Var
  341. C : TCursorName;
  342. begin
  343. C:=Cursor as TCursorName;
  344. C.Row:=MySQL_Fetch_row(C.FRes);
  345. Result:=(C.Row<>Nil);
  346. end;
  347. function TConnectionName.LoadField(cursor : TSQLCursor;
  348. FieldDef : TfieldDef;buffer : pointer) : boolean;
  349. var
  350. I, FC, CT: Integer;
  351. field: PMYSQL_FIELD;
  352. row : MYSQL_ROW;
  353. C : TCursorName;
  354. begin
  355. // Writeln('LoadFieldsFromBuffer');
  356. C:=Cursor as TCursorName;
  357. if C.Row=nil then
  358. begin
  359. // Writeln('LoadFieldsFromBuffer: row=nil');
  360. MySQLError(c.FQMySQL,SErrFetchingData,Self);
  361. end;
  362. Row:=C.Row;
  363. FC := mysql_num_fields(C.FRES);
  364. for I := 0 to FC-1 do
  365. begin
  366. field := mysql_fetch_field_direct(C.FRES, I);
  367. if field^.name=FieldDef.name then break;
  368. Inc(Row);
  369. end;
  370. CT := MySQLWriteData(field^.ftype, field^.length, Row^, Buffer);
  371. result := true;
  372. end;
  373. function InternalStrToFloat(S: string): Extended;
  374. var
  375. I: Integer;
  376. Tmp: string;
  377. begin
  378. Tmp := '';
  379. for I := 1 to Length(S) do
  380. begin
  381. if not (S[I] in ['0'..'9', '+', '-', 'E', 'e']) then
  382. Tmp := Tmp + DecimalSeparator
  383. else
  384. Tmp := Tmp + S[I];
  385. end;
  386. Result := StrToFloat(Tmp);
  387. end;
  388. function InternalStrToDate(S: string): TDateTime;
  389. var
  390. EY, EM, ED: Word;
  391. begin
  392. EY := StrToInt(Copy(S,1,4));
  393. EM := StrToInt(Copy(S,6,2));
  394. ED := StrToInt(Copy(S,9,2));
  395. if (EY = 0) or (EM = 0) or (ED = 0) then
  396. Result:=0
  397. else
  398. Result:=EncodeDate(EY, EM, ED);
  399. end;
  400. function InternalStrToDateTime(S: string): TDateTime;
  401. var
  402. EY, EM, ED: Word;
  403. EH, EN, ES: Word;
  404. begin
  405. EY := StrToInt(Copy(S, 1, 4));
  406. EM := StrToInt(Copy(S, 6, 2));
  407. ED := StrToInt(Copy(S, 9, 2));
  408. EH := StrToInt(Copy(S, 11, 2));
  409. EN := StrToInt(Copy(S, 14, 2));
  410. ES := StrToInt(Copy(S, 17, 2));
  411. if (EY = 0) or (EM = 0) or (ED = 0) then
  412. Result := 0
  413. else
  414. Result := EncodeDate(EY, EM, ED);
  415. Result := Result + EncodeTime(EH, EN, ES, 0);
  416. end;
  417. function InternalStrToTime(S: string): TDateTime;
  418. var
  419. EH, EM, ES: Word;
  420. begin
  421. EH := StrToInt(Copy(S, 1, 2));
  422. EM := StrToInt(Copy(S, 4, 2));
  423. ES := StrToInt(Copy(S, 7, 2));
  424. Result := EncodeTime(EH, EM, ES, 0);
  425. end;
  426. function InternalStrToTimeStamp(S: string): TDateTime;
  427. var
  428. EY, EM, ED: Word;
  429. EH, EN, ES: Word;
  430. begin
  431. EY := StrToInt(Copy(S, 1, 4));
  432. EM := StrToInt(Copy(S, 5, 2));
  433. ED := StrToInt(Copy(S, 7, 2));
  434. EH := StrToInt(Copy(S, 9, 2));
  435. EN := StrToInt(Copy(S, 11, 2));
  436. ES := StrToInt(Copy(S, 13, 2));
  437. if (EY = 0) or (EM = 0) or (ED = 0) then
  438. Result := 0
  439. else
  440. Result := EncodeDate(EY, EM, ED);
  441. Result := Result + EncodeTime(EH, EN, ES, 0);;
  442. end;
  443. function TConnectionName.MySQLWriteData(AType: enum_field_types;ASize: Integer; Source, Dest: PChar): Integer;
  444. var
  445. VI: Integer;
  446. VF: Double;
  447. VD: TDateTime;
  448. Src : String;
  449. begin
  450. Result := 0;
  451. If (Source<>Nil) Then
  452. Src:=StrPas(Source)
  453. else
  454. Src:='';
  455. case AType of
  456. FIELD_TYPE_TINY, FIELD_TYPE_SHORT, FIELD_TYPE_LONG, FIELD_TYPE_LONGLONG,
  457. FIELD_TYPE_INT24:
  458. begin
  459. Result:=SizeOf(Integer);
  460. if (Src<>'') then
  461. VI := StrToInt(Src)
  462. else
  463. VI := 0;
  464. Move(VI, Dest^, Result);
  465. end;
  466. FIELD_TYPE_DECIMAL, FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE:
  467. begin
  468. Result := SizeOf(Double);
  469. if Src <> '' then
  470. VF := InternalStrToFloat(Src)
  471. else
  472. VF := 0;
  473. Move(VF, Dest^, Result);
  474. end;
  475. FIELD_TYPE_TIMESTAMP:
  476. begin
  477. Result := SizeOf(TDateTime);
  478. if Src <> '' then
  479. VD := InternalStrToTimeStamp(Src)
  480. else
  481. VD := 0;
  482. Move(VD, Dest^, Result);
  483. end;
  484. FIELD_TYPE_DATETIME:
  485. begin
  486. Result := SizeOf(TDateTime);
  487. if Src <> '' then
  488. VD := InternalStrToDateTime(Src)
  489. else
  490. VD := 0;
  491. Move(VD, Dest^, Result);
  492. end;
  493. FIELD_TYPE_DATE:
  494. begin
  495. Result := SizeOf(TDateTime);
  496. if Src <> '' then
  497. VD := InternalStrToDate(Src)
  498. else
  499. VD := 0;
  500. Move(VD, Dest^, Result);
  501. end;
  502. FIELD_TYPE_TIME:
  503. begin
  504. Result := SizeOf(TDateTime);
  505. if Src <> '' then
  506. VD := InternalStrToTime(Src)
  507. else
  508. VD := 0;
  509. Move(VD, Dest^, Result);
  510. end;
  511. FIELD_TYPE_VAR_STRING, FIELD_TYPE_STRING, FIELD_TYPE_ENUM, FIELD_TYPE_SET:
  512. begin
  513. Result := ASize;
  514. { Write('Moving string of size ',asize,' : ');
  515. P:=Source;
  516. If (P<>nil) then
  517. While P[0]<>#0 do
  518. begin
  519. Write(p[0]);
  520. inc(p);
  521. end;
  522. Writeln;
  523. } if Src<> '' then
  524. Move(Source^, Dest^, Result)
  525. else
  526. Dest^ := #0;
  527. end;
  528. end;
  529. end;
  530. procedure TConnectionName.UpdateIndexDefs(var IndexDefs : TIndexDefs;TableName : string);
  531. var qry : TSQLQuery;
  532. begin
  533. if not assigned(Transaction) then
  534. DatabaseError(SErrConnTransactionnSet);
  535. qry := tsqlquery.Create(nil);
  536. qry.transaction := Transaction;
  537. qry.database := Self;
  538. with qry do
  539. begin
  540. ReadOnly := True;
  541. sql.clear;
  542. sql.add('show index from ' + TableName);
  543. open;
  544. end;
  545. while not qry.eof do with IndexDefs.AddIndexDef do
  546. begin
  547. Name := trim(qry.fieldbyname('Key_name').asstring);
  548. Fields := trim(qry.fieldbyname('Column_name').asstring);
  549. If Name = 'PRIMARY' then options := options + [ixPrimary];
  550. If qry.fieldbyname('Non_unique').asinteger = 0 then options := options + [ixUnique];
  551. qry.next;
  552. { while (name = qry.fields[0].asstring) and (not qry.eof) do
  553. begin
  554. Fields := Fields + ';' + trim(qry.Fields[2].asstring);
  555. qry.next;
  556. end;}
  557. end;
  558. qry.close;
  559. qry.free;
  560. end;
  561. function TConnectionName.GetTransactionHandle(trans: TSQLHandle): pointer;
  562. begin
  563. Result:=Nil;
  564. end;
  565. function TConnectionName.Commit(trans: TSQLHandle): boolean;
  566. begin
  567. // Do nothing.
  568. end;
  569. function TConnectionName.RollBack(trans: TSQLHandle): boolean;
  570. begin
  571. // Do nothing
  572. end;
  573. function TConnectionName.StartdbTransaction(trans: TSQLHandle; AParams : string): boolean;
  574. begin
  575. // Do nothing
  576. end;
  577. procedure TConnectionName.CommitRetaining(trans: TSQLHandle);
  578. begin
  579. // Do nothing
  580. end;
  581. procedure TConnectionName.RollBackRetaining(trans: TSQLHandle);
  582. begin
  583. // Do nothing
  584. end;
  585. end.