CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
SQL query return types

 



FDARI
New User

Mar 30, 2011, 6:22 AM

Post #1 of 2 (4179 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?


FishMonger
Veteran / Moderator

Mar 30, 2011, 8:17 AM

Post #2 of 2 (4174 views)
Re: [FDARI] SQL query return types [In reply to] Can't Post

See my answer on your cross post.
http://forums.devshed.com/perl-programming-6/forcing-sql-query-return-types-dbi-801271.html

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives