Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dealing with a long SQL Select
Message
From
23/12/2015 03:12:51
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01629230
Message ID:
01629248
Views:
65
>The part in parenthesis is built dynamically and the user can select pretty much any number of order numbers to include. So if the entire SQL Select becomes too long, it bombs. Any suggestions on how I could simplify this but still allow user to select any number of "orders"?
>

I'm about to describe some approaches that I've used, though they are with .NET and SQL Server - and I don't know if these can be done from VFP.

First, Hank's approach of the temp table is an approach that many VFP developers have used over the years. It definitely works.

OK, three approaches.

1) If you can take the X number of user selections and make them a basic XML string (with one attribute, representing the key for each user selection), you could take your query and make it a stored procedure. The stored procedure could receive the XML string as a parameter from the application. Inside the stored procedure, you can "shred" the XML string as a table variable and join your main SQL table to the table variable. I *think* you could do this in VFP but not positive

2) Same approach as #1, except that you take the user selections and build a comma-separated string. Inside the SQL Stored Procedure, you can shred the CSV string to a table variable, and then join in. I've done this one many times over the years. I would think you could do this in VFP.

3) I tend to doubt this can be done in VFP, but I'll mention it. Starting in SQL Server 2008 and .NET 2008, you can pass an ADO.NET data table to a stored procedure. Inside the proc you can treat it as a read-only SQL table variable and join it. Only problem - I don't know if any of the data types in Fox can be expressed or transformed into something that the SQL data type would recognize as a data table. I've never tried it and I have no idea if it would work.

But #1 or #2 might possibly work for you.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform