how do you handle async queries (i mean we do not need to read all rows before call a second query) in a Transaction
- Dominant language
- Go
- Stars
- 14.3k
- Forks
- 1.1k
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 11
Description
how do you call a nested query in a transaction ?
db is pgxpool.Pool
tx,err:=db.BeginTx(context.Background(),txOp);
then i call my function with this tx inside of my function
func (tx) {
rows tx.Query(sql)
for rows.Next() {
// //scan row and process the row and use this data to build a new query
secondRows tx.Query()
for secondRows.Next() {
//scan row and process the row during process we can update other table based on the condition
}
secondRows.Close()
}
rows.Close()
}
does it work ?
this type of operation is supported in JDBC which having multiple statements (each statement has own result set) with one db connection.
Contributor guide
Research direction
Start with the pgxpool.Pool, BeginTx, and Tx.Query flow shown in the issue, then inspect the repository's transaction and Rows behavior. Determine the supported handling of a second query while the first Rows remains open, and document the answer or limitation with a representative usage pattern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- databases
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100