-
Is it possible to support to retrieve the last ID upon INSERT? I know MySQL supports SELECT LAST_INSERT_ID() but I was wondering the INSERT generated by sqlc can at least return the auto genereted ID |
Beta Was this translation helpful? Give feedback.
Answered by
Jille
May 2, 2022
Replies: 2 comments
-
你可以在插入时指定ID, 比如UUID 或者 其他形式的自增ID。 |
Beta Was this translation helpful? Give feedback.
0 replies
-
For Postgres you can add |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
kyleconroy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For Postgres you can add
RETURN id
to your query and use:one
. For MySQL, use:execresult
which makes your query return asql.Result
, which has aLastInsertId() (int64, error)
method.