我一直试图通过点火中的信息链接找出通过点播设置获取多个字符串值的数据的方法。 目前我使用excel文件将表导入spotfire并使用该表的值来过滤我需要的内容。但由于这很麻烦,我需要通过在输入框中输入值并刷新来提取数据。也许我还没找到正确的分隔符。任何人都可以请指教。我的信息链接是从SQL数据库中获取数据,我需要定义标记来获取值。
答案 0 :(得分:0)
如果您的数据集非常大,并且您希望根据可能值列表限制单个列,那么这就是我一直使用的方法,我发现这种方法通常以合理的速度工作,最多可用于列表约50,000个值:
脚本:
strVals = Document.Properties[PreList]
lst = ""
x = 0
y = 0
z = 0
for letter in strVals:
if y == 1:
if letter == " ":
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == ",":
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == "\n":
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == "\r":
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == "'":
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == '"':
lst = lst + strVals[x:z] + ", "
y = 0
elif letter == '\t':
lst = lst + strVals[x:z] + ", "
y = 0
else:
if letter <> " " and letter <> "," and letter <> "\n" and letter <> "\r" and letter <> "'" and letter <> '"' and letter <> "\t":
#print letter
x = z
y = 1
z += 1
if y == 1:
lst = lst + strVals[x:z]
print lst
Document.Properties[PostList] = lst
信息链接本身将引用一个存储过程,该存储过程也将解析它刚刚传递的列表。
ALTER PROCEDURE usp_ProcedureName
@UserID as varchar(max) , @SearchColumn as varchar(max) = NULL
AS
BEGIN
SET NOCOUNT ON;
declare @SQL as varchar(max)
declare @tSearchColumn as varchar(max)
if @UserID <> ''
BEGIN
delete [UserList] where UserID = @UserID
END
if @UserID <> '' and len(@SearchColumn) > 1
begin
while len(@SearchColumn) > 0
begin
set @tSearchColumn = ''
if CHARINDEX(',', @SearchColumn) = 0
begin
set @tSearchColumn = @SearchColumn
set @SearchColumn = replace(@SearchColumn,@tSearchColumn,'')
end
if CHARINDEX(',', @SearchColumn) <> 0
begin
set @tSearchColumn = substring(@SearchColumn, 1 , CHARINDEX(',', @SearchColumn) - 1 )
set @SearchColumn = replace(@SearchColumn, @tSearchColumn + ',', '' )
end
if len(@tSearchColumn) > 0
begin
insert into [UserList]
([UserID]
,[SearchColumn]
,[LoadDate])
(select @UserID , replace(replace(@tSearchColumn,'''',''),' ',''), 2 , getdate()
where not exists (select * from UserList where [SearchColumn] = replace(replace(@tSearchColumn,'''',''),' ','')
and [UserID] = @UserID )
)
end
end
end
select dt.*
from UserList ul join DesiredTable dt on ul.[SearchColumn] = dt.[SearchColumn]
where [UserID] = @UserID
END
如果您愿意,可以使用临时表,但我将数据存储到实例化的表中,以便我可以在以后检查值。