Forum > Databases
MySQL writing into BLOB error: ""is invalid float
syalyshev:
Could anyone kindly help me.
When attempting to insert string variable into blob field of MySQL table the error message ' ""is invalid float' is obtained. Query formed is like this
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---... SaveQuery.SQL.Add(''''+F_Centre.Text+''','); SaveQuery.SQL.Add(''''+BW.Text+''','); SaveQuery.SQL.Add(''''+st_co+''','); SaveQuery.SQL.Add(''''+st_cx+''')'); SaveQuery.ExecSQL; SQLTransaction.Commit;... st_co and st_cx are strings inserted into blobs.
All records in the table are written correctly. Is it possible not to show such a message?
rvk:
--- Quote from: syalyshev on October 13, 2017, 12:33:52 pm ---st_co and st_cx are strings inserted into blobs.
All records in the table are written correctly. Is it possible not to show such a message?
--- End quote ---
Yes, don't insert text when your database/SQL expects a float value.
It's impossible to see because you didn't include the whole SQL statement but in the fields-selection you are trying to insert is a float and you are trying to put text into that (which results in this message).
Check the order of the fields of your entire SQL-statement or put it here with the complete table description.
syalyshev:
Thanks a lot for your reply!
Well, the whole SQL Statement (if nesessary) looks like this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---... SaveQuery.SQL.Add('INSERT INTO work_sp'); SaveQuery.SQL.Add('VALUES (last_insert_id(),'''+ES_Index.Text+''','); {index} SaveQuery.SQL.Add(''''+FormatDateTime('yyy.mm.dd/hh:mm:ss',StrToDateTime(Date_Time.Text))+''','); {date} SaveQuery.SQL.Add(''''+customer_es_name.Text+''','); {cust_es} SaveQuery.SQL.Add(''''+ASMI_Operator.Text+''','); {ASMI_Operator} SaveQuery.SQL.Add(''''+operator_phone.Text+''','); {operator_phone} SaveQuery.SQL.Add(''''+srb_doc.Text+''','); {srb_doc} SaveQuery.SQL.Add(''''+Satellite.Text+''','); {Satellite} SaveQuery.SQL.Add(''''+SatLongitude.Text+''','); {Sat Longitude} SaveQuery.SQL.Add(''''+ChooseTP.Text+''','); {co_tp_name} SaveQuery.SQL.Add(''''+Co_Up_pol.Text+''','); {co_up_pol} SaveQuery.SQL.Add(''''+CX_tp.Text+''','); {cx_tp_name} SaveQuery.SQL.Add(''''+Cx_Up_pol.Text+''','); {cx_up_pol} SaveQuery.SQL.Add(''''+Station_Own.Text+''','); {es_owner} SaveQuery.SQL.Add(''''+User_Operator.Text+''','); {contact_person} SaveQuery.SQL.Add(''''+User_Cont_Phone.Text+''','); {contact_phone} SaveQuery.SQL.Add(''''+ES_location.Text+''','); {es_location} SaveQuery.SQL.Add(''''+ES_latitude.Text+''','); {es_latitude} SaveQuery.SQL.Add(''''+ES_longitude.Text+''','); {es_longitude} SaveQuery.SQL.Add(''''+Ant_Diameter.Text+''','); {es_ant_diam} SaveQuery.SQL.Add(''''+Ref_Station.Text+''','); {ref_station} SaveQuery.SQL.Add(''''+F_up.Text+''','); {frq_isol_up} SaveQuery.SQL.Add(''''+F_dn.Text+''','); {frq_isol_dn} SaveQuery.SQL.Add(''''+CO_EIRP_f.Text+''','); {co_eirp_calculated} SaveQuery.SQL.Add(''''+CPI_es_f.Text+''','); {cpi_es_calculated} SaveQuery.SQL.Add(''''+sp+''','); {dir_spectrum} SaveQuery.SQL.Add(''''+frq+''','); {dir_frq} SaveQuery.SQL.Add(''''+eirp+''','); {dir_frq} SaveQuery.SQL.Add(''''+'0'+''','); {Comment} SaveQuery.SQL.Add(''''+Pot_f.Text+''','); {Pot} SaveQuery.SQL.Add(''''+Pxt_f.Text+''','); {Pxt} SaveQuery.SQL.Add(''''+Por_f.Text+''','); {Por} SaveQuery.SQL.Add(''''+Pxr_f.Text+''','); {Pxr} SaveQuery.SQL.Add(''''+G_CO_Max.Text+''','); {G_CO_Max} SaveQuery.SQL.Add(''''+Got_f.Text+''','); {Got} SaveQuery.SQL.Add(''''+Gor_f.Text+''','); {Gor} SaveQuery.SQL.Add(''''+Gxt_f.Text+''','); {Gxt} SaveQuery.SQL.Add(''''+Gxr_f.Text+''','); {Gxr} SaveQuery.SQL.Add(''''+Gxtx_f.Text+''','); {Gxtx} SaveQuery.SQL.Add(''''+CPIsum_f.Text+''','); {CPIsum} SaveQuery.SQL.Add(''''+CPIsat_f.Text+''','); {CPIsat} SaveQuery.SQL.Add(''''+descr_cust.Text+''','); {cust_full} SaveQuery.SQL.Add(''''+City_Full_f.Text+''','); {City_Full} SaveQuery.SQL.Add(''''+TimeToStr(BegTime.Time)+''','); {BegTime} SaveQuery.SQL.Add(''''+TimeToStr(EndTime.Time)+''','); {EndTime} SaveQuery.SQL.Add(''''+SpentTime.Text+''','); {SpentTime} SaveQuery.SQL.Add(''''+F_Centre.Text+''','); {central FRQ} SaveQuery.SQL.Add(''''+BW.Text+''','); {Band Width} SaveQuery.SQL.Add(''''+st_co+''','); {Spectrum values CO} SaveQuery.SQL.Add(''''+st_cx+''')'); {Spectrum values CX} SaveQuery.ExecSQL; SQLTransaction.Commit;... Table structure as per attached table_structure.jpg.
I have just changed types of fields st_co and ct_cx from MEDIUMBLOB to MEDIUMTEXT for to confirm that string was expected, not float! The result was the same :(
What was my mistake? The message '""is invalid float' though not having influence on the result of recording to database annoys very much!
rvk:
--- Quote from: syalyshev on October 13, 2017, 02:34:06 pm ---Table structure as per attached table_structure.jpg.
I have just changed types of fields st_co and ct_cx from MEDIUMBLOB to MEDIUMTEXT for to confirm that string was expected, not float! The result was the same :(
What was my mistake? The message '""is invalid float' though not having influence on the result of recording to database annoys very much!
--- End quote ---
The fields st_co and ct_cx are not your problem.
If you look at the following fields... you can see you pass them as TEXT (with quotes around it). But according to your DB-design these should be DECIMAL(8,2)s. So you need to pass them as values/valid floats (so remove the extra '). And if one of these field.Text is empty string you should convert it to 0 or NULL. A '' can't be stored in a DECIMAL(8,2).
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- SaveQuery.SQL.Add(''''+Pot_f.Text+''','); {Pot} SaveQuery.SQL.Add(''''+Pxt_f.Text+''','); {Pxt} SaveQuery.SQL.Add(''''+Por_f.Text+''','); {Por} SaveQuery.SQL.Add(''''+Pxr_f.Text+''','); {Pxr} SaveQuery.SQL.Add(''''+G_CO_Max.Text+''','); {G_CO_Max} SaveQuery.SQL.Add(''''+Got_f.Text+''','); {Got} SaveQuery.SQL.Add(''''+Gor_f.Text+''','); {Gor} SaveQuery.SQL.Add(''''+Gxt_f.Text+''','); {Gxt} SaveQuery.SQL.Add(''''+Gxr_f.Text+''','); {Gxr} SaveQuery.SQL.Add(''''+Gxtx_f.Text+''','); {Gxtx} SaveQuery.SQL.Add(''''+CPIsum_f.Text+''','); {CPIsum} SaveQuery.SQL.Add(''''+CPIsat_f.Text+''','); {CPIsat} SaveQuery.SQL.Add(''''+F_Centre.Text+''','); {central FRQ} SaveQuery.SQL.Add(''''+BW.Text+''','); {Band Width}
syalyshev:
Thanks again for your reply!
I followed your recommendations and obtained no effect. No change.
One thing puzzles... Until I addded fields: fcenter, band (float!) and spect_co, spect_cx (blob or text!), everything worked, records were written without rough. Adding these fields changed the structure of the table dramatically!
Thanks a lot anyway! Going to think over the issue further!
Navigation
[0] Message Index
[#] Next page