Page 1 of 1

muti update table

Posted: 30.07.2006, 03:38
by hitman
how to muti update table
ex

select a.id,b.name from a,b where a.id=b.id
now i update a only
how to do !!

Posted: 30.07.2006, 07:17
by dhongu
Use TZUpdateSQL and define InsertSQl, ModifiySQL, DeleteSQL property.


For update table a: update a set a.id = :id where a.id = :old_id

Posted: 31.07.2006, 00:18
by hitman
tks
i did update a set id = :id where id = :old_id

so raise a error !! ha ha

Posted: 31.07.2006, 13:41
by btrewern
Look at the help entries for the BDE TUpdateSQL component. The TZUpdateSQL works in a similar manner.

If you tell us what error you are getting, maybe someone could help you.

Regards,

Ben

Posted: 31.07.2006, 14:32
by dhongu

Code: Select all

object Form2: TForm2
  
 
  object DBGrid1: TDBGrid

    DataSource = DataSource1

  end
  object DBNavigator1: TDBNavigator

    DataSource = DataSource1

  end
  object ZUpdateSQL1: TZUpdateSQL
    InsertSQL.Strings = (
      'insert into a  (id) value (:id);'
      ''
      'insert into b (id,name) values ( :id, :name );')
    ModifySQL.Strings = (
      'update a set a.id = :id where a.id = :old_id;'
      ''
      'update b set b.id = :id, b.name = :name where b.id= :old_id;')
    UseSequenceFieldForRefreshSQL = False
    Left = 136
    Top = 8
    ParamData = <
      item
        DataType = ftUnknown
        Name = 'id'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'old_id'
        ParamType = ptUnknown
      end
      item
        DataType = ftUnknown
        Name = 'name'
        ParamType = ptUnknown
      end>
  end
  object ZQuery1: TZQuery
    
    UpdateObject = ZUpdateSQL1
    SQL.Strings = (
      'select a.id,b.name from a,b where a.id=b.id')
    Params = <>
    Left = 88
    Top = 8
  end
  object DataSource1: TDataSource
    DataSet = ZQuery1
    Left = 176
    Top = 8
  end
end