![]() |
| ||
|
|
Новости |
Поиск |
FAQ |
Статьи |
Книги |
Новости VCL
| | Форумы ЧАТ |
Орешник |
|
| |||
| |||
« предыдущая ветвь | форум | следующая ветвь »
Что за параметры требуются для выполнения Execute в KOLSLQuery
Armaniak © (2003-07-25 12:06:00)Собственно весь вопрос. Не смог найти по хелпам.
Заранее спасибо.
Armaniak (2003-07-28 05:11:00) [1]Спасибо, ещё раз. Обязательно попробую.
Boguslaw (2003-07-27 17:11:00) [2]Actually I think that You can also use %d statement for integer variables and other format parameters but I'm not sure .
Try
select * from sometable where thing=%d
and Open([V]) function
where V is integer variable.
This solution is powerfull (just change V value and Open again!) but not compatible with SQL standard.
Boguslaw (2003-07-25 19:52:00) [3]Hello,
function Open(Params : array of const) : Integer;
{* Execute SQL query returning resultset}
function Execute(Params : array of const) : Integer;
{* Execute SQL query without returning resultset (Note: use RowID to find last inserted row
for example to establish foreign key relation)}
Params = array of const
You must read about this in Delphi help.
This is of course something that needs change, but as nobody really take attention to it I assume that this object is not needed by anyone.
I always use this to put params into SQL statement. You must allocate strings variables for each param and pass it to Open or Execute like this:
procedure TDataMod.ChangeUser(Nr : Integer);
var
Iden : String;
begin
try
Iden := Int2Str(Nr);
with QWorking^ do begin
Close;
SQL.Clear;
SQL.Add('SELECT NR_PRACOWNIKA,IMIE || '' '' || NAZWISKO AS DANEOS,NAZWA_STANOWISKA AS STANOWISKO,');
SQL.Add('ADMIN,POP3,SMTP,USER,PASSWORD,EMAIL');
SQL.Add(' FROM STANOWISKA');
SQL.Add(' INNER JOIN PRACOWNICY USING(NR_STANOWISKA) WHERE NR_PRACOWNIKA =%Q');
if Open([Iden]) <> 0 then Exit;
First;
if RowCount <> 1 then Exit;
NrPrac := Str2Int(SField[0]);
Admin := StrEq('T',SField[3]);
POP3 := SField[4];
SMTP := SField[5];
USER := SField[6];
PASSWORD := SField[7];
ADR_MAIL := SField[8];
DaneOsobowe := SFieldByName['DANEOS'] + CrLf + SFieldByName['Stanowisko'];
end;
finally
QWorking.Close;
end;
end;
Note that each %Q or %q must be represented by param in Params array:
SQL = select source form repository when cathegory=%Q and date < %Q
var
s1,s2 : String;
begin
s1 := 'KOL';
s2 := DecodeDateToStringInFormat???(Now); //2003-01-03 (yyyy-mm-dd);
SLQuery.Open[s1,s2];
Regards
Boguslaw