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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:22:14+00:00 2026-05-18T21:22:14+00:00

I have a plpgsql function that executes a query, but when i put an

  • 0

I have a plpgsql function that executes a query, but when i put an array into it it wont parse it, at least it gives me this error:

[FAIL]    syntax error at or near "{"
LINE 21:  AND c.category_uuid != ANY({"c0857e20-111e-11e0-ac64-0800...
CONTEXT:  PL/pgSQL function "get_membercategories" line 22 at FOR over EXECUTE statement

This is the complete line:
AND c.category_uuid != ANY({"c0857e20-111e-11e0-ac64-0800200c9a66"})

This is how my function looks

CREATE OR REPLACE FUNCTION get_membercategories(in_company_uuid uuid, in_parent_uuid uuid, in_start integer, in_limit integer, in_sortby character varying, in_order character varying, in_querystring character varying, IN in_excludestring UUID[], OUT out_status integer, OUT out_status_description character varying, OUT out_value character varying[]) RETURNS record
LANGUAGE plpgsql
AS $$

DECLARE
 temp_record RECORD;
 altered_parent_uuid UUID;
 temp_out_value VARCHAR[];
 temp_iterator INTEGER := 0; 
 temp_parent_uuidstring VARCHAR;
 temp_excludestring VARCHAR := '';
BEGIN

IF in_parent_uuid IS NOT NULL THEN
    temp_parent_uuidstring := 'AND c.parent_uuid = ''' || in_parent_uuid || '''';
ELSE
    temp_parent_uuidstring := 'AND c.parent_uuid IS NULL';
END IF;

IF in_excludestring IS NOT NULL THEN
    temp_excludestring := 'AND c.category_uuid != ANY(' || in_excludestring || ')';
END IF;


FOR temp_record IN EXECUTE '
 SELECT 
  c.name, 
  c.category_uuid,
  mc.password, 
  (
     SELECT COUNT(*)
     FROM
       targetgroupusers tgu
     WHERE
      tgu.targetgroup_uuid = mc.targetgroup_uuid
  )  AS receivers
FROM
    membercategories AS mc
LEFT JOIN
    categories AS c
ON
    mc.category_uuid = c.category_uuid  
WHERE
   c.isdeleted IS NULL
   ' || temp_excludestring || '
AND
   mc.company_uuid = ''' || in_company_uuid   || '''
   ' || in_querystring || '
   ' || temp_parent_uuidstring || '
ORDER BY
   ' || in_sortby || ' ' || in_order || '
OFFSET
   ' || in_start || '
LIMIT
   ' || in_limit

LOOP   
   temp_out_value[temp_iterator] = ARRAY[temp_record.category_uuid::VARCHAR(36), temp_record.name::CHARACTER VARYING, temp_record.receivers::CHARACTER VARYING, CASE WHEN temp_record.password IS NOT NULL THEN '1' ELSE '0' END];
   temp_iterator = temp_iterator+1;
END LOOP;

out_status := 0;
out_status_description := 'Member categories successfully retrieved';
out_value := temp_out_value;
RETURN;

END$$;

I am clueless at this point, any help is very much appreciated!

  • 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-18T21:22:15+00:00Added an answer on May 18, 2026 at 9:22 pm

    Your problem is that the the array gets expanded to an invalid string (as you can see in the error message). The string representation of an array needs to be enclosed into single quotes again and then casted to the approriate array type:

    The following should work:

    IF in_excludestring IS NOT NULL THEN
        temp_excludestring := 'AND c.category_uuid != ANY(''' || in_excludestring::varchar||'''::UUID[])';
    END IF;
    

    Note that in_excludestring is explicitely cast to a varchar to force the string representation of an array, enclosed in single quotes to satisfy the “array literal” syntax and then cast back to an UUID array.

    The resulting string will look something like this:

    category_uuid != ANY ( '{c0857e20-111e-11e0-ac64-0800200c9a66,7fffda0c-11c9-11e0-967c-a300aec7eb54}'::UUID[] )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that is used as an INSERT trigger. This function deletes
I have this upsert function that allows me to modify the fill_rate column of
I have a trigger that executes a function on table insert or update. It
I'm trying to write a function in PL/PgSQL that have to work with a
I have this Trigger in Postgresql that I can't just get to work (does
have such zend query: $select = $this->_table ->select() ->where('title LIKE ?', '%'.$searchWord.'%') ->where('description LIKE
Have you managed to get Aptana Studio debugging to work? I tried following this,
This is a multi-part question. I have a table similar to: CREATE TABLE sales_data
I have a number of tables that use the Postgres Partitioning feature. I want
Is it possible for a PostgreSQL plpgsql function to not return anything? I've created

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.