Pascal Data Objects

procedure IPDOStatement.bindTimeValue (valueIndex: Cardinal; PassedValue: TPDOGenericTime); overload;

procedure IPDOStatement.bindTimeValue (valueIndex: AnsiString; PassedValue: TPDOGenericTime); overload;

This overloaded function binds a DATE/TIME structure to a corresponding named or question mark placeholder in the SQL statement that was use to prepare the statement.

Parameters

valueIndex: Parameter identifier. The placeholder can be referenced by either it's 0-indexed position, or its name. For names, the colon is not included, so a placeholder in the statement of :userid has a string valueIndex of userid.

PassedValue: This is the time structure to bind to the placeholder. This is the definition:

    TPDOGenericTime = record
        year:        Cardinal;   
        month:       Cardinal;
        day:         Cardinal;
        hour:        Cardinal;
        minute:      Cardinal;
        second:      Cardinal;
        neg:         Byte;       {boolean: 0 for positive time, 1 for negative time}
        second_part: Int64;      {fraction part of second, not used for MySQL}
    end;

Examples

Example 1. Execute a prepared statement with bound variables

procedure example1;
var
   logtime: TPDOGenericTime;
Begin
   with logtime do begin
      year   := 2000;
      month  := 4; 
      day    := 17;
      hour   := 15;
      minute := 15; 
      second := 0;
      neg    := 0;
      second_part := 0;
   end;
   stmt := db.prepare_as_is (
         'SELECT user_id, name ' + 
         'FROM forum_users ' + 
         'WHERE last_logged_in > :logtime');
   stmt.bindTimeValue ('logtime', logtime);
   stmt.execute;
End;

Example 2. Execute a prepared statement with question mark placeholders

procedure example1;
var
   logtime: TPDOGenericTime;
Begin
   with logtime do begin
      year   := 2000;
      month  := 4; 
      day    := 17;
      hour   := 15;
      minute := 15; 
      second := 0;
      neg    := 0;
      second_part := 0;
   end;
   stmt := db.prepare_as_is (
         'SELECT user_id, name ' + 
         'FROM forum_users ' + 
         'WHERE last_logged_in > ?');
   stmt.bindTimeValue (0, logtime);
   stmt.execute;
End;