help-octave
[Top][All Lists]
Advanced

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

Re: string handling in database-2.0.1 commands


From: richard
Subject: Re: string handling in database-2.0.1 commands
Date: Fri, 22 Feb 2013 21:49:39 +0000
User-agent: Mutt/1.5.20 (2009-06-14)

On Fri, Feb 22, 2013 at 09:57:17PM +0100, Olaf Till wrote:
> On Fri, Feb 22, 2013 at 06:55:22PM +0000, richard wrote:
> > On Thu, Feb 21, 2013 at 06:47:58PM +0100, Olaf Till wrote:
> >  
> > > While constructing strings from Octave valules (with cstrcat or
> > > better, with sprintf) will work, I'd say the 'preferred' way is to use
> > > placeholders ($..), as explained in the help-text of pq_exec_params.
> > > 
> > > Example:
> > > 
> > > data = S.data;
> > > 
> > > pq_exec_params (conn, "insert into rome001 (year, l_pay) values ($1, 
> > > $2);", {data(1, 1), data(1, 2)});
> > > 
> > I tried your example, with a slight modification for my test: 
> > pq_exec_params (conn, "insert into rome001 (year, l_pay, legion_pay, 
> > legions, Army_pay) values ($1, $2, $3, $4, $5);", {data(1, 1), data(1, 2), 
> > data(1, 3), data(1, 4), data(1, 5)});
> > #error: could not determine postgresql type for Octave parameter
> 
> Sorry, I have a typo in my example, of corse you need curled braces
> (data{1, 1}, and so on) to access the cell elements.
> 
Thanks - with a couple of changes, this works : 
j=1; 
pq_exec_params (conn,"insert into rome001 (year,l_pay, legion_pay, legions, 
Army_pay) values($1, $2, $3, $4, $5)", 
{data{j,1},data{j,2},data{j,3},data{j,4},data{j,5}});

many thanks 

Richard



reply via email to

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