Solved

TQuery Index Fields

Posted on 1998-11-29
9
1,938 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 68
Simple Delphi Question 9 96
Open a URL with Internet Explorer in a new tab (not a new window) 1 120
Tvertscrollbox like a whatsapp layout 5 34
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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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