Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How does VFP determine numeric field length in SQL outpu
Message
 
 
À
02/05/2003 15:09:18
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00784307
Message ID:
00784310
Vues:
23
Hi David,

VFP uses first physical record in the table to determine the size of all query fieds, not just numeric. You can change your query as follow to get more or less consistent results.
00000000000 + (getCompAvailQty(p1.stock_id,kc.dEdition)) AS qtyAvail
At least the field size wouldn't less than number of zeros in the constant.

>I am trying to debug a numeric overflow error, which occurs very intermittently. The code I am working with does a select into a temp dbf. One of the select list items is:
>
>(getCompAvailQty(p1.stock_id,kc.dEdition)) AS qtyAvail
>
>Then later:
>
> Replace qtyAvail WITH qtyAvail - otherQty
>
>where the numeric overflow occurs.
>
>The previous developer had harcoded the result set as:
>
>'into dbf kitcomponents'
>
>So I removed that code and changed it so that it would write into a temp table named with sys(2015), and then I erase the temp table.
>So now, I can't look at this result set file to see what the data looked like. Good change in terms of multi-user practice - bad for me trying to debug this. So, I looked at some old copies of the kitcomponents table lying around (in different folders for different contexts of the same app) and found that in some cases qtyavail was numeric(11), and in one, (with overflow data) it was numeric(1).
>
>In my tests from the command line, I found that if I issue:
>select sometable.*, 1 as one from sometable into dbf result
>Then sometable.one is numeric(1)
>
>If I:
>select sometable.*, 10 as ten from sometable into dbf result
>
>then sometable.ten is numeric(2) (and so on)
>
>It seems to figure out the length in a consistent way in the case of a literal.
>
>BUT, in the case when I passed in my own FUNCTION that returned a value, it always made the output field numeric(12) even when the largest return value was 1, or, it made the output field larger than numeric(12) if the largest output was larger than that
>
>Yet, I have a few of these old 'kitcomponent.dbf's 'lying around' that created qtyavail as numeric(1).
>
>So my question is, how does vfp determine the length of the output field, and, is it consistent in doing this?
>
>TIA
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform