Sujet : Re: The joy of FORTRAN
De : ${send-direct-email-to-news1021-at-jusme-dot-com-if-you-must} (at) *nospam* jusme.com (Ian)
Groupes : alt.folklore.computers comp.os.linux.miscDate : 04. Mar 2025, 19:20:51
Autres entêtes
Organisation : Wet Socks!
Message-ID : <slrnvseh43.41d.${send-direct-email-to-news1021-at-jusme-dot-com-if@vm46.home.jusme.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13
User-Agent : slrn/1.0.3 (Linux)
On 2025-03-04, Scott Lurndal <
scott@slp53.sl.home> wrote:
The Natural Philosopher <tnp@invalid.invalid> writes:
On 04/03/2025 04:02, c186282 wrote:
...
As I pointed out, sprintf and fprintf dont take structure pointers as an
argument.
if you have never programmed SQL or CSV type data, you wouldnt understand.
An SQL insert or update statement consists (for safety) in a series of
>
'update[insert into] table 'hogwash' set blah = 'x', poo = 'y'
....[where id=BigNum]'
>
statements...
>
That string needs to be constructed. You do not want to break it down
into 60 short strings and 60 database accesses
>
You don't have to. Build the string piecemeal and send the
final string to the DBMS.
And you shoudn't really be passing query data with parameters embedded in
text strings, unless you're a friend of Mr. Robert D. Tables.
E.g. with the Postgres C API you can pass a query string with positional
placeholders, and an array of values:
const char * sql_values[] =
{
uuid.c_str(),
config.data(),
label.c_str()
};
res = PQexecParams( pg_dp_conn,
"insert into config(uuid,config,label) values($1,$2,$3)",
sizeof( sql_values ) / sizeof( sql_values[0] ),
...
};
(Would be nicer to have a proper C++ API, but...)
-- Ian"Tamahome!!!" - "Miaka!!!"