Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxAKG-0003KP-Ba for pgsql-general@arkaria.postgresql.org; Tue, 14 Dec 2021 16:06:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mxAKF-0001AV-82 for pgsql-general@arkaria.postgresql.org; Tue, 14 Dec 2021 16:06:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxAKE-0001AI-RR for pgsql-general@lists.postgresql.org; Tue, 14 Dec 2021 16:06:46 +0000 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1mxAKC-0003aX-HK for pgsql-general@lists.postgresql.org; Tue, 14 Dec 2021 16:06:46 +0000 Received: by mail-oi1-x236.google.com with SMTP id 7so27682772oip.12 for ; Tue, 14 Dec 2021 08:06:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=PEMQIvy5590yyvcM+KABVft8gxVPMv8ZH2RNgFu9FLk=; b=lzTr3RS7jbwvO+EIs2guLOuHP9rkyh24ZqeOyo8+VmVJoMdwHwCIYBbgUQH2BG/B5p c6f9+s0dyIFoHE6ldW0IycMA5/UZyNVUnNR93pst8r+JLlsuR9IZPiPZBA1NEf77WLen s4A3myZRDiq1RAS0ywg2Od8usIqxm61zqCLlxWQH17uRU2rAnL1t2+O9OSht8piX6jn1 8CAuRFpzI2J+G/t6lcM8EN6jrrzND0KL9AUhkbeJ/i8XPRNwbmd+oq5/da8zhQZUQwEP AEWO/AymZoec7GgqFyYMgAODhybU6VGmca212XUICHShVmqUkVs/69cYWvUp7aLI0xBK JUpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=PEMQIvy5590yyvcM+KABVft8gxVPMv8ZH2RNgFu9FLk=; b=Yom1t//IFg5msLWnTS5RG5P+RxF92Kx535HKjNtGV6/toodrVartz9oKe8Wdss0NCk zwgV+ubuAqX4Ej7NGxe6FOtTxoJb/JE6irWtkH8Nd5K5yF09EV1IXnYvknVdcgijA5ef A86+apQ8GmvajfFuupcT+BMjxihT5LaIMxeLV4mmWQZyAtXpSlyJG8oLu/iAXJbwCCGR r4Ie2BkfOHqJ80SVtVRbHXKfQon7xpzw1TPhHnu/r3fI5wrsgp/UV9WIaEKbjb9ikgzD 9XJoFONfzfNsOeQcGjYuwTWxS5IdJHDCHAwXO2y8dqC+guJ6U64hQKQtQR5U/hRclsn2 F0pQ== X-Gm-Message-State: AOAM531VELaOF2RbfoOHCYmyadLVW+vXV/h2C4CIPQ5Q+g3nssYiyYXD n0v22hI5RwUv8F4TUIfYypsGsBmxpHY= X-Google-Smtp-Source: ABdhPJy9lOnOyERMRLcph17PzG8MkSD2a0T28bq+iO7/+TM1eGfeb8I1Wced6FoTXytvm3OLpaHCxQ== X-Received: by 2002:a54:480b:: with SMTP id j11mr4989847oij.102.1639498002171; Tue, 14 Dec 2021 08:06:42 -0800 (PST) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id k16sm38286otp.21.2021.12.14.08.06.41 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 14 Dec 2021 08:06:41 -0800 (PST) Subject: Re: timestamp default current_timestamp not working To: pgsql-general@lists.postgresql.org References: From: Ron Message-ID: Date: Tue, 14 Dec 2021 10:06:40 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------9104E97291275A0ED4E887C7" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------9104E97291275A0ED4E887C7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Show us the code (especially since there is no value "nil" in SQL). On 12/14/21 10:00 AM, Sanjay Minni wrote: > Its an insert and my insert SQL contains the column timestamp and value nil. > Will it work if the SQL contains timestamp through value is nil > > On Tue, 14 Dec, 2021, 9:20 pm Adrian Klaver, > wrote: > > On 12/14/21 07:36, Sanjay Minni wrote: > > Hi > > > > I am not getting the timestamp value which i am expecting to be > > automatically inserted in the column defined: > > ... > > "timestamp" timestamp with time zone DEFAULT CURRENT_TIMESTAMP, > > ... > > (I see the above definition in pgadmin4 in the tab SQL. > > I have set it thru pgadmin4 table->properties->columns by entering > > CURRENT_TIMESTAMP in the default column) > > > > why is the timestamp value not being automatically inserted by the > system > > 1) It is a DEFAULT value so if a value is provided in the INSERT that > will be used. > > 2) DEFAULT values only apply to INSERTs not UPDATEs. > -- Angular momentum makes the world go 'round. --------------9104E97291275A0ED4E887C7 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Show us the code (especially since there is no value "nil" in SQL).

On 12/14/21 10:00 AM, Sanjay Minni wrote:
Its an insert and my insert SQL contains the column timestamp and value nil. 
Will it work if the SQL contains timestamp through value is nil

On Tue, 14 Dec, 2021, 9:20 pm Adrian Klaver, <adrian.klaver@aklaver.com> wrote:
On 12/14/21 07:36, Sanjay Minni wrote:
> Hi
>
> I am not getting the timestamp value which i am expecting to be
> automatically inserted in the column defined:
> ...
> "timestamp" timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
> ...
> (I see the above definition in pgadmin4 in the tab SQL.
> I have set it thru pgadmin4 table->properties->columns by entering
> CURRENT_TIMESTAMP in the default column)
>
> why is the timestamp value not being automatically inserted by the system

1) It is a DEFAULT value so if a value is provided in the INSERT that
will be used.

2) DEFAULT values only apply to INSERTs not UPDATEs.


--
Angular momentum makes the world go 'round.
--------------9104E97291275A0ED4E887C7--