Glad you got it to work! Cheers, Kevin
On Wednesday, June 4, 2014, Douglas Teixeira Goncalves <[email protected] <javascript:_e(%7B%7D,'cvml','[email protected]');>> wrote: > It worked with: > > out_table = Array(Int64,5) >> >> sum = 0 >> >> value = 0 > >> >> for i in 1:5 >> >> out_table[i] = 0 >> >> sum+=1 >> >> value = out_table[i] > >> query("INSERT INTO test(id,soma) VALUES ('$value','$sum')") >> >> end >> >> > Thanks! > > On Wednesday, June 4, 2014 9:11:11 PM UTC-7, Douglas Teixeira Goncalves > wrote: > > Thanks Kevin! > > and if I want to insert values from an Array? > > out_table = Array(Int64,5) > > sum = 0 > > > > > for i in 1:5 > > out_table[i] = 0 > > sum+=1 > > > > query("INSERT INTO test(id,soma) VALUES ('$out_table[i]','$sum')") > > end > > > I got this message: [ODBC] 22P02: ERROR: invalid input syntax for integer: "0 > > 539041008 > > 539044752 > > 389747888 > > 539005488 > > [i]"; > > Error while executing the query > > > Thanks for your time! > > > Douglas > > > On Wednesday, June 4, 2014 8:18:36 PM UTC-7, Kevin Squire wrote: > > Hi Douglas, > > The value you are passing to query is just a string in Julia, so while the > SQL engine will treat those like variables, it has no access to the Julia > values for those variables. You'll have to put those values into the > string itself. > > Fortunately, that's easy to do--just add a '$' before "value" and "sum". > Check out http://julia.readthedocs.org/en/latest/manual/strings/# > interpolation for more information. > > Cheers, > Kevin > > > On Wed, Jun 4, 2014 at 6:02 PM, Douglas Teixeira Goncalves <[email protected]> > wrote: > > Hi guys, > > I've tried to insert some values into a table (postgres) > > I was successful when I put: > > query("INSERT INTO sum_access(contact_id,sum_reg) VALUES ('1','10')") > > > But, when I replace the integer values for variables like: > > > value = 10 > > sum = 15 > > > query("INSERT INTO sum_access(contact_id,sum_reg) VALUES ('value','sum')") > > > it doesn't work. The message error is: [ODBC] 22P02: ERROR: invalid input > syntax for integer: "value"; > > Error while > >
