Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dealing with a long SQL Select
Message
 
 
À
23/12/2015 03:12:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01629230
Message ID:
01629252
Vues:
35
>>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.

Thank you very much for all your suggestions.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform