help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

string handling in database-2.0.1 commands


From: richard
Subject: string handling in database-2.0.1 commands
Date: Thu, 21 Feb 2013 16:29:08 +0000
User-agent: Mutt/1.5.20 (2009-06-14)

Hi all, 

I am trying to both read data from a database and to write the 
data back to the database. Reading the data puts the data into 
a cell structure "S.data" 

I may be trying to write the data back in an inefficient way, 
but in any case I seem to have a problem with string handling:

octave:59> j=1
j =  1
octave:60> a= num2str(cell2mat(S.data(j,1)));
octave:61> b= num2str(cell2mat(S.data(j,2)));
octave:62>  c= num2str(cell2mat(S.data(j,3)));
octave:63> d= num2str(cell2mat(S.data(j,4)));
octave:64>  e= num2str(cell2mat(S.data(j,5)));
octave:65> Y = ["(", a,", ", b,", " c, ", ", d, ", ", e,");"];
octave:66>  X = "insert into rome001 (year,l_pay, legion_pay, legions, 
Army_pay) values";
octave:67>  Z = strcat("\"",X, Y, "\"");
octave:68> Z
Z = "insert into rome001 (year,l_pay, legion_pay, legions, Army_pay) 
values(-27, 150, 559, 28, 15652);"
octave:69>  pq_exec_params (conn, Z);
NOTICE:  identifier "insert into rome001 (year,l_pay, legion_pay, legions, 
Army_pay) values(-27, 150, 559, 28, 15652);" will be truncated to "insert into 
rome001 (year,l_pay, legion_pay, legions, Army_pay)"
error: pq_exec_params: fatal error: ERROR:  syntax error at or near ""insert 
into rome001 (year,l_pay, legion_pay, legions, Army_pay) values(-27, 150, 559, 
28, 15652);""
LINE 1: "insert into rome001 (year,l_pay, legion_pay, legions, Army_...
        ^

I do not see why "identifier  .... will be truncated " happened. 

Is there a preferred way to write data to a database table? 
Why did this method fail? 

TIA

Richard 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]