Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Vfp Stored procedure help
Message
From
08/01/2004 04:15:24
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
07/01/2004 16:38:09
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00864863
Message ID:
00864988
Views:
12
>Hello all
>
>I have 12 tables say empJan,empFeb,empMar...empDec.how can i get the data for the range that user specifies. for eg if user selects JAN..MAY, i need to get data into one cursor. right now i use procedure code to do this, is it possible thru SQL/ Stored Procedures.
>
>TIA

Akhan,
Possible by SQL through unions. However thinking SQL subqueries have a limit of 10 and a year has 12 months you might need to divide it into more than one SQLs.
IMHO not playing with SQL and directly using xbase would be neater and (faster?). I think all structures are same.
GetRangeCursor('Jan','May','myCursor')
GetRangeCursor('Feb','May')
GetRangeCursor('Feb')

Function GetRangeCursor
Lparameters tcStart,tcEnd,tcCursorName
tcCursorName = Iif(Empty(m.tcCursorName),'empRange',m.tcCursorName)
If Empty(m.tcEnd)
  Select * ;
    from ( 'Emp'+m.tcStart ) ;
    into Cursor (m.tcCursorName) ;
    readwrite
  Return
Endif
Local Array aTables[12]
Local ix
For ix=1 To 12
  aTables[m.ix] = Upper('Emp'+Left(Cmonth(Date(2000,m.ix,1)),3))
Endfor
Select * ;
  from ( aTables[Ascan(aTables,'EMP'+Upper(m.tcStart))] ) ;
  into Cursor (m.tcCursorName) ;
  readwrite
For ix = Ascan(aTables,'EMP'+Upper(m.tcStart)) + 1 To ;
    Ascan(aTables,'EMP'+Upper(m.tcEnd))
  Append From ( aTables[m.ix] )
Endfor
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
Previous
Reply
Map
View

Click here to load this message in the networking platform