Query UpdateQuery Fieldbyname

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
guney_tosun
Üye
Mesajlar: 82
Kayıt: 19 Ağu 2005 09:34
Konum: Istanbul

Query UpdateQuery Fieldbyname

Mesaj gönderen guney_tosun »

3 ayrı tablodan query ile aldığım dataların 3 tane boş alanına field by name kullanarak editlerdeki stringleri atamak istiyorum..


UpdateSQL de kullanıyorum..

Kod: Tümünü seç

update billto,shipto,shipmentinfo,nikebarcode set
  nikebarcode.Code1 = :Code1,
  nikebarcode.Code2 = :Code2,
  nikebarcode.Shipment = :Shipment,
  nikebarcode.Package = :Package,
  shipmentinfo.trailer = :trailer,
  shipmentinfo.Shipment = :Shipment,
  shipmentinfo.Customer = :Customer,
  shipmentinfo.city = :city,
  shipmentinfo.country = :country,
  shipmentinfo.Name = :Name,
  shipmentinfo.Colli = :Colli,
  shipmentinfo.Weight = :Weight,
  shipmentinfo.Unit = :Unit,
  shipmentinfo.ProductName = :ProductName,
  shipmentinfo.WaybillNo = :WaybillNo,
  shipmentinfo.DeliveryDate = :DeliveryDate,
  shipmentinfo.time = :time,
  shipmentinfo.MISSING = :MISSING,
  shipmentinfo.Waybilldate = :Waybilldate,
  shipmentinfo.WaybillCreated = :WaybillCreated,
  shipto.ID = :ID,
  shipto.CustomerCode = :CustomerCode,
  shipto.DeliveryName = :DeliveryName,
  shipto.DeliveryAddress = :DeliveryAddress,
  shipto.DeliveryAddress2 = :DeliveryAddress2,
  shipto.DeliveryDistrict = :DeliveryDistrict,
  shipto.DeliveryCity = :DeliveryCity,
  shipto.DeliveryPostCode = :DeliveryPostCode,
  shipto.Deliverycode = :Deliverycode,
  billto.ID = :ID,
  billto.CustomerCode = :CustomerCode,
  billto.CustomerName = :CustomerName,
  billto.Address = :Address,
  billto.Address2 = :Address2,
  billto.District = :District,
  billto.City = :City,
  billto.Postcode = :Postcode,
  billto.TaxOffice = :TaxOffice,
  billto.TaxNumber = :TaxNumber
