Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g33Ac-0008CF-GL for pgsql-general@arkaria.postgresql.org; Thu, 20 Sep 2018 17:55:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g33AZ-0008Da-8t for pgsql-general@arkaria.postgresql.org; Thu, 20 Sep 2018 17:55:15 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g33AY-0008DG-Ty for pgsql-general@lists.postgresql.org; Thu, 20 Sep 2018 17:55:15 +0000 Received: from 24-182-127-154.static.stls.mo.charter.com ([24.182.127.154] helo=mail.brookhurstdata.net) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g33AR-0005xZ-La for pgsql-general@lists.postgresql.org; Thu, 20 Sep 2018 17:55:12 +0000 Received: from mail.brookhurstdata.net (mail.brookhurstdata.net [10.1.5.12]) by mail.brookhurstdata.net (Postfix) with ESMTP id 0F39988901D for ; Thu, 20 Sep 2018 12:55:05 -0500 (CDT) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 20 Sep 2018 12:55:05 -0500 From: Susan Hurst To: pgsql-general@lists.postgresql.org Subject: array must have even number of elements Organization: Brookhurst Data LLC Reply-To: susan.hurst@brookhurstdata.com Mail-Reply-To: susan.hurst@brookhurstdata.com Message-ID: X-Sender: susan.hurst@brookhurstdata.com User-Agent: Roundcube Webmail/RCMAIL_VERSION List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Why must an array have an even number of elements? I need to use a trigger function on any table, some of which may have an odd number of columns that I want to cleanse before inserting/updating. Is there a workaround for this? ERROR: array must have even number of elements SQL state: 2202E Context: SQL statement "SELECT ($1 #= hstore(array[trim(replace(regexp_replace($1.c,'( ){2,}',' ','g'),' ',' ')),trim(replace(regexp_replace($1.vc,'( ){2,}',' ','g'),' ',' ')),trim(replace(regexp_replace($1.t,'( ){2,}',' ','g'),' ',' '))])).*" PL/pgSQL function store.trim_string_before_dml() line 44 at EXECUTE -- my test table create table dm.trg_test (c character(8), vc varchar(16), t text); insert into dm.trg_test (c,vc,t) values ('ctest',' vctest ',' ttest '); -- code snippet that produced the error. -- new will be substituted for $1 during execution with using clause l_query_string := 'select ($1 #= hstore(array[' || l_column_list || '])).*'; execute format(l_query_string) using new into new; return new; Thanks for your help! -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Susan E Hurst Principal Consultant Brookhurst Data LLC Email: susan.hurst@brookhurstdata.com Mobile: 314-486-3261