We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ToField Cursor
Hello,
I'd like to use cursors to perform an update of a very large table. Postgres allows for this kind of query:
UPDATE foo SET dataval = myval WHERE CURRENT OF curs1;
(see https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-USING)
However, I can't just do
execute [sql| UPDATE foo SET dataval = ? WHERE CURRENT OF ?|] ( myval, cursor )
because Cursor doesn't have a ToField instance. Also, I see that only the datatype of Cursor is exported
Cursor
ToField
https://hackage.haskell.org/package/postgresql-simple-0.6.5/docs/src/Database.PostgreSQL.Simple.Cursor.html#declareCursor
and not the constructor, so I can't access the name field.
name
The text was updated successfully, but these errors were encountered:
I was able to successfully run the above query with this instance:
import qualified Data.Text.Encoding as T instance ToField Cursor where toField (Cursor name _conn) = toField $ Identifier $ T.decodeUtf8 $ fromQuery name
Sorry, something went wrong.
As a side note, it would be nice if the declareCursor function allowed to accept query parameters as well.
declareCursor
[Cursor] add a ToField instance
0ee3461
Related to haskellari#113
This branch seems to work for me: https://github.com/CGenie/postgresql-simple/tree/cursor-to-field
No branches or pull requests
Hello,
I'd like to use cursors to perform an update of a very large table. Postgres allows for this kind of query:
(see https://www.postgresql.org/docs/current/plpgsql-cursors.html#PLPGSQL-CURSOR-USING)
However, I can't just do
execute [sql| UPDATE foo SET dataval = ? WHERE CURRENT OF ?|] ( myval, cursor )
because
Cursor
doesn't have aToField
instance. Also, I see that only the datatype ofCursor
is exportedhttps://hackage.haskell.org/package/postgresql-simple-0.6.5/docs/src/Database.PostgreSQL.Simple.Cursor.html#declareCursor
and not the constructor, so I can't access the
name
field.The text was updated successfully, but these errors were encountered: