Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Remote view TOP n with n as a param
Message
De
19/11/2013 13:07:52
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01588219
Message ID:
01588317
Vues:
33
>>I've been trying to get this to work with ODBC and SPT but if i read the VFP docs correctly a param can't be part of a SELECT statement. Anyway. so far no luck but I'm not sure it is critical to the app and seems like kind of a half assed approach to do in on the back end when it is a VFP app and the potential result set is really small anyway.
>
>You can do this one of two ways:
>
>
>
>LOCAL lnRows
>
>lnRows = 10
>SET STEP ON 
>TEXT TO lcSQL NOSHOW TEXTMERGE
>   DECLARE @RowsToGet INT
>   SET @RowsToGet = <<m.lnRows>>
>   SELECT TOP (@RowsToGet) * FROM SomeTable ORDER BY SomeField
>ENDTEXT 
>
>?SQLEXEC(m.lnHandle, m.lcSQL, "curResults1")
>
>
>LOCAL lnRows
>
>lnRows = 10
>
>TEXT TO lcSQL NOSHOW 
>   DECLARE @RowsToGet INT
>   SET @RowsToGet = ?m.lnRows
>   SELECT TOP (@RowsToGet) * FROM SomeTable ORDER BY SomeField
>ENDTEXT 
>
>?SQLEXEC(m.lnHandle, m.lcSQL, "curResults2")
>
>
Thanks, Paul. The problem is I am doing this in VFE with remote views. I did try the second approach you show above. I have not yet tested to see if the parser in VFE/VFP that converts a remote view to SPT would do the substitution at runtime. In order to convert the 900 views I wrote an app that exports all the local views to prgs using VFEGenview then gets them as close as it can to what I want by manipulating the prg as a string and rewriting it to file. Then it flags the stuff in the files that will take human intervention and I start grinding on those. Haven't put them back into a DBC yet to run them against the back end (another program will compare the results against benchmark data in SQL and in VFP in the 2 versions of the program.)

I really did tell the client it would just be faster to rewrite the app using EF, Breeze and Angular but they think somehow they are getting something by taking a very badly designed VFP app and making no changes other than to make it talk to SQL data that uses the same bad design. (sigh)


Charles Hankey

Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy

Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.

-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin

Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform