demotypesafeaccess.pp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. program testpp;
  2. {$mode objfpc}
  3. {$H+}
  4. uses sysutils, sqldb, ibconnection, tsamytable;
  5. Procedure DoTest;
  6. Var
  7. C : TIBConnection;
  8. T : TSQLTransaction;
  9. A : IMyTypeSafeAccess;
  10. begin
  11. C:=TIBConnection.Create(Nil);
  12. try
  13. C.HostName:='localhost';
  14. C.DatabaseName:='/home/firebird/testdb.fdb';
  15. C.UserName:='WISASOFT';
  16. C.Password:='SysteemD';
  17. T:=TSQLTransaction.Create(C);
  18. C.Transaction:=T;
  19. T.Database:=C;
  20. A:=TMyTypeSafeAccess.GetQuery(C,T);
  21. A.Open;
  22. A.Append;
  23. A.MyBoolean:=True;
  24. A.MyInteger:=StrToIntDef(Paramstr(1),1);
  25. A.MyWideString:='a';
  26. A.MyUnicodeString:='B';
  27. A.MyByteInteger:=123;
  28. A.MyInt64:=4564654;
  29. A.MyQWordLargeInt:=6566564564;
  30. A.MySmallintInteger:=2345;
  31. A.MyShortIntInteger:=5;
  32. A.MyCardinalInteger:=6;
  33. A.MybLob.Write(C.DatabaseName[1],Length(C.DatabaseName));
  34. A.MyFixedChar:='fa';
  35. A.MyFixedWideString:='fu';
  36. A.Post;
  37. A.ApplyUpdates;
  38. T.Commit;
  39. finally
  40. // A.Free;
  41. C.Free;
  42. end;
  43. end;
  44. begin
  45. Try
  46. DoTest;
  47. except
  48. On E : Exception do
  49. writeln('Exception ',E.ClassName,' with message : ',E.Message);
  50. end;
  51. end.