Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Ticket #900 (closed defect: fixed)

Opened 4 months ago

Last modified 4 months ago

On startup, application throws "Column count doesn't match value count at row 1" error

Reported by: jmiranda Assigned to: jmiranda
Priority: major Milestone: OpenMRS 1.3
Component: OpenMRS Code Base Keywords:
Cc: Introductory Ticket:

Description

I just encountered an old bug ("Column count doesn't match value count at row 1") that occurs when your OpenMRS database schema contains an extra column that the application is not aware of. This occurs (for me) when I use the sync data model (most tables have an extra column for GUID) with the latest version of the OpenMRS application.

If you see an error like the following, it's due to the fact that there's SQL that uses SELECT or INSERT without explicitly referring to columns by name.

ERROR - HibernateContextDAO.checkCoreDataset(304) |2008-07-09 14:02:11,203| Error while setting core privileges java.sql.SQLException: Column count doesn't match value count at row 1

The problem occurs due to the following SQL statements:

psSelect = conn.prepareStatement("SELECT * FROM role WHERE UPPER(role) = UPPER(?)"); psInsert = conn.prepareStatement("INSERT INTO role VALUES (?, ?)");

THE POINT: This particular bug should not concern most developers as you're most likely using the most current version of the data model (which is consistent with the source code). In other words, if you're not using sync then you probably won't run into these issues.

However, I just wanted to remind all developers to make all column references explicit (see below). That should help keep this issue from popping up and will also improve performance of those queries (albeit, only slightly)

psSelect = conn.prepareStatement("SELECT role, description FROM role WHERE UPPER(role) = UPPER(?)"); psInsert = conn.prepareStatement("INSERT INTO role (role, description) VALUES (?, ?)");

Change History

07/16/08 13:25:53 changed by bwolfe

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone changed from OpenMRS 1.4 to OpenMRS 1.3.

Fixed in [4943]