Empty data source returning a relation error
Posted: Tue Aug 22, 2017 2:46 pm
Hello,
I had a problem using relations in data sources, when the sql of a data source return 0 rows and the data source has a relation with other data source, the software return an error, but it should just print the report clean, with out the databand that is using the data source, just the page header and the page footer.
In my case the data source 'servidor' return 0 rows when the variables 'matricula' and 'nome' don't exist in the database, but the user could enter an invalid value to the report.
The images above show the data sources and the relation between then, and the error that i had.
SQL data source 'servidor':
SELECT
T1001_Matricula_Fun,
T1001_Nome_Fun,
LPAD(T1001_CPF_Fun, 11 ,'0') as T1001_CPF_Fun,
IF(T1001_Flag_Portador_Doenca = 'S' OR T1001_Classe_Fun = 'Auxílio Doença', 'Sim', 'Não')
as IsentoIR,
(select Count(*) from tab09003 WHERE T9003_Matricula_Fun=T1001_Matricula_Fun) as
qtdDependentes,
T1001_Data_Admissao,
T1001_Data_Nasc,
T1001_Regra_Aposentadoria
FROM tab01001
WHERE
exists(
SELECT
*
FROM tab01024
WHERE
T1024_Matricula_Fun=T1001_Matricula_Fun
AND T1024_Competencia = '{referencia}'
)
AND IF(LENGTH('{nome}') > 0, T1001_Nome_Fun LIKE CONCAT('%',TRIM('{nome}'),'%'), 0 = 0)
AND IF('{matricula}' <> 0, '{matricula}' = T1001_Matricula_Fun, 0 = 0)
I had a problem using relations in data sources, when the sql of a data source return 0 rows and the data source has a relation with other data source, the software return an error, but it should just print the report clean, with out the databand that is using the data source, just the page header and the page footer.
In my case the data source 'servidor' return 0 rows when the variables 'matricula' and 'nome' don't exist in the database, but the user could enter an invalid value to the report.
The images above show the data sources and the relation between then, and the error that i had.
SQL data source 'servidor':
SELECT
T1001_Matricula_Fun,
T1001_Nome_Fun,
LPAD(T1001_CPF_Fun, 11 ,'0') as T1001_CPF_Fun,
IF(T1001_Flag_Portador_Doenca = 'S' OR T1001_Classe_Fun = 'Auxílio Doença', 'Sim', 'Não')
as IsentoIR,
(select Count(*) from tab09003 WHERE T9003_Matricula_Fun=T1001_Matricula_Fun) as
qtdDependentes,
T1001_Data_Admissao,
T1001_Data_Nasc,
T1001_Regra_Aposentadoria
FROM tab01001
WHERE
exists(
SELECT
*
FROM tab01024
WHERE
T1024_Matricula_Fun=T1001_Matricula_Fun
AND T1024_Competencia = '{referencia}'
)
AND IF(LENGTH('{nome}') > 0, T1001_Nome_Fun LIKE CONCAT('%',TRIM('{nome}'),'%'), 0 = 0)
AND IF('{matricula}' <> 0, '{matricula}' = T1001_Matricula_Fun, 0 = 0)