我有一个选择函数,我需要在其中使用SIMILAR TO
带有变量的表达式,但我不知道该怎么做。这是代码:
DECLARE pckg_data cl_data;
DECLARE contacts contacts_reg%ROWTYPE;
DECLARE sim_name varchar;
BEGIN
SELECT client_reg._name,
client_reg.last_name,
client_reg.id_card,
client_reg.address
INTO pckg_data
FROM client_reg WHERE(client_reg._name = (cl_name ||' '|| cl_lastname));
RETURN NEXT pckg_data;
SELECT ('%'||cl_name || ' ' || cl_lastname ||'%') INTO sim_name;
FOR contacts IN SELECT contacts_reg.id
FROM contacts_reg, contactscli_asc, client_reg
WHERE(contacts_reg._name SIMILAR TO sim_name) LOOP
SELECT client_reg._name, client_reg.last_name, client_reg.id_card,
client_reg.address, client_reg.id
INTO pckg_data
FROM client_reg, contactscli_asc WHERE(contactscli_asc.contact = contacts.id
AND client_reg.id = contactscli_asc.client);
END LOOP;
END;