Trying to select records via matching timestamptz with varchar parameters

From: "ben wilko" <wilko_ben(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Trying to select records via matching timestamptz with varchar parameters
Date: 2006-08-09 00:12:50
Message-ID: BAY116-F192A4BF9CD801215B438998F550@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

<html><div style='background-color:'><P><FONT face=Arial size=2>Hi Guys</FONT></P>
<P><FONT face=Arial size=2>Trying to select records via matching timestamptz with varchar parameters in postgres 8.1, using the 8.1-404 JDBC3 driver. We're also running Java 1.5.0-05.</FONT></P>
<P>CREATE OR REPLACE FUNCTION return_daily_card_list(d "varchar", m "varchar", y "varchar")<BR>&nbsp; RETURNS refcursor AS<BR>$BODY$&nbsp; <BR>declare&nbsp; <BR>&nbsp;&nbsp;&nbsp; pointer refcursor;&nbsp; <BR>begin&nbsp; <BR>&nbsp;&nbsp;&nbsp; open pointer for&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select *&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from daily_time_record&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where<BR>&nbsp;if<BR>&nbsp;d = SELECT EXTRACT(YEAR FROM daily_time_record.daily_time_card_date)<BR>&nbsp;and<BR>&nbsp;m = SELECT EXTRACT(MONTH FROM daily_time_record.daily_time_card_date)<BR>&nbsp;and<BR>&nbsp;y = SELECT EXTRACT(DAY FROM daily_time_record.daily_time_card_date)<BR>&nbsp;and if;<BR>&nbsp;&nbsp;&nbsp; return pointer;&nbsp; <BR>end;&nbsp; <BR>$BODY$<BR>&nbsp; LANGUAGE 'plpgsql' VOLATILE;<BR>ALTER FUNCTION return_daily_card_list(d "varchar", m "varchar", y "varchar") OWNER TO postgres;</P>
<DIV class=RTE>ERROR:&nbsp; syntax error at or near "$1" at character 44<BR>QUERY:&nbsp;&nbsp; select * from daily_time_record where if&nbsp; $1&nbsp; = SELECT EXTRACT(YEAR FROM daily_time_record.daily_time_card_date) and&nbsp; $2&nbsp; = SELECT EXTRACT(MONTH FROM daily_time_record.daily_time_card_date) and&nbsp; $3&nbsp; = SELECT EXTRACT(DAY FROM daily_time_record.daily_time_card_date) and if<BR>CONTEXT:&nbsp; SQL statement in PL/PgSQL function "return_daily_card_list" near line 15<BR></DIV>
<DIV class=RTE>CREATE TABLE daily_time_record<BR>(<BR>&nbsp; daily_time_card_id int4 NOT NULL DEFAULT nextval 'daily_time_record_daily_time_card_id_seq'::regclass),<BR>&nbsp; daily_time_card_date timestamptz,<BR>&nbsp; employee_id varchar(10),<BR>&nbsp; agreed_start_time timestamptz,<BR>&nbsp; actual_start_time timestamptz,<BR>&nbsp; total_hours float8,<BR>&nbsp; CONSTRAINT daily_time_record_pkey PRIMARY KEY (daily_time_card_id)<BR>) <BR>WITHOUT OIDS;<BR>ALTER TABLE daily_time_record OWNER TO postgres;</DIV></div></html>

Attachment Content-Type Size
unknown_filename text/html 2.2 KB

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Stephan Szabo 2006-08-09 00:35:53 Re: Trying to select records via matching timestamptz with
Previous Message Steve Crawford 2006-08-08 19:44:35 Re: Scheduling data input from tab delimited file via php