Takusen. PostrgeSQL inserts - are they possible ?

Alistair Bayley alistair at abayley.org
Mon Mar 31 00:47:40 EDT 2008

> execCommand db "INSERT INTO dmlTest.t (realVal, dblVal) VALUES (?,?)"
> [newBindVal (10.1::Float), newBindVal (1023.6::Double)]
> or something like:
> dmlStatement = "INSERT INTO dmlTest.t (realVal, dblVal) VALUES (?,?)"
> bindTypes = [bindType (undefined::Float), bindType (undefined::Double)]
> bindParams = [bindP (10.1::Float), bindP (1023::Double)]
> in
>  withPreparedStatement (prepareCommand "test" (sql dmlStatement)
> bindTypes) $ \pstmt ->
>    withBoundStatement pstmt bindParams $ \bstmt -> execDML bstmt
> lead to the "Segmentation fault/access violation in generated code" crash.

You are right; there are gaps in the docs for the DML operations.
However, there is a note in the first section ("Usage"):

 - for a DML command with bind variables:
      cmdbind "insert into ..." [bindP ..., bindP ...]

  cmdbind "INSERT INTO dmlTest.t (realVal, dblVal) VALUES (?,?)"
    [ bindP (10.1::Float), bindP (1023::Double)]

Let me know if this works for you or not.

If you want to use the withPreparedStatement+withBoundStatement combo,
then you need to be aware that the bound statement has already been
executed when it is passed to the action that is the last argument of
withBoundStatement (this seems to be a significant omission from the
docs). So, you don't need to do execDML bstmt; a return () should


More information about the Libraries mailing list