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 1t3bGA-00DVuW-Qv for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2024 13:18:47 +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 1t3bG8-009iYA-Sv for pgsql-general@arkaria.postgresql.org; Wed, 23 Oct 2024 13:18:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <01020192b98778c0-78365d74-1341-45c8-b0de-cc6b962afcf9-000000@mail.rodonnell.ie>) id 1t3bG8-009iY1-Bq for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2024 13:18:44 +0000 Received: from a7-38.smtp-out.eu-west-1.amazonses.com ([54.240.7.38]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from <01020192b98778c0-78365d74-1341-45c8-b0de-cc6b962afcf9-000000@mail.rodonnell.ie>) id 1t3bG2-002ZXs-D2 for pgsql-general@lists.postgresql.org; Wed, 23 Oct 2024 13:18:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=dv7fx26oobputowqxkzhnujragfvk7eg; d=rodonnell.ie; t=1729689516; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To; bh=cPfhyDLM4aR8hTqXEaeQUD4cVruv09YRVDsY/l6CAvY=; b=vsBH9kZJ085ozJ1N91GmtpczjK+j9kaY53RDyvrFRb+4eEWZVxPr/KkuTx2ryNts jCEmDMFdPAcXtW+4j7qiWr7Cb6ObTFWldELJzuURju1Zw/wmedMeHKvHTKAthshV+6H KSJdKCU2p/c4v7Ild2EXnL9tO1SFQx/pFKb0chah44p7XlxywPDCTz+3phRk2pU9sfs dTdgWVonxNGUdl1CuHTOh7jO8vbRE6Mdr9sYaGCi7SX1f1iZHjnEyBLygsBu3mM7VZl +t9p/wy76OKgS5LWcFFCIJ5DZmt4jjr1PwNy1rIYdtU3cpipC0RRVEjzA7NLcLgJwVN PB3boWYhKA== DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=uku4taia5b5tsbglxyj6zym32efj7xqv; d=amazonses.com; t=1729689516; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:References:From:In-Reply-To:Feedback-ID; bh=cPfhyDLM4aR8hTqXEaeQUD4cVruv09YRVDsY/l6CAvY=; b=fxUJpb+Q7EX9Hhllr4hlS815DAOfhD65ufRXiSDVy7qhoPdm8yxKVb4GXigu/xk4 m4gjugfg+j0xVqyu1tITFr/rGj2IjMFrxrGN0/lrAqfv+CmKXihOggcbelr4J9GMGRt yu9N0uXFmckCzbgYzhghIXUAKSvQoqGXGSFSphYI= Content-Type: multipart/alternative; boundary="------------NlwdQKVJb5gaZU2G4KJDDsnf" Message-ID: <01020192b98778c0-78365d74-1341-45c8-b0de-cc6b962afcf9-000000@eu-west-1.amazonses.com> Date: Wed, 23 Oct 2024 13:18:36 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: CURRENTE_DATE To: Rossana Ocampos , pgsql-general@lists.postgresql.org References: <00b001db2475$e6584640$b308d2c0$@bry-it.com> Content-Language: en-GB From: Ray O'Donnell In-Reply-To: <00b001db2475$e6584640$b308d2c0$@bry-it.com> X-Spam-Bar: / Feedback-ID: ::1.eu-west-1.Bw1eu/7Uepg3xcsiFBL71JJRCh2A2yTFrgBhhiulXmU=:AmazonSES X-SES-Outgoing: 2024.10.23-54.240.7.38 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. --------------NlwdQKVJb5gaZU2G4KJDDsnf Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 22/10/2024 12:31, Rossana Ocampos wrote: > > *Hello ,* > > I am new with PostgreSQL and I have a bug. I have created a function > that has an input variable of type date , in case it does not receive > value , it has to assume by default the current date. > > I have defined it as follows variable  DATE DEFAULT CURRENT_DATE, but > I get the following error. > > *_El error _* > > ERROR: invalid input syntax for type date: “CURRENT_DATE” LINE 1: > ...extsupplydate ('1085018'::bigint, '5278'::bigint, 'CURRENT_D... ^ > ERROR: invalid input syntax for type date: “CURRENT_DATE” SQL status: > 22007 Characters: 78 > I think you just need to leave off the quotes, as current_date is a function:   insert into .... values ( ... , current_date, ....); Also, you don't need to quote the bigint values. HTH, Ray. > Please could you help me, thank you very much. > > Rossana > -- Raymond O'Donnell // Galway // Ireland ray@rodonnell.ie --------------NlwdQKVJb5gaZU2G4KJDDsnf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
On 22/10/2024 12:31, Rossana Ocampos wrote:

Hello ,

I am new with PostgreSQL and I have a bug. I have created a function that has an input variable of type date , in case it does not receive value , it has to assume by default the current date.

I have defined it as follows variable  DATE DEFAULT CURRENT_DATE, but I get the following error.

 

El error

ERROR: invalid input syntax for type date: “CURRENT_DATE” LINE 1: ...extsupplydate ('1085018'::bigint, '5278'::bigint, 'CURRENT_D... ^ ERROR: invalid input syntax for type date: “CURRENT_DATE” SQL status: 22007 Characters: 78


I think you just need to leave off the quotes, as current_date is a function:

  insert into .... values ( ... , current_date, ....);

Also, you don't need to quote the bigint values.


HTH,

Ray.


 

Please could you help me, thank you very much.

Rossana



-- 
Raymond O'Donnell // Galway // Ireland
ray@rodonnell.ie
--------------NlwdQKVJb5gaZU2G4KJDDsnf--