[twsocket] OT Delphi ADO question

2009-04-01 Thread Info2004
Sorry for the OT guys, but I'm not getting any response on 
forums.codegear.com, and since you guys know your stuff, I'm hoping for 
some tips.

I am using an ADO stored proc to call a stored proc on a MSSQL server.

One of the parameters in the stored proc on the server is a 
Decimal(28,20) but delphi detects this in the parameters list and sets 
it to ftBCD, precision 28, scale of 20.

Now, trying to insert a number of 53.4167098 ends up in the database as 
53.4167, and the profiler captures this as well. So, something happening 
at the delphi end.

I am using Turbo 2006.

I have manually changed the parameter field type to ftFloat in the GUI, 
and also in code just before the call is made to the assignment of the 
value. But still the truncation.

Any ideas guys?

Regards,

Andy
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] OT Delphi ADO question

2009-04-01 Thread Angus Robertson - Magenta Systems Ltd
 I am using an ADO stored proc to call a stored proc on a MSSQL 
 server.
 One of the parameters in the stored proc on the server is a 
 Decimal(28,20) but delphi detects this in the parameters list and 
 sets it to ftBCD, precision 28, scale of 20.

It sounds like you are using the stored procedure component, and some
data conversion is going wrong.  Unless you are using data aware controls
or something, you can build the command and parameter list for the stored
procedure as a simple widestring and use the EXECUTE method in the
connection to run it.  You can get a result set and read it as string
numerics, to get whatever precision you need.  

ADO only deals in ASCII, not numerics, all conversions to internal SQL
data types take place in ADO or SQL itself, not Delphi. 

Angus

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] OT Delphi ADO question

2009-04-01 Thread Info2004
Angus,

Thanks for the response.

Yes I'm using the stored proc component. No data aware controls.

So, you solution would be something like creating a string:

exec sp_InsertVehicleData;1 '2009/01/17
15:48:12',1,'0358104000636686','0F611B8C',17,$53.5161,$-2.2367,0,$15475.
5996,$0.,$0.,0,0,'S',0,0,0,0,0,0,0,0,'',$-2.2367,$53.5161,$65535.000
0,0x010358104000636686FF447800344015FF2A0F611B8C11EAC5738C79105642C0260F
C8B904C0260FC07910564200FF7F47900105,60,1,'447800344015'

which is the command captured with the profiler.

Am I understanding you correctly?

Regards,

Andy


Angus Robertson - Magenta Systems Ltd wrote:
 I am using an ADO stored proc to call a stored proc on a MSSQL 
 server.
 One of the parameters in the stored proc on the server is a 
 Decimal(28,20) but delphi detects this in the parameters list and 
 sets it to ftBCD, precision 28, scale of 20.
 
 It sounds like you are using the stored procedure component, and some
 data conversion is going wrong.  Unless you are using data aware controls
 or something, you can build the command and parameter list for the stored
 procedure as a simple widestring and use the EXECUTE method in the
 connection to run it.  You can get a result set and read it as string
 numerics, to get whatever precision you need.  
 
 ADO only deals in ASCII, not numerics, all conversions to internal SQL
 data types take place in ADO or SQL itself, not Delphi. 
 
 Angus
 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] OT Delphi ADO question

2009-04-01 Thread Info2004
Angus,

Fantastic answer. Thanks for going the extra distance to explain it. 
It's appreciated.

Yep to the application :)

Regards,

Andy

Angus Robertson - Magenta Systems Ltd wrote:
 exec sp_InsertVehicleData;1 '2009/01/17
 15:48:12',1,'0358104000636686','0F611B8C',17,$53.5161,$-2.2367,0
 ,$15475.
 5996,$0.,$0.,0,0,'S',0,0,0,0,0,0,0,0,'',$-2.2367,$53.5161,$6
 5535.000
 0,0x010358104000636686FF447800344015FF2A0F611B8C11EAC5738C791056
 42C0260F
 C8B904C0260FC07910564200FF7F47900105,60,1,'447800344015'
 
 So you're collecting moving vehicle GPS data from a UK mobile telephone
 modem for a map, seen it all before g
 
 So, you solution would be something like creating a string:
 
 Essentially yes, except ADO adds sp_ and ;1 so just use the stored
 procedure name:
 
 exec InsertVehicleData xxx 
 
 And you've got a wide range of data types in your parameter list there,
 which you need to ensure match the data types in the stored procedure,
 those hex strings look strange, but then I don't store binary stuff.
 You're original error could be in those strings.  You might be better
 passing strange numbers as VARCHAR and converting them to numerics in the
 stored procedure itself, assuming you can mess with it. 
 
 Getting back on topic with ICS, this is how I build the parameter to save
 my FTP server statistics in SQL:
 
 cmd := 'EXEC ftp_events_updx1 ' +
 IntToStr (FtpServers [servnr].StartId) + paramSep +
 QuotedStr (EventState) + paramSep +
 QuotedStr (Comment) + paramSep +
 '0' + paramSep +  // endpos
 IntToStr (FtpServers [servnr].TotalXmit) + paramSep +
 IntToStr (FtpServers [servnr].TotalRecv) + paramSep +
 IntToStr (secs) + paramSep +  // duration secs
 IntToStr (FtpServers [servnr].MaxSpeedXmit) + paramSep +
 IntToStr (FtpServers [servnr].MaxSpeedRecv) ;
 ExecSqlFtpCmd (cmd) ;
 
 and this is the core of the function to call SQL and get a resultset,
 which just contains two fields with an error code and description in this
 case, but could be a million records.
 
 DataSetFtpUpd.Recordset := ADOConn.Execute (cmd) ;
 if DataSetFtpUpd.RecordCount = 1 then
 begin
dbretcode := DataSetFtpUpd.Fields[0].DisplayText ;
result := AscToInt (DataSetFtpUpd.Fields[2].DisplayText) ;
 end ;
   
 Angus
 

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be