Page 1 of 1

sql data not going in correct fields

Posted: Thu Apr 23, 2015 11:15 pm
by jalz
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

Re: sql data not going in correct fields

Posted: Thu Apr 23, 2015 11:43 pm
by MaxV
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#####

Re: sql data not going in correct fields

Posted: Fri Apr 24, 2015 6:45 pm
by jalz
Thanks MaxV.

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

Re: sql data not going in correct fields

Posted: Fri Apr 24, 2015 10:31 pm
by phaworth
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