Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anil Sharma
  Where is Anil Sharma?
 ludhiana
 India
 Anil Sharma
 To: Nadeem Shah
  Where is Nadeem Shah?
 Rawalpindi
 Pakistan
 Nadeem Shah
 Tags
Subject: RE: SQL query problem
Thread ID: 268724 Message ID: 268726 # Views: 29 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Errors & Debugging
Date: Wednesday, July 14, 2010 9:42:34 AM         
   


> Hi all
>
> When I execute following query
>
>
> Select Stkstatus.Date, Stkstatus.opening, Stkstatus.purchase,;
> convert(stkstatus.sale, products.unit) As qtypack,;
> Stkstatus.sale, Stkstatus.sale_ret, Stkstatus.closing, Stkstatus.exp_ret,;
> Products.pname, Company.Name,Products.unit;
> FROM ;
> medical!Stkstatus ;
> LEFT Outer Join medical!Products ;
> ON Stkstatus.pid = Products.pid ;
> LEFT Outer Join medical!Company ;
> ON Products.cid = Company.cid;
> Into Cursor tmp Readwrite
>
> ** convert function
>
> Lparameters m.qty, m.unit
> If Pcount()==2
> If m.qty#0 Or m.unit#0
> m.pack=Int(m.qty/m.unit)
> m.piece=Mod(m.qty,m.unit)
> Return Alltrim(Str(m.pack))+" - "+Alltrim(Str(m.piece))
> Else
> Return '0 - 0'
> Endif
> Else
> Return '0 - 0'
> Endif
>
> <\vfp>
>
> My problem is when query executed
>
> convert(stkstatus.sale, products.unit) As qtypack
>
> it returns value according to first record field length, if first record field length is 4 then remaining all fields have length 4. All fields will restrict only 4 remaining truncated.
>
>
>
> Any solution to set field size space(10)
>
> Nadeem
Yeh it will. becaz ur first result is 0-0 so its better u return value '0 - 0' OR Wrap in CAST() FUNCTION


CAST(convert(stkstatus.sale, products.unit) AS CHAR(10)) As qtypack

Anil

My Blog

ENTIRE THREAD

SQL query problem Posted by Nadeem Iqbal @ 7/14/2010 9:34:01 AM
RE: SQL query problem Posted by Martin Krivka @ 7/14/2010 9:36:41 AM
RE: SQL query problem Posted by Nadeem Iqbal @ 7/14/2010 9:47:03 AM
RE: SQL query problem Posted by Anil Sharma @ 7/14/2010 9:42:34 AM
RE: SQL query problem Posted by Nadeem Iqbal @ 7/14/2010 9:47:53 AM
RE: SQL query problem Posted by Anders Altberg @ 7/14/2010 1:00:13 PM
RE: SQL query problem Posted by Samir H. @ 7/14/2010 4:02:02 PM
RE: SQL query problem Posted by Anders Altberg @ 7/15/2010 3:06:12 PM