MurraySobol
Technical User
Here is my SQL:
CREATE OR REPLACE TYPE t_col
AS
object
(name_and_address_id varchar2(26),
full_name varchar2(200),
parent_record_id varchar2(26),
pass number
)
;
/
CREATE OR REPLACE TYPE id_table
AS
TABLE OF t_col;
/
CREATE OR REPLACE FUNCTION f_get_name_address_list
(name_and_address_id IN varchar2,
full_name IN varchar2,
parent_record_id IN varchar2,
pass IN number
)
RETURN id_table
IS
v_ret id_table;
BEGIN
SELECT CAST(multiset
(INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
1
FROM s1_name_and_address c
WHERE c.name_and_address_id = name_address_id
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
2
FROM s1_name_and_address c
WHERE c.parent_record_id <> c.name_and_address_id
AND c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.pass = 1
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
3
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 2
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
4
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 3
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
5
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 4
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
6
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 5
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
7
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 6
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
8
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 7
)
) AS id_table
)
INTO v_ret
FROM dual;
return v_ret;
END f_get_name_address_list;
/
And here is the error I get:
ATTRIBUTE MESSAGE_NUMBER
--------- --------------
F_GET_NAME_ADDRESS_LIST FUNCTION 1 12 24
PL/SQL: ORA-00936: missing expression
ERROR 0
F_GET_NAME_ADDRESS_LIST FUNCTION 2 11 4
PL/SQL: SQL Statement ignored
ERROR 0
Any assistance would be appreciated.
CREATE OR REPLACE TYPE t_col
AS
object
(name_and_address_id varchar2(26),
full_name varchar2(200),
parent_record_id varchar2(26),
pass number
)
;
/
CREATE OR REPLACE TYPE id_table
AS
TABLE OF t_col;
/
CREATE OR REPLACE FUNCTION f_get_name_address_list
(name_and_address_id IN varchar2,
full_name IN varchar2,
parent_record_id IN varchar2,
pass IN number
)
RETURN id_table
IS
v_ret id_table;
BEGIN
SELECT CAST(multiset
(INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
1
FROM s1_name_and_address c
WHERE c.name_and_address_id = name_address_id
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
2
FROM s1_name_and_address c
WHERE c.parent_record_id <> c.name_and_address_id
AND c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.pass = 1
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
3
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 2
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
4
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 3
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
5
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 4
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
6
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 5
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
7
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 6
)
UNION
INSERT INTO id_table
SELECT c.name_and_address_id,
c.full_name,
c.parent_record_id,
8
FROM s1_name_and_address c
WHERE c.parent_record_id IN
(SELECT x.name_and_address_id
FROM id_table x
WHERE x.parent_record_id <> x.name_and_address_id
AND x.pass = 7
)
) AS id_table
)
INTO v_ret
FROM dual;
return v_ret;
END f_get_name_address_list;
/
And here is the error I get:
ATTRIBUTE MESSAGE_NUMBER
--------- --------------
F_GET_NAME_ADDRESS_LIST FUNCTION 1 12 24
PL/SQL: ORA-00936: missing expression
ERROR 0
F_GET_NAME_ADDRESS_LIST FUNCTION 2 11 4
PL/SQL: SQL Statement ignored
ERROR 0
Any assistance would be appreciated.