Message-ID: From: "siga0984 (@siga0984)" To: "postgresql-interfaces/psqlodbc" Date: Tue, 08 Apr 2025 18:07:14 +0000 Subject: Re: [postgresql-interfaces/psqlodbc] issue #102: Statement using WITH and INSERT does not work when UseDeclareFetch=1 In-Reply-To: References: List-Id: X-GitHub-Author-Login: siga0984 X-GitHub-Comment-Id: 2787274507 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 102 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/issues/102#issuecomment-2787274507 Content-Type: text/plain; charset=utf-8 I think this is the important slice ... ODBC tries do declare a cursor with the entire statement ... ``` 2025-04-08 15:00:09.516 -03 [30972] DEPURAÇÃO: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 2025-04-08 15:00:09.516 -03 [30972] COMANDO: BEGIN;declare "SQL_CUR000001FF38302570" cursor with hold for WITH TRB(CAMPO) AS ( SELECT CAMPO FROM ORIGEM ) INSERT INTO DESTINO(CAMPO) SELECT CAMPO FROM TRB;fetch 100 in "SQL_CUR000001FF38302570" 2025-04-08 15:00:09.516 -03 [30972] ERRO: erro de sintaxe em ou pr?imo a "INSERT" no caractere 110 2025-04-08 15:00:09.516 -03 [30972] COMANDO: BEGIN;declare "SQL_CUR000001FF38302570" cursor with hold for WITH TRB(CAMPO) AS ( SELECT CAMPO FROM ORIGEM ) INSERT INTO DESTINO(CAMPO) SELECT CAMPO FROM TRB;fetch 100 in "SQL_CUR000001FF38302570" 2025-04-08 15:00:09.524 -03 [26044] DEPURAÇÃO: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 2025-04-08 15:00:09.524 -03 [26044] COMANDO: delete from top_param where param_session = 26044 2025-04-08 15:00:09.525 -03 [30972] DEPURAÇÃO: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 2025-04-08 15:00:09.525 -03 [30972] COMANDO: delete from top_param where param_session = 30972 2025-04-08 15:00:09.526 -03 [26044] DEPURAÇÃO: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0 (used) 2025-04-08 15:00:09.526 -03 [26044] COMANDO: delete from top_param where param_session = 26044 ```