Question: Why in FIBPlus 6.5 do I get an error "COLUMN The column ... was specified multiple times for derived table unnamed." in some queries?

An example of such a query:

SELECT PAYMENTS.ID,PAYMENTS.DATE_ORDER,PAYMENTS.SERVICE_STATUS,MAIN.ID,
MAIN.CLNT,CLIENTS.ID,CLIENTS.R FROM PAYMENTS
LEFT JOIN MAIN ON PAYMENTS.ID_COMPANY=MAIN.ID
LEFT JOIN CLIENTS ON MAIN.clnt=CLIENTS.ID WHERE PAYMENTS.
SERVICE_STATUS=0 AND PAYMENTS.DATE_ORDER IS NOT NULL

This example works well everywhere (in IBExpert, console, etc).

Answer: This happens because you try to execute this query from pFIBDataset with an active poAskRecordCount option for Firebird 2.x.

If you use Firebird 2.x, poAskRecordCount uses Select Count(*) from (Select...)

In your case the query will be:

Select Count(*) from (SELECT PAYMENTS.ID,PAYMENTS.DATE_ORDER,PAYMENTS.
SERVICE_STATUS,MAIN.ID,MAIN.CLNT,CLIENTS.ID,CLIENTS.R FROM PAYMENTS
LEFT JOIN MAIN ON PAYMENTS.ID_COMPANY=MAIN.ID
LEFT JOIN CLIENTS ON MAIN.clnt=CLIENTS.ID WHERE PAYMENTS.
SERVICE_STATUS=0 AND PAYMENTS.DATE_ORDER IS NOT NULL )

As Firebird 2.x cannot execute this query, it shows the error "COLUMN The column ... was specified multiple times for derived table unnamed." In other words, this happens because the error is in the query which realises the poAskRecordCount function.

If you write the query as:

SELECT PAYMENTS.ID,PAYMENTS.DATE_ORDER,PAYMENTS.
SERVICE_STATUS,MAIN.ID ID1 ,MAIN.CLNT,CLIENTS.ID ID2,CLIENTS.R FROM PAYMENTS
LEFT JOIN MAIN ON PAYMENTS.ID_COMPANY=MAIN.ID
LEFT JOIN CLIENTS ON MAIN.clnt=CLIENTS.ID WHERE PAYMENTS.
SERVICE_STATUS=0 AND PAYMENTS.DATE_ORDER IS NOT NULL

everything will work correctly. So you should either deactivate the poAskRecordCount option in the dataset or rewrite the query.


Preview text: 
Prices in Euro:

235 (1 copy)
1250 (unlimited)

Volume discounts are available...

Navigation



FIBPlus has taken the headache out of this project. When I got the current contract, FIBPlus was included on the work computer from the client. I quickly found it easier to use and more powerful than any other Firebird component suite I had tested. When I ran into a problem setting up a persistent calculated field, the tech support people saved the day. I would also add that I tested Zeos, IBX, DBGo, UIB, and other FBconnectors.  FIBPlus outperformed all of them, and FIBPlus was run on an older machine than the others were.  That was most impressive.

>>

Frank Luke, Big Creek software, LLC
FOR CUSTOMERS
Download full versions and updates in your Personal Area