Page 1 of 1

ERRO: List index out of bounds(0)

Posted: 03.03.2010, 17:42
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.

Posted: 04.03.2010, 16:19
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.

List index out of bounds when try select from table function

Posted: 22.02.2012, 12:48
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

Posted: 01.03.2012, 01:35
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

Posted: 05.03.2012, 13:12
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

Posted: 14.03.2012, 23:53
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

Posted: 19.03.2012, 18:53
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.

Posted: 25.04.2012, 22:00
by mdaems
I'll believe you :lol:

Committing it in testing branch now.

Mark