
FDARI
New User
Mar 30, 2011, 6:22 AM
Post #1 of 2
(6162 views)
|
SQL query return types
|
Can't Post
|
|
Hi. I am an SQL-DBA, not a PERL-programmer, but I have been approached by a programmer who has difficulty with return types from SQL. He queries a table on the SQL-server storing many values as floating point numbers (most or all can be represented as integers). The programmer uses CAST(column_name AS INT) on several columns in his query, iterates the results (loading them into an array of variables) and prints them with an automatic string conversion: print("$colvar1; $colvar2..."). He is quite upset with my SQL-server for returning floats when he has cast his columns to int. I believe my poor SQL-server is already doing what it can, and I know that the perl programmer can make explicit casts on the assigned variables, but I'm not off the hook until the query returns integer values all around. Unless that can for some reason not be done. I might eventually be able to convince him that some formatted print method is the ideal solution, and that this is not a failure of the SQL-server. Specifications: Data source: MS SQL Server 2008 ODBC Provider: Microsoft SQL Server DSN PERL Version 5.8.7 My questions to you: A) Where is this behaviour introduced? Behaviour: Not getting the appropriate type from a CAST in SQL Suggested layers: ODBC provider, Perl runtime B) Is it possible to get appropriately typed data directly from the SQL-query? B2) How? C) What is the ideal method for fetching floating point numbers from sql and displaying them as integer values?
|