[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string handling in database-2.0.1 commands
From: |
Olaf Till |
Subject: |
Re: string handling in database-2.0.1 commands |
Date: |
Fri, 22 Feb 2013 21:57:17 +0100 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
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.
Olaf
--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net
signature.asc
Description: Digital signature