PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → [WD20] HFSQL Update
[WD20] HFSQL Update
Débuté par Curtis, 12 juin 2017 22:41 - 2 réponses
Posté le 12 juin 2017 - 22:41
I am using HFSQL C/S files. I have a Payment file and a Receipt file. Payment is linked to Receipt by ReceiptID. How can I write a valid query that matches Payments with Receipts and sets Payment.Amount to the matching Receipt.Total?

UPDATE Payment SET Payment.Amount = (SELECT Receipt.Total FROM Receipt WHERE Payment.ReceiptID = Receipt.ReceiptID) //ERROR : No analysis opened: Receipt file not described. UPDATE Payment SET Payment.Amount= Receipt.Total FROM Payment INNER JOIN Receipt ON Payment.ReceiptID = Receipt.ReceiptID //ERROR : Unexpected word: FROM. UPDATE Payment INNER JOIN Receipt ON Payment.ReceiptID = Receipt.ReceiptID SET Payment.Amount= Receipt.Total //ERROR: Unable to cast data to type of JOIN.AppliedAmount item. UPDATE Payment SET Payment.Amount = (SELECT Receipt.Total FROM Receipt WHERE Receipt.ReceiptID = Payment.ReceiptID) WHERE EXISTS (SELECT * FROM Receipt WHERE Receipt.ReceiptID = Payment.ReceiptID) //ERROR : No analysis opened: Receipt file not described. UPDATE Payment,Receipt SET Payment.Amount = Receipt.Total WHERE Payment.ReceiptID = Receipt.ReceiptID //ERROR: Unable to cast data to type of JOIN.AppliedAmount item.
Posté le 12 juin 2017 - 23:15
You should do this as below:

UPDATE Payment JOIN Receipt ON Payment.ReceiptID = Receipt.ReceiptID SET Payment.Amount= Receipt.Total

and it should work with analysis file.

HTH

King
Posté le 12 juin 2017 - 23:58
Oops. Payment.Amount was set to text instead of currency. Now it works.

Thanks kingdr.