在SQL存储过程中查找SELECT语句以及在ColdFusion中查找相应的查询

时间:2012-02-13 18:30:38

标签: sql-server coldfusion stored-functions cfstoredproc

在ColdFusion中,我使用3个输入和6个输出调用以下cfstoredproc。

<cfstoredproc procedure="si_updateProject" datasource="#mydsn#" returncode="yes">
    <cfprocparam type="IN" cfsqltype="CF_SQL_VARCHAR" value="#platform#">
    <cfprocparam type="IN" cfsqltype="CF_SQL_VARCHAR" value="#projectData#">
    <cfprocparam type="IN" cfsqltype="CF_SQL_VARCHAR" value="#sysData#">
    <cfprocresult name="projectInfo" resultSet=1>
    <cfprocresult name="newPSA" resultSet=2>
    <cfprocresult name="newStatus" resultSet=3>
    <cfprocresult name="goliveSystems" resultSet=4>
    <cfprocresult name="goliveHistory" resultSet=5>
    <cfprocresult name="newSystems" resultSet=6>
</cfstoredproc>

在存储过程si_updateProject中,如何识别为resultSets列出的6个resultSet查询?存储过程有几个语句(选择,更新,删除等)。

1 个答案:

答案 0 :(得分:1)

(上述评论摘要..)

除了生成SELECT语句的sql之外,我不知道任何方法,这些语句生成结果并比较columnList值。

当我需要测试对涉及虚拟表的存储过程的修改时,我通常只注释掉CREATE PROCEDURE ... BEGINEND语句并在查询分析器中手动运行sql。技术非常低,但对快速测试很有用。

--- Comment out the procedure wrapper and run the sql in
--- the query analyzer manually with test parameters
DECLARE @platform varchar(50)
DECLARE @projectData varchar(50)
DECLARE @sysData varchar(50)

SET @platform = 'foo'
SET @projectData = 'bar'
SET @sysData = 'qax'

/*     
CREATE PROCEDURE si_updateProject
        @platform varchar(50)
        , @projectData varchar(50)
        , @sysData varchar(50)
AS
BEGIN
*/

        -- simulate some virtual tables
        DECLARE @table1 TABLE ( columnOne varchar(50), createdDate datetime)
        DECLARE @table2 TABLE ( columnTwo varchar(50), createdDate datetime)
        DECLARE @table3 TABLE ( columnThree varchar(50), createdDate datetime)

        -- now you can do whatever debugging you want with the virtual tables ...
        SELECT  'Testing the 1st resultset' AS DebugText, *
        FROM    @table1


        -- simulate some resultsets
        SELECT  columnOne FROM @Table1
        SELECT  columnTwo FROM @Table2
        SELECT  columnThree FROM @Table3

/*
END */
GO