我一直在研究将查询存储到变量中,但我遇到了麻烦。我一直收到错误
调用'||'
时参数的数目或类型错误
这就是我试过的
mydictionary = {'yummy tim tam':3, 'milk':2, 'chocolates':5, 'biscuit pudding':3, 'sugar':2}
recipes_book = "For today's lesson we will show you how to make biscuit pudding using yummy tim tam milk and rawsugar"
searcher = re.compile(r'{}'.format("|".join(mydictionary.keys())), flags=re.I | re.S)
for match in searcher.findall(recipes_book):
print(match)
答案 0 :(得分:3)
您可以通过名称来引用记录rec
中的列:
DECLARE
addresses VARCHAR(200);
CURSOR allAddresses IS
SELECT *
FROM ALL_ADDRESS;
BEGIN
FOR rec IN allAddresses LOOP
addresses := addresses || rec.house_number
|| ' ' || rec.house_name
|| ' ' || rec.address1
|| ' ' || rec.address2;
END LOOP;
DBMS_OUTPUT.PUT_LINE(addresses);
END;
/
答案 1 :(得分:2)
您不能在表达式中直接使用CURSOR for loop
迭代器。您只能将列名引用为rec.col1
,rec.col2
..等等
DECLARE
addresses VARCHAR(200);
CURSOR allAddresses IS
SELECT *
FROM ALL_ADDRESS;
BEGIN
FOR rec IN allAddresses LOOP
addresses := addresses || rec.<address_column>;
END LOOP;
DBMS_OUTPUT.PUT_LINE(addresses);
END;
答案 2 :(得分:2)
对于这种情况,你应该理解游标变量调用事物:
DECLARE
addresses VARCHAR(200);
CURSOR allAddresses IS
SELECT *
FROM ALL_ADDRESS;
BEGIN
FOR rec IN allAddresses LOOP
addresses := addresses || rec.a; -- A as attribute of your cursor
--- so your need to access your cursor attribute using loop name i.e rec
END LOOP;
DBMS_OUTPUT.PUT_LINE(addresses);
END;
/
每当您尝试访问光标记录时,都应该在属性之前调用cursor变量。 希望它会帮助你..谢谢
答案 3 :(得分:-1)
试试这个 -
addresses := addresses || '' || rec;