Re: Setting expire date on insert/modify

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: "Foster, Stephen" <stephenlfoster(at)comcast(dot)net>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Setting expire date on insert/modify
Date: 2006-01-25 01:18:04
Message-ID: 780F3D40-B0FE-4BB1-94E0-9A1A11D9AC99@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jan 25, 2006, at 10:12 , Foster, Stephen wrote:

> If I try to save without which was what I did in the first place I
> receive this using "ExpireDate := (date StartDate + integer
> NumOfDays);"
>
> ERROR: syntax error at or near "$1" at character 16
> QUERY: SELECT (date $1 + integer $2 )
> CONTEXT: SQL statement in PL/PgSQL function "TF_BannerAd_Ads_InsMod"
> near line 8

The common ways of casting in PostgreSQL are some_value::some_type,
e.g., "ExpireDate"::date, or using CAST, e.g., CAST ("ExpireDate" as
date). In the general case, some_type some_value will not work.

The docs can also be very helpful. I myself just looked up the syntax
of the CAST expression (I generally use the double-colon method).

See if that makes a difference.

Michael Glaesemann
grzm myrealbox com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2006-01-25 01:18:27 Re: Setting expire date on insert/modify
Previous Message Benjamin Smith 2006-01-25 01:17:43 Postgresql Segfault in 8.1