Einzelnen Beitrag anzeigen

question

Registriert seit: 17. Apr 2013
97 Beiträge
 
#1

Mysql Typs (Null) Typ (Integer)

  Alt 25. Aug 2013, 20:27
Hello,
I am using Delphi with mysql, i have a table which contains the data.For example
Table A has ID,Name,Phone and so on , the empty field are filled with "Null"
ID=1, Name=To,Phone=null,

I would like to copy the data from Table A to Table B, but the problem is, if there is no value in a filed then its filled with '0' instead of Null and i got a error messege

"Variante des Typs (Null) konnte nicht in Typ (Integer) konvertiert werden."

ID=1,Name=Tom,Phone=0

my question is, why one table put Null and others 0,since both are same field and same type

need suggestion, i wanna filled the emtpy field not with 0 rather Null,how to do it?

Code:
Query.SQL.Clear;
    Query.SQL.Add('SELECT * FROM TableA WHERE ID = :ID');
    Query.ParamByName('ID').AsInteger := NewID;
    Query.Open;

    while (Query.Eof) and (Query.RecordCount > 0) do

   begin
      QueryB.Close;
      QueryB.SQL.Clear;

      QueryB.SQL.Add('INSERT INTO `TableB` (`ParentID`,`NewID`, and so on
     ,.......
      QueryB.ParamByName('ParentID').AsInteger := Query.FieldByName('ParentID').AsInteger;
      QueryB.ParamByName('NewID').AsInteger := NewID;
I would like to fill the empty field with "null" instad of "0" what should i change ?
  Mit Zitat antworten Zitat