Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gG2OA-0006Y1-01 for pgsql-general@arkaria.postgresql.org; Fri, 26 Oct 2018 13:42:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gG2O8-0000kS-8y for pgsql-general@arkaria.postgresql.org; Fri, 26 Oct 2018 13:42:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gG2O6-0000k7-8l for pgsql-general@lists.postgresql.org; Fri, 26 Oct 2018 13:42:56 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gG2O1-0002Rg-FT for pgsql-general@postgresql.org; Fri, 26 Oct 2018 13:42:52 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 5096C8DD; Fri, 26 Oct 2018 09:42:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 26 Oct 2018 09:42:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=6 4SNk00n6zp8i+hNkeVSIYTMUeJ7n3q/rK50fSjOMGc=; b=jljfybggxEqr65dgO sdaLqOHTAaFGyn6YATiVER8xmHPL97NnaS4CRWKZ8H3UIoA3M4re2TEVgQGhy0TB mYEHTW165jnVT/vlmm8gYRnzcfkqCDWc/iLPimjatDQWhpg8KRe9MVfF7dOQZqz5 6b19vQvPHqPFfo3kdTfNu+/b23tsVEvonumWORgj5B9DiLPJIeNuctBSMxdWocUk iKszKh1q4RNOrhtLQMbz83eUxJKNTAX8JZjSKqrI5Mlbk32lZaFEEpJS/CPH2Qud YPYy7WCBg0Gf1x4B5pFo7T30IxCINF/mNKQcG2kRY9xYMrmAylgTCzIyN3Ud3tIF Rlhsg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=64SNk00n6zp8i+hNkeVSIYTMUeJ7n3q/rK50fSjOM Gc=; b=lclFNcvbAhh6Ukha9TQE7Rx8NP6WqL1CMG5V90BRJZL/TdEhUpuVq8Yp0 pGKmLJqtfOzxZl2GzJuR8HlZPrXfeuDp9WbQSIFUfFCy6ZuikXEPcOf5Kh4CbwU/ fBYWSV4t18+kXlgUgrJb8r0fgHOVm515VI77aC2xHNtNvWb6afl+GimXH/EcWO+E 6RyL/MmYZTqqjWjcXpBnyMwFn1I2b/Q9luPMONXCQdm1hixZY9D9FJJPWNFH8qSj A5zCmu+Fv0l+wfqDRPEEfMNMITDsg7+LS8x7zetxSouRxpQiYTUPdELCFFOzP6ub moXunWP8mt1UnDgTIy4FRGoLxYs9A== X-ME-Sender: X-ME-Proxy: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id D0DB2E4074; Fri, 26 Oct 2018 09:42:45 -0400 (EDT) Subject: Re: ERROR: type "myrowtype" does not exist To: Arup Rakshit , "pgsql-general@postgresql.org >> PG-General Mailing List" References: From: Adrian Klaver Message-ID: Date: Fri, 26 Oct 2018 06:42:44 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/26/18 4:54 AM, Arup Rakshit wrote: > I was reading the json_populate_record function from the official doc > https://www.postgresql.org/docs/10/static/functions-json.html#FUNCTIONS-JSON-PROCESSING-TABLE. > The doc mentioned examples are giving me errors > > psql (11.0, server 10.5) > Type "help" for help. > > aruprakshit=# select * from json_populate_record(null::extype, > '{"x":"foo", "y":43, "q": true}'); > ERROR:  type "extype" does not exist > LINE 1: select * from json_populate_record(null::extype, '{"x":"foo"... >                                                  ^ > aruprakshit=# select * from json_populate_record(null::myrowtype, '{"a": > 1, "b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}}'); > ERROR:  type "myrowtype" does not exist > LINE 1: select * from json_populate_record(null::myrowtype, '{"a": 1… > > What does null::extype, null::myrowtype mean here ? See this thread: https://www.postgresql.org/message-id/2a8ae0b7-1fd4-869a-a25e-d598968898c9%40aklaver.com In meantime: CREATE TABLE public.test_table ( id integer, username character varying, fullname character varying ); test=> \d test_table Table "public.test_table" Column | Type | Collation | Nullable | Default ----------+-------------------+-----------+----------+--------- id | integer | | | username | character varying | | | fullname | character varying | | | test=> select * from json_populate_record(null::test_table, '{"id": 1, "username": "adrian", "fullname": "adrian klaver"}') ; id | username | fullname ----+----------+--------------- 1 | adrian | adrian klaver (1 row) So myrowtype is just a placeholder in the docs for a rowtype that you need to supply. > > > Thanks, > > Arup Rakshit > ar@zeit.io > > > -- Adrian Klaver adrian.klaver@aklaver.com