function IPDOStatement.fetch_bound: Boolean;
This function retrieves the next row from the result set and binds the variables associated with the columns. All columns must be bound before calling IPDOStatement.fetch_bound.
Returns TRUE if there was an unfetched row on the current result set, and it was successfully bound to the variables, and FALSE otherwise.
Binding columns in the result set to Pascal variables is an effective way to make the data contained in each row immediately available to your application. The following example demonstrates how PDO allows you to bind and retrieve columns with a variety of options and with intelligent defaults.
procedure example1; var sql: AnsiString; cals: Integer; colour, name: AnsiString; Begin sql := 'SELECT name, colour, calories FROM fruit'; try stmt := db.prepare_as_is(sql); stmt.bindColumn ('name', name, string_1); stmt.bindColumn (1, colour); stmt.bindColumn ('calories', cals, integer_16); stmt.execute(); while (stmt.fetch_bound) do begin writeln (name + chr(9) + colour + chr(9) + IntToStr(cals)); end; except on E: Exception do writeln (E.message); end; End;
The above example will output:
apple red 150 banana yellow 175 kiwi green 75 orange orange 150 mango red 200 strawberry red 25