If you do not know whether or not the value returned when running the stored procedure..
try
UniQuery1.Close;
UniQuery1.SQL.Clear;
UniQuery1.SQL.Text := 'EXEC TEST';
UniQuery1.OPEN
except
UniQuery1.Execute;
end;
Is there any other way?
Query 'Open' or 'Execute'
Re: Query 'Open' or 'Execute'
var
i : integer;
begin
UniQuery1.Close;
UniQuery1.SQL.Clear;
UniQuery1.SQL.Text := 'select * from c_usermaster';
UniQuery1.Execute;
for i := 0 to UniQuery1.RecordCount -1 do begin
Memo1.Lines.Add(UniQuery1.Fields[0].AsString);
UniQuery1.Next;
end;
Using 'Execute' in the 'select' query does not cause any problems.
Is it okay to use it like this?
i : integer;
begin
UniQuery1.Close;
UniQuery1.SQL.Clear;
UniQuery1.SQL.Text := 'select * from c_usermaster';
UniQuery1.Execute;
for i := 0 to UniQuery1.RecordCount -1 do begin
Memo1.Lines.Add(UniQuery1.Fields[0].AsString);
UniQuery1.Next;
end;
Using 'Execute' in the 'select' query does not cause any problems.
Is it okay to use it like this?
Re: Query 'Open' or 'Execute'
What database are you accessing with our components? The Open method works only for queries that return a recordset. Otherwise, a "Query does not return rows" exception will be thrown.
Execute is a universal method which analyzes the SQL statement. Depending on the statement, our components will open a recordset with the output of the query (for eaxmple, for SELECT statements) or directly execute the statement and read the out parameters (for example for statements containing EXEC).
Execute is a universal method which analyzes the SQL statement. Depending on the statement, our components will open a recordset with the output of the query (for eaxmple, for SELECT statements) or directly execute the statement and read the out parameters (for example for statements containing EXEC).