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 5929703
In Process

The Archive Base Latest Questions

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

Okay, I’ve got a stored procedure… how do I find all rows whose ID’s

  • 0

Okay, I’ve got a stored procedure… how do I find all rows whose ID’s are not in an array? (Keep in mind that I’m using a PostgreSQL array that is created dynamically when the stored procedure is created

Example:

|  people   |
-------------
| id | Name |
-------------
|  1 | Bob  |
|  2 | Te   |
|  3 | Jack |
|  4 | John |

The array has somePGArray := [1,3], so a psuedo-query would look like this:

SELECT * FROM people WHERE id NOT IN (somePGArray)

Resulting query:

|  people   |
-------------
| id | Name |
-------------
|  2 | Te   |
|  4 | John |

As a bonus, I also have no idea how to create an array and append ID’s to it, so if you have a quick hint how to do that, that’d be tremendously helpful. 🙂

  • 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-22T14:27:25+00:00Added an answer on May 22, 2026 at 2:27 pm
    create table foo1 ( id integer, name text );
    insert into foo1 values (1,'Bob'),(2,'Te'),(3,'Jack'),(4,'John');
    select * from foo1 where id not in (1,2);
    select * from foo1 where not (id = ANY(ARRAY[1,2]));
    
    create or replace function so_example(int)
    returns SETOF foo1 as $$
    declare
      id alias for $1;
      idlist int[] := '{1}';
      q text;
      rec record;
    begin
      idlist := idlist || ARRAY[id];
      q := 'select * from foo1 where not (id = ANY('||quote_literal(idlist)||'))';
      raise notice 'foo % %', idlist,q;
      for rec in execute(q) loop
        return next rec;
      end loop;
    end; $$
    language 'plpgsql';
    
    select * from so_example(3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay, I've looked all over the internet for a good solution to get PHP
Okay, so I'm running a small test webserver on my private network. I've got
Okay, here's the scenario. I have a utility that processes tons of records, and
Okay, we know that the following two lines are equivalent - (0 == i)
Okay, here's my current code for an array. $sites[0]['url'] = http://example0.com; $sites[1]['url'] = http://example1.com;
Okay so I haven't been able to find a question with an answer yet,
Okay I do not even know where to begin when it comes to this
Okay, what I'm trying to accomplish is a simple tool tip that, when you
Okay, so I'm trying to make a game that uses this algorithm: http://www.codeproject.com/Articles/15573/2D-Polygon-Collision-Detection But
Okay, I have hundreds of .net controls with text attributes that needs to be

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.