~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to packages/base/mysql/testdb.pp

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2005-05-30 11:59:10 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050530115910-x5pbzm4qqta4i94h
Tags: 2.0.0-2
debian/fp-compiler.postinst.in: forgot to reapply the patch that
correctly creates the slave link to pc(1).  (Closes: #310907)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
program qtest;
2
 
 
3
 
uses mysql;
4
 
 
5
 
Const
6
 
  DataBase : Pchar = 'testdb';
7
 
  Query    : Pchar = 'Select * from FPdev';
8
 
 
9
 
var
10
 
  count,num : longint;
11
 
  code : integer;
12
 
  sock : PMYSQL;
13
 
  qmysql : TMYSQL;
14
 
  qbuf : string [160];
15
 
  rowbuf : TMYSQL_ROW;
16
 
  dummy : string;
17
 
  recbuf : PMYSQL_RES;
18
 
 
19
 
begin
20
 
  if paramcount=1 then
21
 
    begin
22
 
    Dummy:=Paramstr(1)+#0;
23
 
    DataBase:=@Dummy[1];
24
 
    end;
25
 
  Write ('Connecting to MySQL...');
26
 
  sock :=  mysql_connect(PMysql(@qmysql),nil,nil,nil);
27
 
  if sock=Nil then
28
 
    begin
29
 
    Writeln (stderr,'Couldn''t connect to MySQL.');
30
 
    Writeln (stderr,mysql_error(@qmysql));
31
 
    halt(1);
32
 
    end;
33
 
  Writeln ('Done.');
34
 
  Writeln ('Connection data:');
35
 
{$ifdef Unix}
36
 
  writeln ('Mysql_port      : ',mysql_port);
37
 
  writeln ('Mysql_unix_port : ',mysql_unix_port);
38
 
{$endif}
39
 
  writeln ('Host info       : ',mysql_get_host_info(sock));
40
 
  writeln ('Server info     : ',mysql_stat(sock));
41
 
  writeln ('Client info     : ',mysql_get_client_info);
42
 
 
43
 
  Writeln ('Selecting Database ',DataBase,'...');
44
 
  if mysql_select_db(sock,DataBase) < 0 then
45
 
    begin
46
 
    Writeln (stderr,'Couldn''t select database ',Database);
47
 
    Writeln (stderr,mysql_error(sock));
48
 
    halt (1);
49
 
    end;
50
 
 
51
 
  writeln ('Executing query : ',Query,'...');
52
 
    if (mysql_query(sock,Query) < 0) then
53
 
      begin
54
 
      Writeln (stderr,'Query failed ');
55
 
      writeln (stderr,mysql_error(sock));
56
 
      Halt(1);
57
 
      end;
58
 
 
59
 
  recbuf := mysql_store_result(sock);
60
 
  if RecBuf=Nil then
61
 
    begin
62
 
    Writeln ('Query returned nil result.');
63
 
    mysql_close(sock);
64
 
    halt (1);
65
 
    end;
66
 
  Writeln ('Number of records returned  : ',mysql_num_rows (recbuf));
67
 
  Writeln ('Number of fields per record : ',mysql_num_fields(recbuf));
68
 
 
69
 
  rowbuf := mysql_fetch_row(recbuf);
70
 
  while (rowbuf <>nil) do
71
 
       begin
72
 
       Write  ('(Id: ', rowbuf[0]);
73
 
       Write  (', Name: ', rowbuf[1]);
74
 
       Writeln(', Email : ', rowbuf[2],')');
75
 
       rowbuf := mysql_fetch_row(recbuf);
76
 
       end;
77
 
  Writeln ('Freeing memory occupied by result set...');
78
 
  mysql_free_result (recbuf);
79
 
 
80
 
  Writeln ('Closing connection with MySQL.');
81
 
  mysql_close(sock);
82
 
  halt(0);
83
 
end.
84
 
  $Log: testdb.pp,v $
85
 
  Revision 1.3  2002/09/07 15:42:53  peter
86
 
    * old logs removed and tabs fixed
87
 
 
88
 
  Revision 1.2  2002/05/31 11:54:33  marco
89
 
  * Renamefest for 1.0, many 1.1.x spots patched also.
90
 
 
91
 
  Revision 1.1  2002/01/29 17:54:54  peter
92
 
    * splitted to base and extra
93
 
 
94
 
}