我有一些按此顺序调用的存储过程。
因此,从第一个存储过程开始,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
我确实声明了这个变量,但我仍然得到错误,我不明白为什么。
我怎样才能克服这个错误?
谢谢!