Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL error for blank child table
Message
De
07/05/2003 09:29:11
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
07/05/2003 09:22:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00785687
Message ID:
00785755
Vues:
18
>Dear Cetin,
>
>Thanks for your response.
>Here's my code:
>
>SELECT Stockbook.ddate,Stockbook.citemname, Stockbook.citemid, Stockbook.nqtyin,;
> Stockbook.ncost, SUM(Stockout.nqtyout)-SUM(Stockout.nqtyret) AS qtyout ,;
> (Stockbook.nqtyin-sum(stockbook.nqtydel))-(SUM(Stockout.nqtyout)-SUM(Stockout.nqtyret)) AS avlbal;
> FROM stockbook LEFT OUTER JOIN stockout ;
> ON Stockbook.citemid = Stockout.citemid;
> WHERE Stockbook.citemname = lcitemname;
> GROUP BY Stockbook.citemid;
> ORDER BY Stockbook.citemid;
> INTO CURSOR curAvlStock
>
>...and the error message I get:
>
>'Field QTYOUT does not accept null values'
>
>Thanks Cetin,
>
>Regards,
>
>Steve.

When 2nd table has no matching records returned value is null causing sum() to be null. Check 'set null'. Also you can change your expressions to handle nulls. ie :

instead of :
SUM(Stockout.nqtyout)-SUM(Stockout.nqtyret) AS qtyout
try :
SUM( nvl(Stockout.nqtyout,0)-nvl(Stockout.nqtyret,0) ) AS qtyout

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform