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

  • SEARCH
  • Home
  • 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 7058913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:10:09+00:00 2026-05-28T04:10:09+00:00

SELECT UNNEST(ARRAY[1,2,3,4]) While executing the above query I got the error like this: ERROR:

  • 0
SELECT UNNEST(ARRAY[1,2,3,4])

While executing the above query I got the error like this:

ERROR: function unnest(integer[]) does not exist in postgresql.

I am using PostgreSQL 8.3 and I have installed the _int.sql package in my db for integer array operation.

How to resolve this error?

  • 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-28T04:10:10+00:00Added an answer on May 28, 2026 at 4:10 am

    unnest() is not part of the module intarray, but of standard PostgreSQL. However, you need Postgres 8.4 or later for that.

    So you can resolve this by upgrading to a more recent version. See the versioning policy of the PostgreSQL project.

    Here’s a poor man’s unnest() for Postgres 8.4:

    CREATE OR REPLACE FUNCTION unnest(anyarray)
      RETURNS SETOF anyelement
      LANGUAGE sql IMMUTABLE AS
    'SELECT $1[i] FROM generate_series(array_lower($1,1), array_upper($1,1)) i';
    

    Only works for one-dimensional arrays – as opposed to modern unnest() which also takes accepts multiple dimensions:

    SELECT unnest('{1,2,3,4}'::int[])  -- works
    SELECT unnest('{{1,2},{3,4},{5,6}}'::int[])  -- fails (returns all NULLs)
    

    You could implement more functions for n-dimensional arrays:

    CREATE OR REPLACE FUNCTION unnest2(anyarray) -- for 2-dimensional arrays
      RETURNS SETOF anyelement
      LANGUAGE sql IMMUTABLE AS
    $func$
    SELECT $1[i][j]
    FROM  (
       SELECT i, generate_series(array_lower($1,2), array_upper($1,2)) AS j
       FROM   generate_series(array_lower($1,1), array_upper($1,1)) i
       ) sub;
    $func$;
    

    Call:

    SELECT unnest2('{{1,2},{3,4},{5,6}}'::int[])  -- works
    

    You could also write a PL/pgSQL function that deals with multiple dimensions …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a query like: SELECT DISTINCT unnest(test) AS test FROM table ORDER
select count(category) from list where category like 'action' above is a query i want
select email from mailing list This is the query i want to use if
select * from table where key='çmyk' when i run this query on table that
SELECT * FROM CUSTOMERS WHERE RTRIM(ISNULL([SHORTNAME],'')) LIKE '%john%' I want to write this using
select * from myTable where myInt will not show any possible_keys when explaining the
SELECT AVG(`col5`) FROM `table1` WHERE `id` NOT IN ( SELECT `id` FROM `table2` WHERE
select id from dm_unit where aa like '%'||?||'%'
(SELECT word, description FROM dictionary WHERE word LIKE 'xxxx%') AS a UNION (SELECT word,
select NAME from Temp_EMP where name not in select NAME from EMPLOYEE and deptid

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.