Hi again! Seems like this was more complicated than that, sorry to bring this issue again. I’m trying to open the table vReportQuery, but I get this error:
The data content could not be loaded. at /run/build/libreoffice/connectivity/source/commontools/dbtools.cxx:746
Error code: 1
firebird_sdbc error:
*arithmetic exception, numeric overflow, or string truncation
*string right truncation
*expected length 50, actual 65
caused by
'isc_dsql_fetch'
at /run/build/libreoffice/connectivity/source/drivers/firebird/Util.cxx:69
The current limit for RazónSocial
is set at 500.
This is the SQL view:
select
f."IDFactura", f."FechaFactura", f."Estado", f."FacturaHecha", f.yr,
right('00' || cast(f.grp_pos as varchar(10)), 3) || '/' || right(cast(f.yr as varchar(4)), 2) "IDinvoice",
c."RazónSocial", c."Dirección", c."Ciudad", c."CódigoPostal", c."PaísORegión", c."CIF",
t."Descripción", t."Cantidad", t."Precio"
from
(
select
"IDFactura", "IDCliente", "FechaFactura", "Estado", "FacturaHecha",
row_number() over (partition by extract(year from "FechaFactura") order by "FechaFactura", "IDFactura") grp_pos,
extract(year from "FechaFactura") yr
from "Facturas"
) f
join
(
select "IDCliente", "RazónSocial", "Dirección", "Ciudad", "CódigoPostal", "PaísORegión", "CIF"
from "Clientes"
) c
on f."IDCliente" = c."IDCliente"
join
(
select "IDFactura", "Descripción", "Cantidad", "Precio"
from "Tareas"
) t
on f."IDFactura" = t."IDFactura"
order by f."FechaFactura", f."IDFactura"
EDIT:
Thanks to ChatGPT I could update the SQL and now it works (I am keeping a backup just in case, I don’t trust that much the coding abilities of ChatGPT):
SELECT
f."IDFactura", f."FechaFactura", f."Estado", f."FacturaHecha", f.yr,
RIGHT('00' || CAST(f.grp_pos AS VARCHAR(10)), 3) || '/' || RIGHT(CAST(f.yr AS VARCHAR(4)), 2) AS "IDinvoice",
c."RazónSocial", c."Dirección", c."Ciudad", c."CódigoPostal", c."PaísORegión", c."CIF",
t."Descripción", t."Cantidad", t."Precio"
FROM
(
SELECT
"IDFactura", "IDCliente", "FechaFactura", "Estado", "FacturaHecha",
ROW_NUMBER() OVER (PARTITION BY EXTRACT(YEAR FROM "FechaFactura") ORDER BY "FechaFactura", "IDFactura") AS grp_pos,
EXTRACT(YEAR FROM "FechaFactura") AS yr
FROM "Facturas"
) f
JOIN
(
SELECT "IDCliente", "RazónSocial", "Dirección", "Ciudad", "CódigoPostal", "PaísORegión", "CIF"
FROM "Clientes"
) c ON f."IDCliente" = c."IDCliente"
JOIN
(
SELECT "IDFactura", "Descripción", "Cantidad", "Precio"
FROM "Tareas"
) t ON f."IDFactura" = t."IDFactura"
ORDER BY f."FechaFactura", f."IDFactura";