AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

SQL problem

Ein Thema von nanix · begonnen am 7. Dez 2009 · letzter Beitrag vom 8. Dez 2009
Antwort Antwort
Seite 2 von 4     12 34      
nanix
(Gast)

n/a Beiträge
 
#11

Re: SQL problem

  Alt 7. Dez 2009, 13:42
Sorry was a little typo which happens if you type faast!

But now no updated records

Delphi-Quellcode:
Item:=false;
end
else begin
ABSQuery1.SQL.Clear;
ABSQuery1.SQL.Text := 'UPDATE Sensors SET Field="' +sField+'"' +','+'Value="'+sValue+'"'+','+'Min="'+sMin+'"'+','+'Max="'+sMax+'"'+' WHERE HWM_ID = :HWM_ID and Sensor_Class = :Sensor_Class and Sensor_ID = :Sensor_ID';






for hwm_index := 0 to NBMonitors - 1 do

for sensor_index := 0 to CPUIDSDK_GetNumberOfSensors(hwm_index, SENSOR_CLASS_VOLTAGE) - 1 do begin
if CPUIDSDK_GetSensorInfos(hwm_index,
sensor_index,
SENSOR_CLASS_VOLTAGE,
ptrName,
iValue,
Value,
Min,
Max)
then begin
ABSQuery1.ParamByName('HWM_ID').AsString:=inttostr(hwm_index);
ABSQuery1.ParamByName('Sensor_Class').AsString:=inttostr(SENSOR_CLASS_VOLTAGE);
ABSQuery1.ParamByName('Sensor_ID').AsString:=inttostr(sensor_index);

sField:=pansichar(ptrname);
sValue:=Format('%.3f V', [Value]);
sMin:=Format('%.3f V', [Min]);
sMax:=Format('%.3f V', [Max]);

ABSQuery1.ExecSQL;


end;
end;
end;
  Mit Zitat antworten Zitat
ToFaceTeKilla

Registriert seit: 17. Mai 2006
Ort: Leipzig
283 Beiträge
 
Delphi XE2 Professional
 
#12

Re: SQL problem

  Alt 7. Dez 2009, 13:50
What are :Sensor_Class, :HWM_ID, :Sensor_ID? Are these Delphi-Variables? Then you must quote and add them (if they are strings! otherwise you must convert them to string!)
'...WHERE (HWM_ID = '+:HWM_ID+') and (Sensor_Class = '+:Sensor_Class+') and (Sensor_ID ='+ :Sensor_ID+')'; And put brackets () around every logical statement!

edit: rubbish
Billy Gerwitz
"Bei der Softwareentwicklung suchen wir nicht den richtigen Weg, sondern den am wenigsten falschen." - frei nach V. Hillmann
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#13

Re: SQL problem

  Alt 7. Dez 2009, 13:52
I thought with parameters is good?

delphi variables are
Delphi-Quellcode:
var
sField,sMax,sMin,sValue:String;
begin
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#14

Re: SQL problem

  Alt 7. Dez 2009, 13:54
Zitat:
And put brackets () around every logical statement!
And why? Just makes statement less readable

Zitat:
What are :Sensor_Class, :HWM_ID, :Sensor_ID? Are these Delphi-Variables? Then you must quote and add them (if they are strings! otherwise you must convert them to string!)
No this are Parameters. Type is automatically set by dbms.
Markus Kinzler
  Mit Zitat antworten Zitat
ToFaceTeKilla

Registriert seit: 17. Mai 2006
Ort: Leipzig
283 Beiträge
 
Delphi XE2 Professional
 
#15

Re: SQL problem

  Alt 7. Dez 2009, 13:58
Oh my fault. Just overlooked the whole parameter thing... Then move on Mr I don't know, how to address the parameters here.

Ok, brackets arent necessary. Just a habit of me oO
Billy Gerwitz
"Bei der Softwareentwicklung suchen wir nicht den richtigen Weg, sondern den am wenigsten falschen." - frei nach V. Hillmann
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#16

Re: SQL problem

  Alt 7. Dez 2009, 13:59
Yes setting long SQL texts is trouble for most 3rd party databases..
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#17

Re: SQL problem

  Alt 7. Dez 2009, 14:02
Ist just oen reason for parameters. But the main reasons are type-conversion, type formats (e.g. date values) and the performance boost of using prepared statements for mass import/updates etc.
Markus Kinzler
  Mit Zitat antworten Zitat
nanix
(Gast)

n/a Beiträge
 
#18

Re: SQL problem

  Alt 7. Dez 2009, 14:04
I don't understand why it won't update Records

Edit:
Edit1.Text:=ABSQuery1.SQL.Text; Edit1 reports this

UPDATE Sensors SET Field="",Value="",Min="",Max="" WHERE HWM_ID = :HWM_ID and Sensor_Class = :Sensor_Class and Sensor_ID = :Sensor_ID
  Mit Zitat antworten Zitat
mkinzler
(Moderator)

Registriert seit: 9. Dez 2005
Ort: Heilbronn
39.851 Beiträge
 
Delphi 11 Alexandria
 
#19

Re: SQL problem

  Alt 7. Dez 2009, 14:08
Is an error shown or just nothing happens?
Markus Kinzler
  Mit Zitat antworten Zitat
ToFaceTeKilla

Registriert seit: 17. Mai 2006
Ort: Leipzig
283 Beiträge
 
Delphi XE2 Professional
 
#20

Re: SQL problem

  Alt 7. Dez 2009, 14:08
Does the code compile? Do you get any error messages or arent there just any updated records?

If it runs and there are just no records updated then set breakpoints and step through your code. Maybe one of the functions (CPUIDSDK_GetNumberOfSensors or CPUIDSDK_GetSensorInfos) returns a wrong value?
Billy Gerwitz
"Bei der Softwareentwicklung suchen wir nicht den richtigen Weg, sondern den am wenigsten falschen." - frei nach V. Hillmann
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 4     12 34      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:07 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz