query on a pipeline: the statement is queued, checked like query, and its rows come later
from take. Queue several, then take them: they share one round trip.
- p: the pipeline to queue on.
- sql: the statement, as for
query. - args: one value per
%, in order. - call: the code of the call, which lets the query text be checked while compiling. Leave the default.
p := Pg.pipeline_enter(c);
users := Pg.queue(p, "select id, name from users where id = $1", id);
count := Pg.queue_execute(p, "update users set seen = now() where id = $1", id);
rows, error := Pg.take(p, users);
changed, error = Pg.take(p, count);
Pg.pipeline_exit(p);Not run: the example is marked ignore.
Not run: it needs a PostgreSQL server.
queue :: (
p: *Pipeline,
$sql: string,
args: ..Any,
$call := #caller_code
) -> (Pending(Rows(#run row_type(sql, call, 1, #insert,scope(call) #run row_table_type(sql, call, 1, #insert,scope(call) #run row_table_exists(sql, call, 1)), Row(#run row_shape(sql, call, 1))))), Pg_Error)
query on a pipeline: the statement is queued, checked like query, and its rows come later
from take. Queue several, then take them: they share one round trip.
Not run: it needs a PostgreSQL server.
Parameters
- p: *Pipeline
- the pipeline to queue on.
- $sql: string
- the statement, as for
query. - args: ..Any
- one value per
%, in order. - $call := #caller_code
- the code of the call, which lets the query text be checked while compiling. Leave the default.
Returns
p := Pg.pipeline_enter(c);
users := Pg.queue(p, "select id, name from users where id = $1", id);
count := Pg.queue_execute(p, "update users set seen = now() where id = $1", id);
rows, error := Pg.take(p, users);
changed, error = Pg.take(p, count);
Pg.pipeline_exit(p);Not run: the example is marked ignore.