我有以下视图运行到外部mssql数据库。我正在为一些带有输入参数的完整存储过程连接到同一个数据库,这些过程工作正常,但视图不起作用并给出错误
Warning: mssql_execute() [function.mssql-execute]: message: The request for procedure 'usv_Extended_Confirmation' failed because 'usv_Extended_Confirmation' is a view object. (severity 18) in
Warning: mssql_execute() [function.mssql-execute]: General SQL Server error: Check messages from the SQL Server (severity 18) in
Warning: mssql_execute() [function.mssql-execute]: stored procedure execution failed in
Warning: mssql_fetch_assoc() expects parameter 1 to be resource, boolean given in
调用视图的脚本如下所示
//run msdb connected view procedure
function runView($procedure){
global $msdb;
//initiate function
$proc = mssql_init('usv_Extended_Confirmation', $msdb);
//Execute Procedure
$result = mssql_execute($proc);
while ($row = mssql_fetch_assoc($result)){
$results[] = $row;
}
$return = $results;
//Free Memory
mssql_free_statement($proc);
return $return;
}
您不执行视图。视图类似于表或查询 - 您可以从中Select
。
$query = mssql_query('SELECT * FROM usv_Extended_Confirmation');
while ($row = mssql_fetch_assoc($query)) {
....
因为它是一个视图,你不应该从 SELECT 语句调用它吗
SELECT * FROM usv_Extended_Confirmation