I have written a function to accept an integer, a string and an datetime as parameters.
i.e. function_A(int8, bpchar, timestamp)
when I tried to run in query tool, I type
select "DataBaseName"."function_A"(1, 'a', '2004-04-04 10:00:00'), it gives error.
I would like to know how to type a timestamp and a string in PostgreSQL.
For string, it is just quoted by single quote/double quote?
And what is the format to type a timestamp?
'2004-04-04 10:00:00' seems not work.....
but first you have to decide what language you want to create the function in.
Personally i find pl/pgsql the easiest to learn. (perhaps you can do more in c, but i dont know c).
For you example something like this would go:
CREATE FUNCTION my_function_name(integer,text,date) RETURNS TEXT AS'
my_integer := $1;
my_text := $2;
my_date := $3
if you work with dates in a function for example 01-01-2004: you have to escape the ' with a \ and you have to "cast it as a date" Example:
if my_date >= CAST(\'01-01-2004\' AS DATE) THEN
Im not sure if \'01-01-2004\'::date works, you should give it a try.
Im not sure if you can cast it as a timestamp either tho but that is stuff you gotta try for yourself (i myself have just begun scratching the surface of functions and pl/pgsql)
As for calling a function from the command / pgadmin III:
SELECT my_function_name(2,' my text','01-01-2004')
Again, you might need to escape the ' with \.