Script errors on run

Поиск
Список
Период
Сортировка
От Ralph Smith
Тема Script errors on run
Дата
Msg-id D692E8F6-2E71-41AD-8DEB-9EA9DA6F6E77@washington.edu
обсуждение исходный текст
Ответы Re: Script errors on run  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Список 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 по дате отправления:

Предыдущее
От: Michael Glaesemann
Дата:
Сообщение: functions, transactions, key violations
Следующее
От: Tom Lane
Дата:
Сообщение: Re: functions, transactions, key violations