2011-07-05 43 views
2

我试图在获得这样调用存储功能从VBA存储过程:调用MySQL存储功能,而不是与ADO Command对象

SELECT my_function(); 

如果它是一个存储过程,它会是这样:

CALL my_procedure(); 

存储过程,我可以使用:

Dim cmd As Object 
Set cmd = CreateObject("ADODB.Command") 

With cmd 
    Set .ActiveConnection = oConn 'ADODB connection created elsewhere 
    .CommandType = adCmdStoredProc 
    .CommandText = "my_procedure" 
End With 

cmd.execute 

我特别想知道,如果re是相当于'adCmdStoredProc'的函数吗?

回答

0

您是否试过将其作为SELECT声明运行?

SELECT * 
FROM my_function() 
+0

是的,那是有效的,但我真的很想知道是否有相当于adCmdStoredProc函数。也许我在这方面并不清楚。 – David

+0

我不知道与adCmdStoredProc等效的函数。我总是使用Select从一个函数返回。 – Taryn

1

“?具体来说,我想知道如果有一个函数‘adCmdStoredProc’的等效”

但是,你正在使用的SQL是一种选择哪些参数的函数:

SELECT my_function(); 

你有7个选择CommandTypeEnumadCmdUnspecified应该工作;大概adCmdUnknown。我会使用adCmdText,但它不是真的“等效于”adCmdStoredProc函数。

CommandTypeEnum Constants 
Constant   Value Description 
adCmdFile  256 Evaluate as a previously persisted file 
adCmdStoredProc 4 Evaluate as a stored procedure 
adCmdTable   2 Have the provider generate a SQL query and return all rows from the specified table 
adCmdTableDirect 512 Return all rows from the specified table 
adCmdText   1 Evaluate as a textual definition 
adCmdUnknown  8 The type of the CommandText parameter is unknown 
adCmdUnspecified -1 Default, does not specify how to evaluate 
相关问题