我需要从for循环中从另一个表中选择的单个字符创建单个字符串。有办法吗?
CREATE OR REPLACE TRIGGER TRIGGER_TRIGGER_TRIGGER
BEFORE INSERT OR UPDATE ON TABLE_TABLE_TABLE FOR EACH ROW
declare
text_length number(10);
rus_temp varchar2(10);
latin_temp varchar2(10);
mc_temp varchar(55);
begin
begin
text_length := length(:new.mc);
mc_temp := (NULL);
for i in 1..text_length
LOOP
letter_temp := (null);
latin_temp := (null);
rus_temp := SUBSTR(:new.mc, i, 1);
select LATINLETTERS INTO latin_temp from LETTERSAPPROXIMATION where rus_temp = RUSSIANLETTERS;
-- HOW TO ADD UP SELECTED LETTERS INTO ONE STRING
END LOOP;
end if;
end;
END;
答案 0 :(得分:2)
似乎您只需要串联即可,例如:
for i in select someChar from ... loop
vString := vString || i.someChar;
end loop
没有循环的另一种方式可以是listagg
,例如:
select listagg(someChar) within Group (order by ...) from ...
答案 1 :(得分:0)
为什么要为此使用for循环?只需使用rpad()
。像这样:
select rpad(SUBSTR(:new.mc, i, 1), text_length, SUBSTR(:new.mc, i, 1)
into mc_temp