Script errors on run

From: Ralph Smith <smithrn(at)washington(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Script errors on run
Date: 2008-06-04 20:57:27
Message-ID: D692E8F6-2E71-41AD-8DEB-9EA9DA6F6E77@washington.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jason Long 2008-06-04 21:18:57 Full vacuum really slowing query down
Previous Message Rob Richardson 2008-06-04 19:32:42 Slow access to remote database