Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Querying data between SQL Server and VFP...
Message
 
 
À
22/08/2001 23:14:46
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00547774
Message ID:
00547812
Vues:
9
Hi!

It is more SQL Server question. You can use SQL Server commands to run what you need using SQLEXEC() function. You can run multiple commands. The script in your case will look like following:
lcSQL="CREATE TABLE #TMPACCTS ..."+chr(13)+chr(10)+;
  "INSERT #TMPACCTS EXEC sp_GETTMPAccounts ?Param1,?Param2"+chr(13)+chr(10)+;
  "CREATE TABLE #TMPITEMS ..."+chr(13)+chr(10)+;
  "INSERT #TMPITEMS EXEC sp_GETTMPItems ?Param1,?Param2"+chr(13)+chr(10)+;
  "SELECT ... FROM #TMPACCTS, #TMPITEMS , ... WHERE ..."+chr(13)+chr(10)+;
  "DROP TABLE #TMPACCTS"+chr(13)+chr(10)+;
  "DROP TABLE #TMPITEMS"
lnSuccess = SQLEXEC(nConnectHandle, lcSQL, 'MyResultCursor')
As you see, SQL Server allows to insert result of the stored procedure into the table.

Run this script first in the SQL Server query analizer and see if it returns correct result - to debug it. Then move these SQL commands to a string like in a sample above. Note that "GO" is not recognized by SQLEXEC(), it works only as a single batch of commands. Avoid using of ? at all cost because ? for SQLEXEC is used to pass parameters to the SQL Server (I often catchec by this when writing comments and end question in the comment by ?, that cause error ;)

HTH.

>For a front-end VFP application that is utilizing SQL Server, what is the best strategy for constructing a stored procedure where a history file is being queries for many accounts and many items?
>
>For example, let's say I have an INVOICE table in SQL Server that has both an account and product column. A user, at run-time, may want to see a report on inovices for 20 accounts and 100 items....or maybe 10 accounts and 2 items, etc.
>
>So the VFP app interface allows the user to select the 20 accts and 100 items...and let's say they're sitting in two VFP cursors called TMPACCTS and TMPITEMS. What is the most effective way to 'get' these two cursors into SQL server so that a stored procedure can do a join between INVOICE, TMPACCTS, and TMPITEMS?
>
>Only way I've figured out is to create a temp table in SQL Server (#TMPACCTS and #TMPITEMS), use SQLEXEC to insert the 20 accts and 100 items that the user selected, and then run the stored proc between my INVOICE table and the two #TMP files. This 'works', but I don't know if that's a good practice, since hundreds of users could be doing the same thing.
>
>There's probably some fundamental command or strategy I'm missing...
>
>TIA,
>Kevin
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform