Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to run Stored Procedure?
Message
De
04/05/2006 20:05:19
 
 
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
Divers
Thread ID:
01119387
Message ID:
01119448
Vues:
24
Got it, check help for PROCEDURE command and FUNCTION command, Remarks section.

If you define a function, is one search order, if you define a procedure is another, or do they mean that the difference is in the way you call any of them?

Is calling method that determines search order?:

=myFunction(param)
=myProcedure(param)

or

do myFunction with param
do myProcedure with param

Or is declaring method that determines search order?:

FUNCTION FunctionName
[ENDFUNC]

or

PROCEDURE ProcedureName
[ENDPROC]

It says for Procedure: (this is what you want)

"When you issue the DO command with a procedure name, Visual FoxPro searches for the procedure in the following order:

1 The file containing the DO command.
2 The current database.
3 Procedure files opened with SET PROCEDURE.
For more information, see SET PROCEDURE Command.
4 Program files in the execution chain.
Visual FoxPro searches program files in order from the most recently
executed program to the first program executed.
5 A standalone program file. "

The order for Function is different:

When you issue the DO command with a function name, Visual FoxPro searches for the function in the following order:

1 The file containing the DO command.
2 Procedure files opened with SET PROCEDURE.
For more information, see SET PROCEDURE Command.
3 Program files in the execution chain.
Visual FoxPro searches program files in order from
the most recently executed program to the first program executed.
5 A standalone program file.


I always thought, back in 2.6 DOS days, that using declare function or procedure was the same thing. Let me check my old 2" thick FoxPro Language Reference book:

OK, the pages for FUNCTION and PROCEDURE are 99% identical, even to the search order, so that confirms my belief that using "FUNCTION" or "PROCEDURE" was the same thing, except for the fact that by default variables are passed to FUNCTIONS by value, and to PROCEDURES always by reference.


>>>>>What do you mean "call this function from SP" - do you want to call one stored procedure from another stored procedure?
>>>>
>>>>No, I just want to run the function from the database and make sure that VFP set path or set('procedure') is not searched to find this function.
>>>
>>>For instance, if I have it in SP and in the program that is in set('procedure'), the one from set('procedure') was executing.
>>
>>Check this:
>>
>>Visual FoxPro Invocation Stack
>>http://fox.wikis.com/wc.dll?Wiki~TopicTextSearch~VisualFoxProInvocationStack
>>
>>Carlos
>
>Carlos,
>
>Thanks a lot. Well, according to this
>Internal commands ( if the function is not prefixed with m.) and base classes, then
>
>User-defined class definitions cached in memory in the order they were loaded, so long as the class definitions are still along SET CLASSLIB or SET PROCEDURE, then
>
>If in VFP 8, a collection's default method, for example myCollection(), then
>
>MyArray(n) array memory variable in scope.
>
>Functions and class definitions in the current .PRG, then
>
>Class definitions along SET CLASSLIB, then
>
>Functions and class definitions along SET PROCEDURE, then
>
>Functions and class definitions in the stored procedures of the current SET DATABASE TO, then
>
>Functions and class definitions in the execution chain (call stack), then
>
>Functions named for files bound in the app/exe, then
>
>Functions named for files in the SET DEFAULT (local) directory, then
>
>Functions named for files out along SET PATH.
>
>COM classes in the OLE registry if SET OLEOBJECT is ON.
>
>
>
>the function in set('procedure') would be called before database procedure.
>
>My question is: is where a way to bypass this VFP internal search and tell the engine to use my SP?
>
>Thanks again for your help.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform