Solved

TQuery Index Fields

Posted on 1998-11-29
9
1,894 Views
Last Modified: 2012-06-27
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
Comment
Question by:dave1968
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 1

Author Comment

by:dave1968
ID: 1348566
Adjusted points to 50
0
 
LVL 1

Expert Comment

by:Gerhard100198
ID: 1348567
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
 
LVL 1

Author Comment

by:dave1968
ID: 1348568
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
 
LVL 1

Expert Comment

by:Gerhard100198
ID: 1348569
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 3

Expert Comment

by:Stefaan
ID: 1348570
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
 
LVL 1

Author Comment

by:dave1968
ID: 1348571
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
 
LVL 3

Expert Comment

by:Stefaan
ID: 1348572
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
 
LVL 1

Author Comment

by:dave1968
ID: 1348573
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
 
LVL 1

Accepted Solution

by:
slautin earned 50 total points
ID: 1348574
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now