TDatabase TQuery TDataSource TDBGrid object Database1: TDatabase AliasName = 'sfis' DatabaseName = 'Allcon' LoginPrompt = False Params.Strings = ( 'SERVER NAME=SFIS.WORLD' 'USER NAME=sfis1' 'NET PROTOCOL=TNS' 'OPEN MODE=READ/WRITE' 'SCHEMA CACHE SIZE=8' 'LANGDRIVER=taiwan' 'SQLQRYMODE=SERVER' 'SQLPASSTHRU MODE=SHARED AUTOCOMMIT' 'SCHEMA CACHE TIME=-1' 'MAX ROWS=-1' 'BATCH COUNT=200' 'ENABLE SCHEMA CACHE=FALSE' 'SCHEMA CACHE DIR=' 'ENABLE BCD=FALSE' 'ENABLE INTEGERS=FALSE' 'LIST SYNONYMS=NONE' 'ROWSET SIZE=20' 'BLOBS TO CACHE=64' 'BLOB SIZE=32' 'OBJECT MODE=TRUE' 'PASSWORD=sfcbasetable1') ReadOnly = True SessionName = 'Default' end object Query1: TQuery DatabaseName = 'Allcon' end object DataSource1: TDataSource DataSet = Query1 end object DBGrid1: TDBGrid DataSource = DataSource1 end
//没有参数查询
Query1.Close; Query1.SQL.Clear; Query1.SQL.Add('SELECT * FROM SFISM4.R_MATERIAL_EXC_T'); Query1.Open;
//传参时
sn:='MATERIAL_SN=:sn';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('SELECT * FROM SFISM4.R_MATERIAL_EXC_T where '+sn);
Query1.ParamByName('sn').AsString := Edit_Qry_KPNO.Text;
Query1.Open;
//插入 或更新操作时 query1.Close; query1.SQL.Clear; query1.SQL.Add('INSERT INTO SFISM4.R_MATERIAL_EXC_T (MATERIAL_SN,VENDER,DATA_CODE,LOC_CODE,EXC_TIME,EXC_CODE,ERROR_REASON,BAR_RATE,REASON_COME,CLEAR_FLAG,CLEAR_CODE,CLOSE_FLAG,CLEAR_TIME,QUA_DC,EIGHT_D_CODE,EIGHT_D_ADD,VC_CONTACT,SQE_CONTACT) ' + 'VALUES ( :MATERIAL_SN,:VENDER,:DATA_CODE,:LOC_CODE,:EXC_TIME,:EXC_CODE,:ERROR_REASON,:BAR_RATE,:REASON_COME,:CLEAR_FLAG,:CLEAR_CODE,:CLOSE_FLAG,:CLEAR_TIME,:QUA_DC,:EIGHT_D_CODE,:EIGHT_D_ADD,:VC_CONTACT,:SQE_CONTACT)'); query1.ParamByName('MATERIAL_SN').AsString:=Edit_KP.Text; //...此处省去其他参数赋值 query1.ExecSQL;
query1.SQL.Add('UPDATE SFISM4.R_MATERIAL_EXC_T SET MATERIAL_SN=:MATERIAL_SN,VC_CONTACT=:VC_CONTACT,SQE_CONTACT=:SQE_CONTACT'+' '+
'where MATERIAL_SN=:MATERIAL_SN ')
date11:= formatdatetime('YYYYMMDD',DT_ex_Begin.date); //?date�??Θ?�''/''��才﹃� date22:= formatdatetime('YYYYMMDD',DT_ex_End.date); time11:= Time1.text; //格式为 13:30 time22:= time2.text; ssql:='SELECT * FROM SFISM4.R_MATERIAL_EXC_T where EXC_TIME between to_date('''+Date11+''' || '''+ time11+''',''YYYYMMDDhh24:miss'') and to_date('''+Date22+''' || '''+ time22+''',''YYYYMMDDhh24:miss'') ';