Hola a todos.
Estoy haciendo una aplicación que debe funcionar en MySql / Firebird / SQLite3
mediante D-7, ZeosDBO 6.6.6 estable y Firebird Server 2.5.1
Intento hacer ésta consulta para Firebird
Código SQL
[-]
SELECT COUNT(*) AS existe
FROM rdb$relations
WHERE rdb$relation_name = 'MITABLA'
AND rdb$view_blr is null
AND (rdb$system_flag is null OR rdb$system_flag=0);
y obtengo éste error:
raised exception class EAccessViolation with message 'Access violation at address 00000000'.
La dichosa consulta debe devolver la existencia de una tabla (es este caso MITABLA) y la creo con esta función:
Código Delphi
[-]
function FIREBIRD_ExisteTabla( ZQuery:TZQuery; TableName:string;
PathSqlError:string ):boolean;
begin
Result := false;
with ZQuery do begin
Active := false;
SQL.Clear;
SQL.Add( 'SELECT COUNT(*) AS existe' );
SQL.Add( ' FROM rdb$relations' );
SQL.Add( ' WHERE rdb$relation_name = '''+UpperCase(TableName)+'''' );
SQL.Add( ' AND rdb$view_blr is null' );
SQL.Add( ' AND (rdb$system_flag is null OR rdb$system_flag=0);' );
try
Open; <------ AQUÍ "CASCA"
Result := ( FieldByName('EXISTE').AsInteger>0 );
Close;
except
SQL.SaveToFile( PathSqlError+'\ERROR_FIREBIRD_ExisteTabla_'+TableName+'.sql' );
end;
end;
end;
¿Podeis decirme qué estoy haciendo mal?
La consulta es adaptada de
esta que encontré en internet.
Gracias de antemano
salvica