where
  ((nikebarcode.Code1 is null and :OLD_Code1 is null) or 
(nikebarcode.Code1 = :OLD_Code1)) and
  ((nikebarcode.Code2 is null and :OLD_Code2 is null) or 
(nikebarcode.Code2 = :OLD_Code2)) and
  ((nikebarcode.Shipment is null and :OLD_Shipment is null) or 
(nikebarcode.Shipment = :OLD_Shipment)) and
  ((nikebarcode.Package is null and :OLD_Package is null) or 
(nikebarcode.Package = :OLD_Package)) and
  ((shipmentinfo.trailer is null and :OLD_trailer is null) or (shipmentinfo.trailer 
= :OLD_trailer)) and
  ((shipmentinfo.Shipment is null and :OLD_Shipment is null) or 
(shipmentinfo.Shipment = :OLD_Shipment)) and
  ((shipmentinfo.Customer is null and :OLD_Customer is null) or 
(shipmentinfo.Customer = :OLD_Customer)) and
  ((shipmentinfo.city is null and :OLD_city is null) or (shipmentinfo.city = 
:OLD_city)) and
  ((shipmentinfo.country is null and :OLD_country is null) or 
(shipmentinfo.country = :OLD_country)) and
  ((shipmentinfo.Name is null and :OLD_Name is null) or 
(shipmentinfo.Name = :OLD_Name)) and
  ((shipmentinfo.Colli is null and :OLD_Colli is null) or (shipmentinfo.Colli = 
:OLD_Colli)) and
  ((shipmentinfo.Weight is null and :OLD_Weight is null) or 
(shipmentinfo.Weight = :OLD_Weight)) and
  ((shipmentinfo.Unit is null and :OLD_Unit is null) or (shipmentinfo.Unit = 
:OLD_Unit)) and
  ((shipmentinfo.ProductName is null and :OLD_ProductName is null) or 
(shipmentinfo.ProductName = :OLD_ProductName)) and
  ((shipmentinfo.WaybillNo is null and :OLD_WaybillNo is null) or 
(shipmentinfo.WaybillNo = :OLD_WaybillNo)) and
  ((shipmentinfo.DeliveryDate is null and :OLD_DeliveryDate is null) or 
(shipmentinfo.DeliveryDate = :OLD_DeliveryDate)) and
  ((shipmentinfo.time is null and :OLD_time is null) or (shipmentinfo.time = 
:OLD_time)) and
  ((shipmentinfo.MISSING is null and :OLD_MISSING is null) or 
(shipmentinfo.MISSING = :OLD_MISSING)) and
  ((shipmentinfo.Waybilldate is null and :OLD_Waybilldate is null) or 
(shipmentinfo.Waybilldate = :OLD_Waybilldate)) and
  ((shipmentinfo.WaybillCreated is null and :OLD_WaybillCreated is null) or 
(shipmentinfo.WaybillCreated = :OLD_WaybillCreated)) and
  shipto.ID = :OLD_ID and
  ((shipto.CustomerCode is null and :OLD_CustomerCode is null) or 
(shipto.CustomerCode = :OLD_CustomerCode)) and
  ((shipto.DeliveryName is null and :OLD_DeliveryName is null) or 
(shipto.DeliveryName = :OLD_DeliveryName)) and
  ((shipto.DeliveryAddress is null and :OLD_DeliveryAddress is null) or 
(shipto.DeliveryAddress = :OLD_DeliveryAddress)) and
  ((shipto.DeliveryAddress2 is null and :OLD_DeliveryAddress2 is null) or 
(shipto.DeliveryAddress2 = :OLD_DeliveryAddress2)) and
  ((shipto.DeliveryDistrict is null and :OLD_DeliveryDistrict is null) or 
(shipto.DeliveryDistrict = :OLD_DeliveryDistrict)) and
  ((shipto.DeliveryCity is null and :OLD_DeliveryCity is null) or 
(shipto.DeliveryCity = :OLD_DeliveryCity)) and
  ((shipto.DeliveryPostCode is null and :OLD_DeliveryPostCode is null) or 
(shipto.DeliveryPostCode = :OLD_DeliveryPostCode)) and
  ((shipto.Deliverycode is null and :OLD_Deliverycode is null) or 
(shipto.Deliverycode = :OLD_Deliverycode)) and
  ((billto.ID is null and :OLD_ID is null) or (billto.ID = :OLD_ID)) and
  ((billto.CustomerCode is null and :OLD_CustomerCode is null) or 
(billto.CustomerCode = :OLD_CustomerCode)) and
  ((billto.CustomerName is null and :OLD_CustomerName is null) or 
(billto.CustomerName = :OLD_CustomerName)) and
  ((billto.Address is null and :OLD_Address is null) or (billto.Address = 
:OLD_Address)) and
  ((billto.Address2 is null and :OLD_Address2 is null) or (billto.Address2 = 
:OLD_Address2)) and
  ((billto.District is null and :OLD_District is null) or (billto.District = 
:OLD_District)) and
  ((billto.City is null and :OLD_City is null) or (billto.City = :OLD_City)) and
  ((billto.Postcode is null and :OLD_Postcode is null) or (billto.Postcode = 
:OLD_Postcode)) and
  ((billto.TaxOffice is null and :OLD_TaxOffice is null) or (billto.TaxOffice = 
:OLD_TaxOffice)) and
  ((billto.TaxNumber is null and :OLD_TaxNumber is null) or 
(billto.TaxNumber = :OLD_TaxNumber))

Buda delphi kodu

Kod: Tümünü seç

procedure TForm7.Button2Click(Sender: TObject);
begin
zquery2.first;
while not ZQuery2.Eof do
if        zquery2.Active then
          zquery2.open;
zquery2.edit;
zquery2.FieldByName('DeliveryDate').asstring:=maskedit1.Text;
zquery2.FieldByName('Waybilldate').asstring:=maskedit3.text;
zquery2.FieldByName('Time').AsString:=maskedit2.Text;
zquery2.Next;
zquery2.edit;
zquery2.post;
end;
Celebrating the past , Creating the Future
Kullanıcı avatarı
rsimsek
Admin
Mesajlar: 4482
Kayıt: 10 Haz 2003 01:48
Konum: İstanbul

Mesaj gönderen rsimsek »

Delphi tarafını aşağıdaki gibi yazarsan çalışması lazım.. UPDATE cümlesi kontrol edilebilecek gibi değil:P.. artık doğruluğu sana kalmı;)

Kod: Tümünü seç

procedure TForm7.Button2Click(Sender: TObject);
begin
if not zquery2.Active then // Query açma olayını başta kontrol etmelisin..
  zquery2.open;
zquery2.first;
while not ZQuery2.Eof do
begin
  zquery2.edit;
  zquery2.FieldByName('DeliveryDate').asstring:=maskedit1.Text;
  zquery2.FieldByName('Waybilldate').asstring:=maskedit3.text;
  zquery2.FieldByName('Time').AsString:=maskedit2.Text;
  zquery2.post;
  zquery2.Next;
end;
Bu while /do ile tüm kayıtlara aynı değerler tablo yapısında aksi belirtilmedikçe atama yapılır!
Bilgiyi paylaşarak artıralım! Hayatı kolaylaştıralım!!
Cevapla