Contents | Prev | Next

4.2.13 feature_mysql - MySQL databases supported?

Description

feature_mysql This constant can be used to determine if the current platform supports using MySQL databases.

Example

program Data(input, output);
var
   conn : connection;

   procedure DisplayError(msg : string);
   begin
      writeln('ERROR:',msg);
      halt
   end;

   function GetConnectionString : string;
   var
      s, sDSN, sUSER, sPassword : string;

      function GetStringValue(sPrompt : string) : string;
      var
         sValue : string;
      begin
         write(sPrompt);
         readln(sValue);
         GetStringValue := sValue
      end;

   begin
      if supported(feature_odbc) then
         begin
            sDSN := GetStringValue('Enter Data Source Name (DSN):');
            sUser := GetStringValue('Enter user id:');
            sPassword := GetStringValue('Enter password:');
            s := 'ODBC;DSN='+sDSN+';user='+sUser+';password='+sPassword;
         end
      else if supported(feature_mysql) then
         begin
            sUser := GetStringValue('Enter user id:');
            sPassword := GetStringValue('Enter password:');
            s := 'MYSQL;user="'+sUser+'";password="'+sPassword+'";socket="/tmp/mysql.sock"';
         end
      else
         DisplayError('No database support detected');
      GetConnectionString := s;
   end;

begin
   new(conn);
   conn.open(GetConnectionString);
   //
   //Add code here to process database
   //
   conn.close;
   dispose(conn);
end.

Portability

Operating Systems: All
Standard Pascal: No

Contents | Prev | Next