Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Switch from String to Integer

Status
Not open for further replies.

sthames

Technical User
Apr 2, 2004
9
0
0
US
Hello. I hope someone can help me with this issue as it has been driving me bonkers.

I am using the Net::Telnet module to brings in a lines of text that looks kind of like this

 (Bob Kastle)  1708 CN  215 ID  10:08A 4-10-04  000 LB  262993 LB T0

Currently I just assign each item into a variable, and then use substr() to remove the spaces and the Units(CN, ID,LB)

Then I insert the data into an access database using a line like

$database->Sql("Insert INTO TheData (Count,UserID,MyTime,Usage,Total) VALUES ('$i1','$i2','$i3','$i4','$i5')");

My problem is that I have to set the database columns to Strings otherwise it fails. I need to do calculations on the data so I want to store the numerical values in the database as integers. Is there a way to force the variables to integers before pushing them into the database? Or is there a way I can fix this bit of code to make it work better.

I greatly appreciate any help.

Thanks!

Shawn
 
just a thought, vut try to put them inside scalar()......

___________________________________
[morse]--... ...--[/morse], Eric.
 
Well, I do not know the sql perl module, but why do you put your $i variables between single quotes ? Whatever values they have in perl, from sql point of view it makes them string values.
Have you tried this :
Code:
$database->Sql("Insert INTO TheData (Count,UserID,MyTime,Usage,Total) VALUES ([COLOR=blue]$i1,$i2,$i3,$i4,$i5[/color])");

--------------------

Denis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top