• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2051
  • Last Modified:

TQuery Index Fields

I am trying a refresh of the current record using a TQuery (trying to get an updated record). The procedure is available for a TQuery but Delphi reports: Table does not support this operation because it is not uniquely indexed.

The table (on the server) is indexed. Do I have to define indexes similar to the TTable component? If so how. I see that the TTable component has properties for indexes where as the TQuery does not.

The database is on a MySQL server using the MyODBC driver. The driver is designed well and functions well throughout Delphi.

Any help is appreciated.
0
dave1968
Asked:
dave1968
  • 4
  • 2
  • 2
  • +1
1 Solution
 
dave1968Author Commented:
Adjusted points to 50
0
 
Gerhard100198Commented:
Just a couple of questions:

1) Are you making use of a TUpdateSQL component?

2) Are your query doing a join between tables or is it a simple query?

3) Are your TQuery component set to request a live result set?

4) Which database are your TQuery connected to? (Paradox, Interbase etc).

I've come across this situation with Interbase some time ago. Using the DBExplorer it was possible to add two or more identical records to the same table even though the table was set up with a unbique key field (not to sure whether this was a DBExplorer or an Interbase bug). If you then tried to delete any one of these records by hitting the DEL key in DBExplorer you would receive the error your described above. The only way to get rid of the "duplicate entries" were to do it with an SQL statement (delete from MYTABLE where MYFIELD = 'ABC123456'). This would then remove ALL of these duplicate entries since they all have the same key value. We then had to re-enter the information for that record into the table.
0
 
dave1968Author Commented:
1. Not using TUpdateSQL, just the TQuery component.
2. Straight simple query, no joins.
3. Tried live set and not live, same error.
4. ODBC database on a SQL server.

The procedure I am calling is Query1.Refresh, which according to the documentation should refresh the record the cursor is on. I used this TQuery for a read only list, so a live set is not necessary. When I do an update to the table with a different TQuery or a different means I want to run a Query1.Refresh to get the latest data.

Query1.SQL is 'select * from items'
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Gerhard100198Commented:
1. Not using TUpdateSQL, just the TQuery component.
2. Straight simple query, no joins.
3. Tried live set and not live, same error.
4. ODBC database on a SQL server.

The procedure I am calling is Query1.Refresh, which according to the documentation should refresh the record the cursor is on. I used this TQuery for a read only list, so a live set is not necessary. When I do an update to the table with a different TQuery or a different means I want to run a Query1.Refresh to get the latest data.

Query1.SQL is 'select * from items'
0
 
StefaanCommented:
1. Not using TUpdateSQL, just the TQuery component.
2. Straight simple query, no joins.
3. Tried live set and not live, same error.
4. ODBC database on a SQL server.

The procedure I am calling is Query1.Refresh, which according to the documentation should refresh the record the cursor is on. I used this TQuery for a read only list, so a live set is not necessary. When I do an update to the table with a different TQuery or a different means I want to run a Query1.Refresh to get the latest data.

Query1.SQL is 'select * from items'
0
 
dave1968Author Commented:
1. Not using TUpdateSQL, just the TQuery component.
2. Straight simple query, no joins.
3. Tried live set and not live, same error.
4. ODBC database on a SQL server.

The procedure I am calling is Query1.Refresh, which according to the documentation should refresh the record the cursor is on. I used this TQuery for a read only list, so a live set is not necessary. When I do an update to the table with a different TQuery or a different means I want to run a Query1.Refresh to get the latest data.

Query1.SQL is 'select * from items'
0
 
StefaanCommented:
1. Not using TUpdateSQL, just the TQuery component.
2. Straight simple query, no joins.
3. Tried live set and not live, same error.
4. ODBC database on a SQL server.

The procedure I am calling is Query1.Refresh, which according to the documentation should refresh the record the cursor is on. I used this TQuery for a read only list, so a live set is not necessary. When I do an update to the table with a different TQuery or a different means I want to run a Query1.Refresh to get the latest data.

Query1.SQL is 'select * from items'
0
 
dave1968Author Commented:
1. Not using TUpdateSQL, just the TQuery component.
2. Straight simple query, no joins.
3. Tried live set and not live, same error.
4. ODBC database on a SQL server.

The procedure I am calling is Query1.Refresh, which according to the documentation should refresh the record the cursor is on. I used this TQuery for a read only list, so a live set is not necessary. When I do an update to the table with a different TQuery or a different means I want to run a Query1.Refresh to get the latest data.

Query1.SQL is 'select * from items'
0
 
slautinCommented:
1. Not using TUpdateSQL, just the TQuery component.
2. Straight simple query, no joins.
3. Tried live set and not live, same error.
4. ODBC database on a SQL server.

The procedure I am calling is Query1.Refresh, which according to the documentation should refresh the record the cursor is on. I used this TQuery for a read only list, so a live set is not necessary. When I do an update to the table with a different TQuery or a different means I want to run a Query1.Refresh to get the latest data.

Query1.SQL is "select * from items"
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now