Next: Composite types, Previous: Large objects, Up: Examples [Index]
# connect
conn = pq_connect (setdbopts ("dbname", "test"));
# create table
pq_exec_params (conn,
"create table testdata (a float8, b float8, label text);")
# generate data in Octave
data = horzcat (num2cell (reshape (linspace (3, 4, 10), [], 2)),
{"a"; "b"; "c"; "d"; "e"})
# copy in to the table
pq_exec_params (conn, "copy testdata from stdin with (format binary);",
setdbopts ("copy_in_from_variable", true,
"copy_in_data", data))
# retrieve the data from the table
rdata = pq_exec_params (conn, "select * from testdata;").data
# cleanup
pq_exec_params (conn, "drop table testdata;");
pq_close (conn);