Number of database records retrieved in EDB

Source: Internet
Author: User

To obtain the number of all records in a database, there is no need to read one by one and then determine how many records are successfully read.

 

EDB provides the cegetdbinformationbyhandle function, which can obtain a lot of corresponding information in the database.

This function requires two parameters. The first is the database handle, which is the handle returned when the database is opened through ceopendatabaseinsession, and the second parameter is

By_handle_db_information structure, which is defined:

Typedef struct by_handle_db_information {
WordWversion;
Word Wreserved ;
CeguidGuidvol;
CeoidOiddbase;
CedbaseinfoexInfdatabase;
} By_handle_db_information;

Before using it, initialize several of its data. wversion is used to identify the struct version. In EDB, it must be set to 2 and 1 in CEDB. Guidvol is the unique identifier of the database volume, and oiddbase is the identifier of the database. After initializing the data, you can use this function to obtain the data.

The infdatabase in the by_handle_db_information structure contains various information about the database. It isThe cedbaseinfoex type is defined as follows:

Typedef struct cedbaseinfoex {
Word Wversion;
Word Wnumsortorder;
DWORD Dwflags;
Wchar Szdbasename[Cedb_maxdbasenamelen];
DWORD Dwdbasetype;
DWORD Dwnumrecords;
DWORD Dwsize;
Filetime Ftlastmodified;
Cesortorderspec Rgsortspecs[Cedb_maxsortorder];
} Cedbaseinfoex;

 

The following code retrieves the number of records:

  1. Ceoid dboid = 0;
  2. HDB = ceopendatabaseinsession (g_hsession,
  3. & G_volguid,
  4. & Dboid,
  5. Szdbname,
  6. Null,
  7. 0,
  8. Null );
  9. By_handle_db_information bhdi = {0 };
  10. Bhdi. wversion = 2;
  11. Bhdi. guidvol = g_volguid;
  12. Bhdi. oiddbase = dboid;
  13. If (! Cegetdbinformationbyhandle (HDB, & bhdi ))
  14. {
  15. DWORD dd = getlasterror ();
  16. Return false;
  17. }

 

After the above code is executed, the number of records stored in bhdi. infdatabase. dwnumrecords is

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.