SQL database returns a comma in a float, instead of the expected decimal point

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
7 posts • Page 1 of 1
ArdMolenaar
Posts:7
Joined: Mon Mar 05, 2012 2:33 pm

SQL database returns a comma in a float, instead of the expected decimal point

Post by ArdMolenaar »

The SQL database contains a column defined as float.

Using PVSS 3.8 I retrieve these database values using a query. The data returned from the database is now captured in the form of a string, which isn't a problem.
However, within this string all decimal points are replaced by comma's.

The regional format of the Windows Server 2003 OS is set to English (United States), which uses a decimal point.

Does anyone has a solution to retrieve the data with decimal points? As it is now, I replace all comma's by points, but this isn't a neat solution.

Thanks in advance!

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: SQL database returns a comma in a float, instead of the expected decimal point

Post by fmulder »

Ard,

You're probably using WinCc OA scripting commands to retrievbe the data from the database. Isn't the float just returned as a float. Where is the float transformed into a string.
Can you attach the script that you use ?

ArdMolenaar
Posts:7
Joined: Mon Mar 05, 2012 2:33 pm

Re: SQL database returns a comma in a float, instead of the expected decimal point

Post by ArdMolenaar »

Dear Frenk Mulder,

Thanks for the reply, I'm sorry for the delayed response.

I attached the script.

The function you will see returns the result from the SQL database in dyn_string &vResult.

This result is obtained by setting a datapoint which controls the SQLViaDP manager. This manager is from PVSS and it is a black box. I think this manager causes the problem.

Regards,
Jeroen https://www.winccoa.com/fileadmin/image ... swerDS.ctl
Attachments

[The extension ctl has been deactivated and can no longer be displayed.]


fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: SQL database returns a comma in a float, instead of the expected decimal point

Post by fmulder »

There is good news and bad news. I'm the original author of the SqlViadp manager. Unfortunately, since I left ETM 3 years ago, I do not have the C++ code of the manager and can't tell you exactly how the data is retrieved from MS-SQL.
I'd assume that there is some kind of for-next loop in the C++ manager that will eventually transofrm the data into a string.
There can be 2 places where the problem happens (Note: this used to work before)

a) The data is somehow returned differently by MS-SQL
b) The data is wrongly formatted by the SqlViaDp( which is weird because it used to work earlier)

You could try to use sprintf() in a standard PVSS script to see if there is soemthing wrong in the formatting of a float ?

It is hard to help without source. I could give you the folliowing tips:

1) ask Gertjan van schijndel at Siemens. He'll have the source code and this might help you to find out how the raw value from MS-SQL is transformed into a string.
2) You might change the query and 'ask' MS-SQL to return your float value in a different value (e.g. let MS-SQL format it into a string)
(See http://msdn.microsoft.com/en-us/library/ms187928.aspx )

Good luck !

Frenk

ArdMolenaar
Posts:7
Joined: Mon Mar 05, 2012 2:33 pm

Re: SQL database returns a comma in a float, instead of the expected decimal point

Post by ArdMolenaar »

What a coincidence, Frenk!

I am going to carry out your suggested tips. I will keep you up to date on this matter.

Thank you for the information.

Jeroen

fmulder
Posts:330
Joined: Wed Feb 03, 2010 9:46 am

Re: SQL database returns a comma in a float, instead of the expected decimal point

Post by fmulder »

That is weird...... that Ard suddenly signs his reactions as jeroen ?

Well good luck. I'd say that converting the value directly in the query should be the easiest and fastest solution


Good luck !

Frenk

ArdMolenaar
Posts:7
Joined: Mon Mar 05, 2012 2:33 pm

Re: SQL database returns a comma in a float, instead of the expected decimal point

Post by ArdMolenaar »

I'm new on the project and using Ard's account to get some support.

Ard sends his regards, though!

7 posts • Page 1 of 1