Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6971057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:47:24+00:00 2026-05-27T16:47:24+00:00

I have a table which has column_id of type varchar2. This table may contain

  • 0

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;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:47:25+00:00Added an answer on May 27, 2026 at 4:47 pm

    Instead of using INTO you must use BULK COLLECT INTO:

    DECLARE
       TYPE t_col_id IS TABLE OF TEST_TABLE.COLUMN_ID%TYPE INDEX BY BINARY_INTEGER;
       AR_COL_ID T_COL_ID;
    BEGIN
       SELECT COLUMN_ID 
         BULK COLLECT INTO AR_SIM_ID 
         FROM TEST_TABLE
        WHERE COLUMN_ID = 1;
    
       IF AR_SIM_ID.LENGTH = 0 THEN 
          -- BUSINESS LOGIC 1
       ELSE
          -- BUSINESS LOGIC 2
       END IF;
    
    EXCEPTION
       WHEN NO_DATA_FOUND THEN
          -- BUSINESS LOGIC 3
    END;
    

    But couldn’t you just use COUNT for this scenario?

    DECLARE
       numRows   NUMBER;
    BEGIN
       SELECT COUNT(COLUMN_ID)
         INTO numRows
         FROM TEST_TABLE 
        WHERE COLUMN_ID = 1;
    
       IF numRows = 0 THEN 
          -- BUSINESS LOGIC 1
       ELSE
          -- BUSINESS LOGIC 2, 3, etc...
       END IF;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table which has a column called Direct of type char(1). It's
I have a table which has a NVARCHAR column, which could contain a GUID
I have a table which has around 1 million rows (size on physical disk
I have a column in a table which is has the data type of
I have a table with 692256 number of rows ,which has data similar to
I have a table in SQL Server 2005 which has three columns: id (int),
I have a table which has the below columns. Ticket_id (Primary key, Int) Attachment1
I have a table PGM_MASTER, which has three columns PGM_ID | int(11) PGM_ENV_ID |
I have a table User which has an identity column UserID , now what
I have a table which has two varchar(Max) columns Column 1 Column 2 -----------------------

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.