Thanks Kevin!
and if I want to insert values from an Array?
For example:
out_table = Array(Int64,5)
sum = 0
for i in 1:5
out_table[i] = 0
sum+=1
query("INSERT INTO test(id,sum) VALUES ('$value[i]','$sum')")
end
I have this message:
LoadError("C:/julia/writeArray.jl",44,ErrorException("value not
defined"))
Thanks for your Help!
Douglas
Douglas Teixeira Goncalves
Undergraduate Student of Computer Engineering
Exchange Student of Brazilian Scientific Mobility Program
Missouri University of Science and Technology
1-573-466-3602
On Wed, Jun 4, 2014 at 8:18 PM, Kevin Squire <[email protected]> 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 executing the query
>>
>>
>> If anyone could help me it would be great!
>>
>>
>> Thank you,
>>
>>
>> Douglas
>>
>>
>