pg.ddx.io pgsql-odbc@postgresql.org mailing list archive
help / color / mirror / Atom feedget number of rows selected
4+ messages / 4 participants
[nested] [flat]
* get number of rows selected
@ 2008-04-03 13:20 Malm Paul <paul.malm@saabgroup.com>
2008-04-03 16:30 ` Re: get number of rows selected Adam M <gnuman1@gmail.com>
2010-03-10 15:10 ` Re: get number of rows selected VitaliyG <vitaliygrabchuk@gmail.com>
0 siblings, 2 replies; 4+ messages in thread
From: Malm Paul @ 2008-04-03 13:20 UTC (permalink / raw)
To: pgsql-odbc
Hi,
I dont know much about databases, and I have a question
I've just installed PostgreSLQ.
Now I would like to get the number of rows selected via a ODBC SQL
statement in C++. I would like to know the amount before I do Fetch.
This is a little example of what I do in c++:
selStr="select * from layer where visible = 1");
rc = SQLAllocHandle(SQL_HANDLE_STMT, ConHandle, &StmtHandle);
if(rc == SQL_SUCCESS)
{
SQLSetStmtOption(StmtHandle, SQL_CONCURRENCY,
SQL_CONCUR_READ_ONLY);
SQLSetStmtOption(StmtHandle, SQL_CURSOR_TYPE,
SQL_CURSOR_KEYSET_DRIVEN);
SQLSetStmtOption(StmtHandle, SQL_ROWSET_SIZE, m_rows);
rc = SQLExecDirect(StmtHandle, (SQLCHAR *)selStr,
SQL_NTS);
...
...
...
How do I know how many rows that was found??
Kind regards,
Paul Malm
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: get number of rows selected
2008-04-03 13:20 get number of rows selected Malm Paul <paul.malm@saabgroup.com>
@ 2008-04-03 16:30 ` Adam M <gnuman1@gmail.com>
2008-04-07 01:30 ` Re: get number of rows selected Andrei Kovalevski <andyk@commandprompt.com>
1 sibling, 1 reply; 4+ messages in thread
From: Adam M @ 2008-04-03 16:30 UTC (permalink / raw)
To: pgsql-odbc
Generally you would do that with a count function instead of relying
on something else.
"select * from layer where visible = 1"
so I guess "SELECT COUNT(*) FROM layer WHERE visible=1" would give you
the answer.
- Adam
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: get number of rows selected
2008-04-03 13:20 get number of rows selected Malm Paul <paul.malm@saabgroup.com>
2008-04-03 16:30 ` Re: get number of rows selected Adam M <gnuman1@gmail.com>
@ 2008-04-07 01:30 ` Andrei Kovalevski <andyk@commandprompt.com>
0 siblings, 0 replies; 4+ messages in thread
From: Andrei Kovalevski @ 2008-04-07 01:30 UTC (permalink / raw)
To: pgsql-odbc; +Cc: Adam M <gnuman1@gmail.com>; Malm Paul <paul.malm@saabgroup.com>
Hello,
Take a look at SQLRowCount(
http://msdn2.microsoft.com/en-us/library//ms711835.aspx ). You may note:
*/For other statements and functions, the driver may define the value
returned in *RowCountPtr. For example, some data sources may be able to
return the number of rows returned by a SELECT statement or a catalog
function before fetching the rows./*
You may rely on this when using psqlODBC or ODBCng with buffering mode
ON (default).
Adam M wrote:
> Generally you would do that with a count function instead of relying
> on something else.
>
> "select * from layer where visible = 1"
>
> so I guess "SELECT COUNT(*) FROM layer WHERE visible=1" would give you
> the answer.
>
> - Adam
>
--
Andrei Kovalevski
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Managed Services, Shared and Dedicated Hosting
Co-Authors: plPHP, ODBCng - http://www.commandprompt.com/
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: get number of rows selected
2008-04-03 13:20 get number of rows selected Malm Paul <paul.malm@saabgroup.com>
@ 2010-03-10 15:10 ` VitaliyG <vitaliygrabchuk@gmail.com>
1 sibling, 0 replies; 4+ messages in thread
From: VitaliyG @ 2010-03-10 15:10 UTC (permalink / raw)
To: pgsql-odbc
paul malm wrote:
>
>
> Hi,
> I dont know much about databases, and I have a question
>
> I've just installed PostgreSLQ.
> Now I would like to get the number of rows selected via a ODBC SQL
> statement in C++. I would like to know the amount before I do Fetch.
>
> This is a little example of what I do in c++:
>
> selStr="select * from layer where visible = 1");
> rc = SQLAllocHandle(SQL_HANDLE_STMT, ConHandle, &StmtHandle);
> if(rc == SQL_SUCCESS)
> {
> SQLSetStmtOption(StmtHandle, SQL_CONCURRENCY,
> SQL_CONCUR_READ_ONLY);
> SQLSetStmtOption(StmtHandle, SQL_CURSOR_TYPE,
> SQL_CURSOR_KEYSET_DRIVEN);
> SQLSetStmtOption(StmtHandle, SQL_ROWSET_SIZE, m_rows);
> rc = SQLExecDirect(StmtHandle, (SQLCHAR *)selStr,
> SQL_NTS);
> ...
> ...
> ...
> How do I know how many rows that was found??
>
>
> Kind regards,
>
> Paul Malm
>
>
>
Use SQLRowCount ODBC function
--
View this message in context: http://old.nabble.com/get-number-of-rows-selected-tp16475169p27851040.html
Sent from the PostgreSQL - odbc mailing list archive at Nabble.com.
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2010-03-10 15:10 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2008-04-03 13:20 get number of rows selected Malm Paul <paul.malm@saabgroup.com>
2008-04-03 16:30 ` Adam M <gnuman1@gmail.com>
2008-04-07 01:30 ` Andrei Kovalevski <andyk@commandprompt.com>
2010-03-10 15:10 ` VitaliyG <vitaliygrabchuk@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox