Script errors on run - Mailing list pgsql-general

From Ralph Smith
Subject Script errors on run
Date
Msg-id D692E8F6-2E71-41AD-8DEB-9EA9DA6F6E77@washington.edu
Whole thread Raw
Responses Re: Script errors on run  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-general
This is my first 'real' script, one that verifies proper format for a user-entered date string.
Once that is done I want the script to return the UNIX time.

I plan on invoking this script on a psql connection (via .psqlrc), so that I can call it from the command line.

Here's what I have at the end of my script,
************************************

  -- ==========================================
  good_date := to_date(year||'-'||month||'-'||day , 'YYYY-MM-DD') ;

  

  RAISE NOTICE 'good_date =  %',good_date ;

  Usecs := EXTRACT(EPOCH FROM TIMESTAMP good_date) ;

END ;


Here's what I get when I
*********************

psql -U username dbname  -f myfile.sql
CREATE FUNCTION
psql:myfile.sql:119: ERROR:  syntax error at or near "$1"
LINE 1: SELECT  EXTRACT(EPOCH FROM TIMESTAMP  $1 )
                                              ^
QUERY:  SELECT  EXTRACT(EPOCH FROM TIMESTAMP  $1 )
CONTEXT:  SQL statement in PL/PgSQL function "usecs_from_date" near line 92

Is this not a programmable extraction???
I'm missing something here.

Thanks!
Ralph

pgsql-general by date:

Previous
From: Michael Glaesemann
Date:
Subject: functions, transactions, key violations
Next
From: Tom Lane
Date:
Subject: Re: functions, transactions, key violations