I have a table which has column_id of type varchar2. This table may contain 1, 0 or multiple rows. My business logic depends on each case.
I am trying to fetch the column into an array but i am getting weird error (given my limited knowledge of pl/sql)
TYPE t_col_id IS TABLE OF TEST_TABLE.COLUMN_ID%TYPE INDEX BY BINARY_INTEGER;
AR_COL_ID T_COL_ID;
Then i am trying to fetch data into this array
SELECT COLUMN_ID INTO AR_SIM_ID FROM TEST_TABLE WHERE COLUMN_ID = 1;
and i am getting this error
Error(7,3): PL/SQL: SQL Statement ignored
Error(7,25): PLS-00597: expression 'AR_SIM_ID' in the INTO list is of wrong type
Error(7,35): PL/SQL: ORA-00904: : invalid identifier
Is there something that i am missing? My original code would use this array as
BEGIN
-- FETCH ARRAY QUERY
IF (AR_SIM_ID.LENGTH = 0) THEN
-- BUSINESS LOGIC 1
ELSE
-- BUSINESS LOGIC 2
EXCEPTION
WHEN NO_DATA_FOUND THEN
-- BUSINESS LOGIC 3
END;
Instead of using
INTOyou must useBULK COLLECT INTO:But couldn’t you just use
COUNTfor this scenario?