向数据库中插入数据代码: with qry_temp do
begin
Close;
sql.Clear;
sql.Add('insert into db(字段1,字段2,...,字段n) values (:1,:2,...,:n)');
Parameters.ParamByName('1').Value := Trim(edt_1.Text); //edt_1.Text内容为aaa
Parameters.ParamByName('2').Value := Trim(edt_2.Text); //edt_1.Text内容为bbb
...
Parameters.ParamByName('n').Value := Trim(edt_n.Text); //edt_n.Text内容为xxx ShowMessage(sql.Text); ExecSQL; end;现在在运行程序时,ShowMessage(sql.Text); 语句执行后,在弹出的对话框中显示的内容是:insert into db(字段1,字段2,...,字段n) values (:1,:2,...,:n)请问如何获取传给:1,:2参数值之后的sql.text语句,即调用ShowMessage(sql.Text); 后弹出的对话框中显示类似下面的效果:
insert into db(字段1,字段2,...,字段n) values ('aaa','bbb',...,'xxx')
begin
Close;
sql.Clear;
sql.Add('insert into db(字段1,字段2,...,字段n) values (:1,:2,...,:n)');
Parameters.ParamByName('1').Value := Trim(edt_1.Text); //edt_1.Text内容为aaa
Parameters.ParamByName('2').Value := Trim(edt_2.Text); //edt_1.Text内容为bbb
...
Parameters.ParamByName('n').Value := Trim(edt_n.Text); //edt_n.Text内容为xxx ShowMessage(sql.Text); ExecSQL; end;现在在运行程序时,ShowMessage(sql.Text); 语句执行后,在弹出的对话框中显示的内容是:insert into db(字段1,字段2,...,字段n) values (:1,:2,...,:n)请问如何获取传给:1,:2参数值之后的sql.text语句,即调用ShowMessage(sql.Text); 后弹出的对话框中显示类似下面的效果:
insert into db(字段1,字段2,...,字段n) values ('aaa','bbb',...,'xxx')
sql.text := 'insert into db(字段1,字段2,...,字段n) values (' + Trim(edt_1.Text) + ',' + Trim(edt_2.Text) + ',' + ... + Trim(edt_n.Text) + ')';
这种方式的话,是可以获取到我所需要的效果(即获取各参数值拼接成实际的sql语句);但是我觉得如果使用Parameters.ParamByName('1').Value := Trim(edt_1.Text);
这种方式,在delphi中应该也有某个地方是把上面各参数的实际值拼接成实际的sql语句再去执行.现在就是不清楚这个地方在哪里,需要用什么方法获取到.
from operation o,pat_visit v,dept_dict d,pat_master_index dex ,pats_in_hospital h
where o.operation_code=:V00001
and (o.patient_id,o.visit_id) not in (select patient_id,visit_id from operation where operation_code=:V00002)
and o.operating_date >= :V00003
and o.operating_date < :V00004
and o.patient_id=v.patient_id
and o.visit_id=v.visit_id
and d.dept_code=v.dept_discharge_from(+)
and o.patient_id=dex.patient_id
and o.patient_id=h.patient_id(+)
and o.visit_id=h.visit_id(+)
order by start_date_time
:V00001 = '88.5701'
:V00002 = '36.0601'
:V00003 = '2012-5-2'
:V00004 = '2012-5-2 23:59:59'