testlib

¿Has encontrado un error? ¿Tienes la solución? Deja tu correción ;-)

Antes de comentar: Gran parte de los ejercicios propuestos no tienen librerías debido a que Wordpress las eliminó al verlas como etiquetas HTML. Si sabes/tienes/conoces las librerías que hacen falta, déjalo en los comentarios. Y lo mas importante: Todos los ejemplos fueron realizados por estudiante con únicamente conocimiento básico del lenguaje, no de programación.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
{   $Id: testib.pp,v 1.7 2005/02/14 17:13:12 peter Exp $
 
    Copyright (c) 2000 by Pavel Stingl
 
    Interbase testing program 
    See the file COPYING.FPC, included in this distribution,
    for details about the copyright.
 
    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 **********************************************************************}
 program TestIB;
 
{$ifdef unix}
 {$ifndef BSD}          // BSD has libdl built in libc
  {$linklib dl} {$endif}
{$linklib crypt}
{$endif}
 
uses Interbase, SysUtils; 
var
  Database : TIBDatabase;
  Trans    : TIBTransaction;
  Query    : TIBQuery;  x        : integer;
 
begin
  Database := TIBDatabase.Create(nil);
  Trans    := TIBTransaction.Create(nil);  Query    := TIBQuery.Create(nil);
 
  Database.DatabaseName := 'test.gdb';
  Database.UserName     := 'sysdba';
  Database.Password     := 'masterkey';  Database.Transaction  := Trans;
  Trans.Action          := caRollback;
  Trans.Active          := True;
 
   Write('Opening database... Database.Connected = ');
  Database.Open;
  WriteLn(Database.Connected);
 
  // Assigning database to dataset  Query.Database := Database;
 
  Query.SQL.Add('select * from fpdev');
  Query.Open;
   WriteLn;
 
  while not Query.EOF do
  begin
    for x := 0 to Query.FieldCount - 2 do      Write(Query.Fields[x].AsString,',');
    WriteLn(Query.Fields[Query.FieldCount - 1].AsString);
    Query.Next;
  end;
   WriteLn;
 
 
  try
    WriteLn('Trying to insert new record to table fpdev');    Query.Close;
    Query.SQL.Clear;
    Query.SQL.Add('insert into fpdev values (''9'',''John Doe'',''jd@unknown.net'')');
    Query.ExecSQL;
    Trans.CommitRetaining;    WriteLn('Insert succeeded.');
  except
    on E:Exception do
    begin
      WriteLn(E.Message);      WriteLn('Error when inserting record. Transaction rollback.');
      Trans.RollbackRetaining;
    end;
  end;
   WriteLn;
 
  Trans.Commit;
 
  Write('Closing database... Database.Connected = ');  Database.Close;
  WriteLn(Database.Connected);
end.
 
{  $Log: testib.pp,v $
  Revision 1.7  2005/02/14 17:13:12  peter
    * truncate log
 
}

Punto importante: Si vas a sugerir un segmento de código en algún lenguaje debes hacerlo así:

  • Si es lenguaje C <code lang="c">Código en C</code>
  • Si es lenguaje Pascal <code lang="pascal">Aquí dentro el código de Pascal</code>.

De esta manera el código coloreas el código.

Deja un comentario

Suscribirse a los comentarios.