ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/public/ibx/trunk/runtime/IBSQL.pas
(Generate patch)

Comparing ibx/trunk/runtime/IBSQL.pas (file contents):
Revision 25 by tony, Sat Mar 14 10:44:03 2015 UTC vs.
Revision 33 by tony, Sat Jul 18 12:30:52 2015 UTC

# Line 76 | Line 76 | uses
76   {$ELSE}
77    baseunix, unix,
78   {$ENDIF}
79 <  SysUtils, Classes, Forms, Controls, IBHeader,
79 >  SysUtils, Classes, IBHeader,
80    IBErrorCodes, IBExternals, DB, IB, IBDatabase, IBUtils, IBXConst;
81  
82   const
# Line 366 | Line 366 | type
366      procedure SetSQL(Value: TStrings);
367      procedure SetTransaction(Value: TIBTransaction);
368      procedure SQLChanging(Sender: TObject);
369 <    procedure BeforeTransactionEnd(Sender: TObject);
369 >    procedure BeforeTransactionEnd(Sender: TObject; Action: TTransactionAction);
370    public
371      constructor Create(AOwner: TComponent); override;
372      destructor Destroy; override;
# Line 2159 | Line 2159 | begin
2159    FSQLRecord := TIBXSQLDA.Create(self,daOutput);
2160    FSQLType := SQLUnknown;
2161    FParamCheck := True;
2162 <  FCursor := Name + RandomString(8);
2162 >  FCursor := HexStr(self); //Name + RandomString(8);
2163    if AOwner is TIBDatabase then
2164      Database := TIBDatabase(AOwner)
2165    else
# Line 2311 | Line 2311 | begin
2311        FBOF := True;
2312        FEOF := False;
2313        FRecordCount := 0;
2314 +      if not (csDesigning in ComponentState) then
2315 +        MonitorHook.SQLExecute(Self);
2316        if FGoToFirstRecordOnExecute then
2317          Next;
2318      end;
# Line 2321 | Line 2323 | begin
2323                              Database.SQLDialect,
2324                              FSQLParams.AsXSQLDA,
2325                              FSQLRecord.AsXSQLDA), True);
2326 +      if not (csDesigning in ComponentState) then
2327 +        MonitorHook.SQLExecute(Self);
2328   (*      if (fetch_res <> 0) and (fetch_res <> isc_deadlock) then
2329        begin
2330           { Sometimes a prepared stored procedure appears to get
# Line 2343 | Line 2347 | begin
2347                             TRHandle,
2348                             @FHandle,
2349                             Database.SQLDialect,
2350 <                           FSQLParams.AsXSQLDA), True)
2350 >                           FSQLParams.AsXSQLDA), True);
2351 >      if not (csDesigning in ComponentState) then
2352 >        MonitorHook.SQLExecute(Self);
2353    end;
2354 <  if not (csDesigning in ComponentState) then
2355 <    MonitorHook.SQLExecute(Self);
2354 >  FBase.DoAfterExecQuery(self);
2355 > //  writeln('Rows Affected = ',RowsAffected);
2356   end;
2357  
2358   function TIBSQL.GetEOF: Boolean;
# Line 2458 | Line 2464 | begin
2464         SQLUpdate, SQLDelete])) then
2465      result := ''
2466    else begin
2467 <    info_request := Char(isc_info_sql_get_plan);
2467 >    info_request := isc_info_sql_get_plan;
2468      Call(isc_dsql_sql_info(StatusVector, @FHandle, 2, @info_request,
2469                             SizeOf(result_buffer), result_buffer), True);
2470 <    if (result_buffer[0] <> Char(isc_info_sql_get_plan)) then
2470 >    if (result_buffer[0] <> isc_info_sql_get_plan) then
2471        IBError(ibxeUnknownError, [nil]);
2472      result_length := isc_vax_integer(@result_buffer[1], 2);
2473      SetString(result, nil, result_length);
# Line 2478 | Line 2484 | end;
2484  
2485   function TIBSQL.GetRowsAffected: Integer;
2486   var
2481  result_buffer: array[0..1048] of Char;
2487    info_request: Char;
2488 +  RB: TResultBuffer;
2489   begin
2490    if not Prepared then
2491      result := -1
2492    else begin
2493 <    info_request := Char(isc_info_sql_records);
2494 <    if isc_dsql_sql_info(StatusVector, @FHandle, 1, @info_request,
2495 <                         SizeOf(result_buffer), result_buffer) > 0 then
2496 <      IBDatabaseError;
2497 <    if (result_buffer[0] <> Char(isc_info_sql_records)) then
2498 <      result := -1
2499 <    else
2500 <    case SQLType of
2501 <    SQLUpdate:   Result := isc_vax_integer(@result_buffer[6], 4);
2502 <    SQLDelete:   Result := isc_vax_integer(@result_buffer[13], 4);
2503 <    SQLInsert:   Result := isc_vax_integer(@result_buffer[27], 4);
2504 <    else         Result := -1 ;
2505 <    end ;
2493 >    RB := TResultBuffer.Create;
2494 >    try
2495 >      info_request := isc_info_sql_records;
2496 >      if isc_dsql_sql_info(StatusVector, @FHandle, 1, @info_request,
2497 >                         RB.Size, RB.buffer) > 0 then
2498 >        IBDatabaseError;
2499 >      case SQLType of
2500 >      SQLInsert, SQLUpdate: {Covers Insert or Update as well as individual update}
2501 >        Result := RB.GetValue(isc_info_sql_records, isc_info_req_insert_count)+
2502 >         RB.GetValue(isc_info_sql_records, isc_info_req_update_count);
2503 >      SQLDelete:
2504 >        Result := RB.GetValue(isc_info_sql_records, isc_info_req_delete_count);
2505 >      SQLExecProcedure:
2506 >        Result :=  RB.GetValue(isc_info_sql_records, isc_info_req_insert_count) +
2507 >                   RB.GetValue(isc_info_sql_records, isc_info_req_update_count) +
2508 >                   RB.GetValue(isc_info_sql_records, isc_info_req_delete_count);
2509 >      else
2510 >        Result := 0;
2511 >      end;
2512 >    finally
2513 >      RB.Free;
2514 >    end;
2515    end;
2516   end;
2517  
# Line 2548 | Line 2563 | const
2563    end;
2564  
2565   begin
2566 +  sParamName := '';
2567    slNames := TStringList.Create;
2568    try
2569      { Do some initializations of variables }
# Line 2708 | Line 2724 | begin
2724      { After preparing the statement, query the stmt type and possibly
2725        create a FSQLRecord "holder" }
2726      { Get the type of the statement }
2727 <    type_item := Char(isc_info_sql_stmt_type);
2727 >    type_item := isc_info_sql_stmt_type;
2728      Call(isc_dsql_sql_info(StatusVector, @FHandle, 1, @type_item,
2729                           SizeOf(res_buffer), res_buffer), True);
2730 <    if (res_buffer[0] <> Char(isc_info_sql_stmt_type)) then
2730 >    if (res_buffer[0] <> isc_info_sql_stmt_type) then
2731        IBError(ibxeUnknownError, [nil]);
2732      stmt_len := isc_vax_integer(@res_buffer[1], 2);
2733      FSQLType := TIBSQLTypes(isc_vax_integer(@res_buffer[3], stmt_len));
# Line 2800 | Line 2816 | begin
2816    if FHandle <> nil then FreeHandle;
2817   end;
2818  
2819 < procedure TIBSQL.BeforeTransactionEnd(Sender: TObject);
2819 > procedure TIBSQL.BeforeTransactionEnd(Sender: TObject;
2820 >  Action: TTransactionAction);
2821   begin
2822    if (FOpen) then
2823      Close;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines