sql data not going in correct fields

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

sql data not going in correct fields

Post by jalz » Thu Apr 23, 2015 11:15 pm

Hi Guys,

I've got the following sql statement which seems to be executing correcting. When I walk through the debugger, the tTheData has the following contents in it [7847400 110000] which is correct. The problem I am having is trying to put that returned data into the appropriate fields. I'm using tab to separate the data but the command put item 1 of tTheData into field "fld_estimate_sales" just doesn't seem to working right. Ami I missing something as usual

Code: Select all

   put field "fld_project_id" into tProjectID
   
   put "SELECT sum(el.estimate_line_price), sum(el.estimate_hours)" &\
   "FROM estimate e " &\
   "LEFT JOIN estimate_line el " &\
   "ON e.estimateID=el.estimateID " &\
   "WHERE e.projectID=" & tProjectID & " AND el.optional='false'" into tTheSQLQuery
   put revDataFromQuery(tab, cr, gConnID, tTheSQLQuery) into tTheData
   
   put item 1 of tTheData into field "fld_estimate_sales"
   put item 2 of tTheData into field "fld_estimate_time" 

Thanks
Jalz

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: sql data not going in correct fields

Post by MaxV » Thu Apr 23, 2015 11:43 pm

Items are separated by comma (,).
I suggest you to change itemdel. Example:
########CODE#######
put field "fld_project_id" into tProjectID

put "SELECT sum(el.estimate_line_price), sum(el.estimate_hours) FROM estimate e LEFT JOIN estimate_line el ON e.estimateID=el.estimateID WHERE e.projectID=" & tProjectID & " AND el.optional='false'" into tTheSQLQuery
put revDataFromQuery(tab, cr, gConnID, tTheSQLQuery) into tTheData

set itemdel to TAB

put item 1 of tTheData into field "fld_estimate_sales"
put item 2 of tTheData into field "fld_estimate_time"
#####END OF CODE#####
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

jalz
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 340
Joined: Fri Sep 12, 2008 11:04 pm

Re: sql data not going in correct fields

Post by jalz » Fri Apr 24, 2015 6:45 pm

Thanks MaxV.

Can't believe I missed the item del to tab out. Arghhhhh

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Re: sql data not going in correct fields

Post by phaworth » Fri Apr 24, 2015 10:31 pm

If you're sure the data will always be number and will not contain commas, try:

put revDataFromQuery(comma, cr, gConnID, tTheSQLQuery) into tTheData

No need to set the itemdelimiter then

Pete

Post Reply