Skip to content

No examples or support for select count(*) #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
acidtonic opened this issue May 19, 2021 · 1 comment
Open

No examples or support for select count(*) #2

acidtonic opened this issue May 19, 2021 · 1 comment

Comments

@acidtonic
Copy link

acidtonic commented May 19, 2021

I have looked all over for an example to simply do a basic select COUNT(*) query.

After wasting a good hour without any success, I'm throwing in the towel.

  QUERY(getAllUsersCount,
        "SELECT COUNT(*) FROM \"AppUser\";")

Over in the service....


  auto dbCountResult = m_database_postgres->getAllUsersCount();
  OATPP_ASSERT_HTTP(dbCountResult->isSuccess(), Status::CODE_500, dbCountResult->getErrorMessage());

Fails with error I can't have anything that's not a container.


  auto total_count = dbCountResult->fetch<oatpp::data::mapping::type::UInt32>(); 
  auto total_count_list = dbCountResult->fetch<oatpp::Vector<oatpp::Fields<oatpp::Any>>>(); 
  auto total_count_list = dbCountResult->fetch<oatpp::Vector<oatpp::Fields< oatpp::UInt32>>>(); 

Fails when I try to iterate the result, no methods begin/end and for each not working. Plus I expect one answer not many.

Why is this so hard?

@lganzzzo
Copy link
Member

Hello @acidtonic ,

Please see this answer - oatpp/oatpp-sqlite#9 (comment)
Fro Postgres it works the same way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants