Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rX9XE-0092n4-9P for pgsql-general@arkaria.postgresql.org; Tue, 06 Feb 2024 00:42:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rX9XD-00GpXW-Eg for pgsql-general@arkaria.postgresql.org; Tue, 06 Feb 2024 00:41:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rX9XC-00GpTI-Gc for pgsql-general@lists.postgresql.org; Tue, 06 Feb 2024 00:41:59 +0000 Received: from fout4-smtp.messagingengine.com ([103.168.172.147]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rX9X9-005Gym-0f for pgsql-general@lists.postgresql.org; Tue, 06 Feb 2024 00:41:57 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.nyi.internal (Postfix) with ESMTP id 477BD1380063; Mon, 5 Feb 2024 19:41:53 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 05 Feb 2024 19:41:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1707180113; x=1707266513; bh=xD0z3P06aXFPIvoyognZbapNgEDP4DG4Tc7xTbLlXzo=; b= Q8XWDq2kn03rQHayg8MwvgkKtYmF05I3yCh8LL1COazCBiY3Ql1SeiMQgh9itKJx Q4VXOAGHy3b1gMVkmavkRoVkZGmrLTBIdJDaj16m+blvcpUV+QPP2eKN2CrR1AhN EgCE6dKbYg0F3idW18NMdFdEz170bUWaIl08Gd1C9IRq9sf7eylQh7Ddv1Hd0zUE a9FoOYnr/OfrPsrKjUz/IkACEokRmmWUlLsQoSJQ4RXWTbgn5oFiCU5+MNrSWTV6 qMvtanuln1xoRUI2jgIYt3aka2T7kPBW7XoxWINH/F6h0bDtfqS3HBQyRRF6xK9G mClvVPUHNIfM68ZabDbwfw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1707180113; x= 1707266513; bh=xD0z3P06aXFPIvoyognZbapNgEDP4DG4Tc7xTbLlXzo=; b=Y Eh3h0hXhGK4RoX+21q1A4fVE7/KcLuA0u5xMnMdRMfZ3WELlcfaRmiMFNQA3C/RD uvgQsNGCwQ1ikGHpnFa9AEBvkE6borcxHJy3ggzORS/jqN8dA+uUZRLSOLj2d3uN ty24xFYJkOKe9+NOpT9fRrAapIJlOHSonYZsvylSiuJsHNvXoJUxWXEtU9U5haeB VsRoJVbwz/zpSZdxwSodXO86sSuSQ0K+fBDC9gobJ3kKmLfj2Xsq/zrWnu/3ZEUf R3RpAre61NxwZNs0MFiElbY8qzFS2EuRQRYkhsoS3UMRTmb7F32z3nx6j3rUK0X8 yG1p3zvkRBFP6KfK+JO5w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedvvddgvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepgfdufeekhfevfeelveeiueevhedvuddukeduvddv lefhueeuieejtdeuvdevvdeunecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrgh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughr ihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 5 Feb 2024 19:41:52 -0500 (EST) Message-ID: Date: Mon, 5 Feb 2024 16:41:51 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: select from composite type Content-Language: en-US To: Lorusso Domenico , "David G. Johnston" Cc: pgsql-general@lists.postgresql.org References: <3c650059-4d07-461c-a791-3f73338a9acc@aklaver.com> From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/5/24 16:35, Lorusso Domenico wrote: > ah ehm.. I solved, it was very easy but I believed it should use the > from clause... > > execute 'select ($1).* ' using _attribute into _r; Beat me to it For the reason why it works: https://www.postgresql.org/docs/current/sql-expressions.html#SQL-SYNTAX-ROW-CONSTRUCTORS > > Il giorno mar 6 feb 2024 alle ore 01:01 Lorusso Domenico > > ha scritto: > > here an example (the actual case in more complex, but the point it's > the same) > > do $$ > declare > _attribute_list temp1.my_type[]; > _attribute temp1.my_type; > > _r record; > begin > _attribute_list=array[row(1,'Hello') , row(2,'Goodbye')]; > > _attribute= row(1,'Doh!!!!'); > > raise notice '%', _attribute_list; > > for _r in execute 'select * from unnest($1) where foo=1' using > _attribute_list loop > raise notice '%', _r; > end loop; > > --Error > execute 'select * from $1' using _attribute into _r; > > raise notice '%', _r; > end; > $$; > > So I able to manage an array of complex type (why I use an array, > because in a previous answer the community suggest to me to use > an array to pass a list of information instead of temporary table), > but I can't do the same thing with just an element. > > Of course I can set an element as part of an array with just that > element but. it's sad... > > > Il giorno lun 5 feb 2024 alle ore 01:48 David G. Johnston > > ha > scritto: > > On Sun, Feb 4, 2024 at 5:39 PM Adrian Klaver > > > wrote: > > > > > > attribute_list is  an array of composite type (with 20 > fields). > > I am trying to wrap my head around "array of composite > type". Please > provide an example. > > > ARRAY[ (1,2)::point, (3,4)::point ]::point[] > > The main problem is the concept of writing "from($1)" in any > query makes no sense, you cannot parameterize a from clause > directly like that.  You have to put the value somewhere an > expression is directly allowed. > > David J. > > > > -- > Domenico L. > > per stupire mezz'ora basta un libro di storia, > io cercai di imparare la Treccani a memoria... [F.d.A.] > > > > -- > Domenico L. > > per stupire mezz'ora basta un libro di storia, > io cercai di imparare la Treccani a memoria... [F.d.A.] -- Adrian Klaver adrian.klaver@aklaver.com