Erreur création article sous PostgreSQL

Si vous voulez participer au développement de Gestinux, et que vous ne maîtrisez pas l'anglais, écrivez vos questions ou remarques ici.

Il reste préférable, dans la mesure du possible, d'utiliser le forum anglais.
Post Reply
tintinux
Site Admin
Posts: 154
Joined: 21 Jun 2012, 19:07
Location: Blois (France)
Contact:

Erreur création article sous PostgreSQL

Post by tintinux »

C'est une requête qui fonctionne sous MariaDb et MySql mais qui n'est pas (ou plus) acceptée sous PostgreSQL.

J'ai l'impression qu'il suffit de changer la ligne 1046 de UnitProduct.pas comme indiqué dans les pièces jointes.

Cela permettra peut-être au moins de créer des articles, puis du stock et de tout tester.

N'ayant pas de serveur PostgreSQL, je ne peux pas le faire.
Attachments
Capture du 2026-06-09 17-36-42.png
UnitProduct.diff
(702 Bytes) Downloaded 21 times
Cordialement,

Tintinux
Reefounet
Posts: 29
Joined: 02 Jun 2026, 11:43

Re: Erreur création article sous PostgreSQL

Post by Reefounet »

Pour répondre à l'erreur du script, il y a un conflit :

Code: Select all

SELECT 0 AS Footer, ps.id, wh.id AS WarehouseId, wh.name AS WarehouseName, ps.qty_checked, ps.date_checked, 
ps.qty_quoted, ps.qty_ordered, ps.qty_delivered, qty_checked-COALESCE(ps.qty_delivered,0) AS qty_remaining,
ps.updatedate FROM Warehouses wh LEFT JOIN ProductsStocks ps ON ps.warehouseid=wh.id AND ps.ProductId = $1 
JOIN Products psp ON psp.Id = ps.productid 
UNION SELECT 1, 
pst.id, --CONFLIT
NULL AS WarehouseId,
'*' AS WarehouseName,
SUM(pst.qty_checked) AS qty_checked, --CONFLIT
NULL AS date_checked,
SUM(COALESCE(pst.qty_quoted,0)) AS qty_quoted, --CONFLIT
SUM(COALESCE(pst.qty_ordered,0)) AS qty_ordered, --CONFLIT
SUM(COALESCE(pst.qty_delivered,0)) AS qty_delivered, --CONFLIT
SUM(pst.qty_checked)-SUM(COALESCE(pst.qty_delivered,0)) AS qty_remaining,  --CONFLIT
MAX(pst.updatedate) AS updatedate --CONFLIT
FROM ProductsStocks pst WHERE pst.productid = $1
ORDER BY 1,4
J'ai cherché le conflit mais je n'ai pas trouvé. Si on supprime pst.id, ça passe.
Si on supprime le premier SUM, c'est le second qui est en conflit, etc !
Le seul moyen que j'ai trouvé pour contourner cela est de faire : select sum(qty_checked) as qty_checked from ProductsStocks WHERE pst.productid = $1
le code devient alors

Code: Select all

SELECT 0 AS Footer, ps.id, wh.id AS WarehouseId, wh.name AS WarehouseName, ps.qty_checked, ps.date_checked, 
ps.qty_quoted, ps.qty_ordered, ps.qty_delivered, qty_checked-COALESCE(ps.qty_delivered,0) AS qty_remaining,
ps.updatedate FROM Warehouses wh LEFT JOIN ProductsStocks ps ON ps.warehouseid=wh.id AND ps.ProductId = $1 
JOIN Products psp ON psp.Id = ps.productid 
UNION SELECT 1, 
pst.id,
NULL AS WarehouseId,
'*' AS WarehouseName,
(SELECT SUM(qty_checked) FROM ProductsStocks WHERE productid = $1) AS qty_checked,
NULL AS date_checked,
(SELECT SUM(COALESCE(qty_quoted,0)) FROM ProductsStocks WHERE productid = $1) AS qty_quoted,
(SELECT SUM(COALESCE(qty_ordered,0)) FROM ProductsStocks WHERE productid = $1) AS qty_ordered,
(SELECT SUM(COALESCE(qty_delivered,0)) FROM ProductsStocks WHERE productid = $1) AS qty_delivered,
(SELECT SUM(qty_checked)-SUM(COALESCE(qty_delivered,0)) FROM ProductsStocks WHERE productid = $1) AS qty_remaining,
(SELECT MAX(updatedate) FROM ProductsStocks WHERE productid = $1) AS updatedate
FROM ProductsStocks pst WHERE pst.productid = $1
ORDER BY 1,4
Sous PgAdmin, c'est OK !
Cordialement
Reefounet
Reefounet
Posts: 29
Joined: 02 Jun 2026, 11:43

Re: Erreur création article sous PostgreSQL

Post by Reefounet »

J'ai modifier la requête dans Unitproduct.pas et ça fonctionne.

Il faut donc le tester sous Mysql et MariaDB

Je joins le fichier modifié.
Attachments
unitproduct.pas
(40.3 KiB) Downloaded 26 times
Cordialement
Reefounet
tintinux
Site Admin
Posts: 154
Joined: 21 Jun 2012, 19:07
Location: Blois (France)
Contact:

Re: Erreur création article sous PostgreSQL

Post by tintinux »

Bonjour

Je ne vois pas de modification dans le fichier joint.
Cordialement,

Tintinux
Reefounet
Posts: 29
Joined: 02 Jun 2026, 11:43

Re: Erreur création article sous PostgreSQL

Post by Reefounet »

Ligne 1049 et suivantes
Cordialement
Reefounet
tintinux
Site Admin
Posts: 154
Joined: 21 Jun 2012, 19:07
Location: Blois (France)
Contact:

Re: Erreur création article sous PostgreSQL

Post by tintinux »

La modification proposée avec le diff ne convenait pas ?
Cordialement,

Tintinux
Reefounet
Posts: 29
Joined: 02 Jun 2026, 11:43

Re: Erreur création article sous PostgreSQL

Post by Reefounet »

Je n'ai pas testé.
Je regarde ça ce soir.
Cordialement
Reefounet
Post Reply