postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: davecramer (@davecramer) <[email protected]>
To: postgresql-interfaces/psqlodbc <[email protected]>
Subject: Re: [postgresql-interfaces/psqlodbc] issue #43: syntax error at or near "ROWS"
Date: Fri, 20 Sep 2024 15:17:12 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
So I wrote some code and test this. Slightly different table works fine.
```
create table serversession("Id" serial , "Begin" int4, "End" int4, logfile text);
```
```
rc = SQLExecDirect(hstmt, (SQLCHAR *) "SET intervalstyle=postgres_verbose", SQL_NTS);
/* Prepare a statement */
rc = SQLPrepare(hstmt, (SQLCHAR *) "SELECT \"Id\",\"Begin\",\"End\",\"Logfile\" FROM ServerSession ORDER BY \"Begin\" ASC OFFSET ? ROWS FETCH FIRST ? ROW ONLY", SQL_NTS);
CHECK_STMT_RESULT(rc, "SQLPrepare failed", hstmt);
/* bind param */
longparam1 = 0;
cbParam1 = sizeof(longparam1);
rc = SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT,
SQL_C_SLONG, /* value type */
SQL_INTEGER, /* param type */
0, /* column size (ignored for SQL_INTEGER) */
0, /* dec digits */
&longparam1, /* param value ptr */
sizeof(longparam1), /* buffer len (ignored for SQL_INTEGER) */
&cbParam1 /* StrLen_or_IndPtr (ignored for SQL_INTEGER) */);
CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
/* bind param */
longparam2 = 3;
cbParam2 = sizeof(longparam2);
rc = SQLBindParameter(hstmt, 2, SQL_PARAM_INPUT,
SQL_C_SLONG, /* value type */
SQL_INTEGER, /* param type */
0, /* column size (ignored for SQL_INTEGER) */
0, /* dec digits */
&longparam2, /* param value ptr */
sizeof(longparam2), /* buffer len (ignored for SQL_INTEGER) */
&cbParam2 /* StrLen_or_IndPtr (ignored for SQL_INTEGER) */);
CHECK_STMT_RESULT(rc, "SQLBindParameter failed", hstmt);
/* Test SQLNumResultCols, called before SQLExecute() */
rc = SQLNumResultCols(hstmt, &colcount);
CHECK_STMT_RESULT(rc, "SQLNumResultCols failed", hstmt);
printf("# of result cols: %d\n", colcount);
/* Execute */
rc = SQLExecute(hstmt);
CHECK_STMT_RESULT(rc, "SQLExecute failed", hstmt);
/* Fetch result */
print_result(hstmt);
rc = SQLFreeStmt(hstmt, SQL_CLOSE);
CHECK_STMT_RESULT(rc, "SQLFreeStmt failed", hstmt);
/* Clean up */
test_disconnect();
```
view thread (14+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://postgresql-interfaces/psqlodbc
Cc: [email protected], [email protected]
Subject: Re: [postgresql-interfaces/psqlodbc] issue #43: syntax error at or near "ROWS"
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox