我有一个bash脚本,我想在SqlPlus中进行这样的查询
CREATE TABLE tab1(digits VARCHAR2(100));
INSERT INTO tab1(digits) VALUES (5,6);
COMMIT;
#!/bin/bash
.
.
DECLARE
lv_digits VARCHAR2(100):='';
BEGIN
SELECT digits INTO digits FROM tab1;
FOR i IN (SELECT column1 FROM tab2 WHERE column_id IN (lv_digits) AS text);
LOOP
DBMS_OUTPUT.PUT_LINE(i.text);
END LOOP;
END;
/
我不知道如何在WHERE中正确输入条件以返回值
如何手动介绍WHERE column_id IN (5,6) AS text
它是否正常工作,并且必须从另一个表中加载值为VARCHAR2的表加载值。
DECLARE
lv_digits VARCHAR2(100):='';
BEGIN
SELECT digits INTO digits FROM tab1;
FOR i IN (SELECT column1 FROM tab2 WHERE column_id IN (5,6) AS text);
LOOP
DBMS_OUTPUT.PUT_LINE(i.text);
END LOOP;
END;
/
有没有人知道如何转换它?
答案 0 :(得分:0)
这对某人有用
DECLARE
lv_digits VARCHAR2(100):='';
BEGIN
SELECT digits INTO digits FROM tab1;
FOR i IN (SELECT column1 FROM tab2 WHERE column_id IN (select regexp_substr(digits,'[^,]+', 1, level) from karuzela_loop
connect by regexp_substr(digits, '[^,]+', 1, level) is not NULL) AS text);
LOOP
DBMS_OUTPUT.PUT_LINE(i.text);
END LOOP;
END;
/
@mathguy感谢您的提示