ERRO: List index out of bounds(0)

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
celsohenrique
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 03.03.2010, 17:35
Location: Brazil

ERRO: List index out of bounds(0)

Post by celsohenrique »

Olá a todos,

quando eu tento executar o comando abaixo, o sistema me exibe a mensagem: "List index out of bounds(0)".

Code: Select all

SELECT 
	DISTINCT
	CAST(EST_PROD.CD_UN_CP AS VARCHAR) + 'CP' AS UNID
	, EST_PROD_UN_MED.DS_UN AS DESCR
FROM 
	EST_NF_ENT_IT
	INNER JOIN EST_PROD ON
		EST_NF_ENT_IT.CD_EMP      = EST_PROD.CD_EMP
		AND EST_NF_ENT_IT.CD_PROD = EST_PROD.CD_PROD
	INNER JOIN EST_PROD_UN_MED ON
		EST_PROD.CD_EMP       = EST_PROD_UN_MED.CD_EMP
		AND EST_PROD.CD_UN_CP = EST_PROD_UN_MED.CD_CTR_UN
	INNER JOIN UFD_EST_NF_ENT_EXP_EF (1, 8,  '2008-01-01' , '2008-01-10' ) AS UFD_EST_NF_ENT_EXP_EF ON
		UFD_EST_NF_ENT_EXP_EF.CD_EMP        = EST_NF_ENT_IT.CD_EMP
		AND UFD_EST_NF_ENT_EXP_EF.CD_FILIAL = EST_NF_ENT_IT.CD_FILIAL
		AND UFD_EST_NF_ENT_EXP_EF.CD_NF     = EST_NF_ENT_IT.CD_NF
WHERE
	UFD_EST_NF_ENT_EXP_EF.POSSUI_PROD  = 0
	AND UFD_EST_NF_ENT_EXP_EF.STS_NF  <> 'CANCELADA'
	AND UFD_EST_NF_ENT_EXP_EF.TP_FORN IN (0, 2, 3, 4, 6)
Porém, se eu mudar de:

Code: Select all

CAST(EST_PROD.CD_UN_CP AS VARCHAR) + 'CP' AS UNID
para:

Code: Select all

EST_PROD.CD_UN_CP AS UNID
O erro pára de acontecer.

Estou usando o Delphi 2007, Zeos 6.6.5-stable e o MS-SQL 2005.
celsohenrique
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 03.03.2010, 17:35
Location: Brazil

Post by celsohenrique »

Translated by Google:

Sorry people,

I can not speak English. The problem is that I'm using a function like a table (UFD_EST_NF_ENT_EXP_EF), then in the TZQuery, I can not reference a field that function and not create a new field.

When I try, the system shows me this error: "List index out of bounds(0)"

I'm using: Delphi2007, Zeos 6.6.5-stable and MS-SQL 2005.
paweld
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 22.02.2012, 12:41

List index out of bounds when try select from table function

Post by paweld »

When try select query from table-value function, get error: List index out of bounds. Error occurs on MSSQL 2000, 2005, 2008 and 2008r2.
Problem is in file "ZDbcDbLibMsSqlMetadata.pas". Patch from attachment solves the problem.

http://zeosbugs.firmos.at/view.php?id=255
You do not have the required permissions to view the files attached to this post.
Best regards
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

paweld,
I'm wondering where you have found the original code line... 'sysobjects o on (o.id = c.id) where o.name = %s and c.number=0'. Maybe I'm just seeing over it... What's your exact zeoslib 6.6 version? Can you browse the code in the 6.6-patches branch and trunk on sourceforge to check if the code there is right or wrong?

Mark
Image
paweld
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 22.02.2012, 12:41

Post by paweld »

mdaems wrote:paweld,
I'm wondering where you have found the original code line... 'sysobjects o on (o.id = c.id) where o.name = %s and c.number=0'. Maybe I'm just seeing over it... What's your exact zeoslib 6.6 version? Can you browse the code in the 6.6-patches branch and trunk on sourceforge to check if the code there is right or wrong?

Mark
File ZDbcDbLibMsSqlMetadata.pas, line: 1646-1648 (ver 7 rev 1055), line 1545-1547 (ver 6.6.6 rev 961).

In attachment example lazarus project.

Best regards
Paweł Dmitruk
You do not have the required permissions to view the files attached to this post.
Best regards
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

OK, found the code. But you made your patch from new version to old version, so it's an inverted patch.

But just looking to your patch makes me worry: wouldn't that only return 1 column for all tables? Adding 'and c.number = 0' looks to me 'allow only 1 column for each table in the resultset'. Can you explain me the way this query works?

Mark
Image
paweld
Fresh Boarder
Fresh Boarder
Posts: 5
Joined: 22.02.2012, 12:41

Post by paweld »

mdaems wrote:OK, found the code. But you made your patch from new version to old version, so it's an inverted patch.
sorry, first patch.
mdaems wrote:But just looking to your patch makes me worry: wouldn't that only return 1 column for all tables? Adding 'and c.number = 0' looks to me 'allow only 1 column for each table in the resultset'. Can you explain me the way this query works?
this condition return only columns. if syscolumns.number>0 then this field is procedure/function param.
Best regards
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

I'll believe you :lol:

Committing it in testing branch now.

Mark
Image
Post Reply