1

この順序で呼び出すストアド プロシージャがいくつかあります。

ここに画像の説明を入力

したがって、最初のストアド プロシージャからimportTaxonomyを呼び出しparseXBRL、からparseXBRLを呼び出しますcreateTaxonomyStructure

しかし、このフローでは、最後のストアド プロシージャのコードを実行するとエラーが発生します。

Msg 1087, Level 15, State 2, Line 1 Must declare the table variable "@temporaryTable".

以下に、このストアド プロシージャの最初の数行のコードを示します。

CREATE PROCEDURE createTaxonomyStructure @taxonomy_table nvarchar(max), @debug bit = 0  
AS

DECLARE @statement NVARCHAR(MAX)
DECLARE @temporaryTable TABLE (taxonomyLine NVARCHAR(MAX))      -- declared a temporary table to avoid creating a Dynamic Query with the entire cursor, but just with the temporary table
DECLARE @taxonomyLine NVARCHAR(MAX)     -- variable that will store one line of the taxonomy

    SET @statement = 'INSERT INTO @temporaryTable SELECT taxText FROM ' + @taxonomy_table   -- statement that will import the taxonomy in the temporary table

EXEC sp_executesql @statement           

DECLARE taxonomyCursor CURSOR READ_ONLY FAST_FORWARD FOR        -- read each line in the taxonomy to parse afterwards
    SELECT taxonomyLine
    FROM @temporaryTable

OPEN taxonomyCursor

FETCH NEXT FROM taxonomyCursor INTO @taxonomyLine               -- parsing each taxonomy line and extracting the values from important attributes
WHILE @@FETCH_STATUS = 0
    BEGIN

        DECLARE @id_element NVARCHAR(MAX)
        DECLARE @leaf_element NVARCHAR(MAX)

        SELECT @id_element = (SELECT dbo.extract_IDElement(@taxonomyLine))
        SELECT @leaf_element = (SELECT dbo.extract_IDLeafElement(@taxonomyLine))

        SET @statement = 'UPDATE ' + @taxonomy_table + ' SET fullName = ''' + @id_element + ''', leafName = ''' + @leaf_element + '''';

        EXEC sp_executesql @statement

    END

この変数を宣言していますが、それでもエラーが発生し、理由がわかりません。

どうすればこのエラーを乗り越えることができますか?

ありがとう!

4

1 に答える 1

1

エラーはここにあります:

SET @statement = 'INSERT INTO @temporaryTable SELECT taxText FROM ' + @taxonomy_table   -- statement that will import the taxonomy in the temporary table

EXEC sp_executesql @statement 

に変更します

set @statement = 'select taxText from ' + @taxonomy_table

insert into @temporaryTable
exec sp_executesql @statement

@statement実行の範囲に変数 table がないため、エラーが発生しています@temporaryTable

于 2013-10-18T12:13:22.807 に答える