pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Jurka <books@ejurka.com>
To: list_usr@spacebox.net
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Column is of type date but expression is of type text
Date: Thu, 18 Feb 2010 17:11:55 -0500 (EST)
Message-ID: <alpine.BSO.2.00.1002181708530.7153@leary.csoft.net> (raw)
In-Reply-To: <1e11c2271002181327g52545a34u6a91c5b17cd1fdfd@mail.gmail.com>
References: <1e11c2271002171814i704d31f4oca1d819dc5a02103@mail.gmail.com>
	<alpine.BSO.2.00.1002180017340.30823@leary.csoft.net>
	<1e11c2271002181327g52545a34u6a91c5b17cd1fdfd@mail.gmail.com>



On Thu, 18 Feb 2010, list_usr@spacebox.net wrote:

> Here is the stored procedure in question:

The attached testcase works fine for me.  What driver and server versions 
do you have?

>
> As an aside, how do most people name their IN parameters so as not to
> have them conflict with actual column names?
>

Some people prefix them with v_ to indicate that they are variables.

Kris Jurka

Attachments:

FuncTest.java (text/plain, 1.4K) download import java.sql.*; public class FuncTest { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5850/kjurka", "kjurka", ""); Statement stmt = conn.createStatement(); stmt.execute("CREATE TEMP TABLE athlete (email text, first_name text, last_name text, password text, gender text, dob date)"); stmt.execute("CREATE OR REPLACE FUNCTION athlete_add(IN new_email TEXT, IN fname TEXT, IN lname TEXT, IN pw TEXT, IN sex TEXT, IN bdate DATE) RETURNS BOOLEAN AS $$ BEGIN INSERT INTO athlete (email, first_name, last_name, password, gender, dob) VALUES (new_email, fname, lname, pw, sex, bdate); IF FOUND THEN RETURN TRUE; END IF; RETURN FALSE; END; $$ LANGUAGE plpgsql;"); CallableStatement cs = conn.prepareCall("{? = call athlete_add(?,?,?,?,?,?)} "); cs.registerOutParameter(1, Types.BOOLEAN); cs.setString(2, "email"); cs.setString(3, "first"); cs.setString(4, "last"); cs.setString(5, "pw"); cs.setString(6, "sex"); cs.setDate(7, new java.sql.Date(System.currentTimeMillis())); cs.execute(); cs.close(); ResultSet rs = stmt.executeQuery("SELECT * from athlete"); ResultSetMetaData rsmd = rs.getMetaData(); while (rs.next()) { for (int i=1; i<=rsmd.getColumnCount(); i++) { System.out.println(rs.getString(i)); } } } }

view thread (12+ messages)  latest in thread

Message-ID: <alpine.BSO.2.00.1002181708530.7153@leary.csoft.net>
Permalink:  ../alpine.BSO.2.00.1002181708530.7153@leary.csoft.net/
Also on:    postgresql.org/message-id/alpine.BSO.2.00.1002181708530.7153@leary.csoft.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: books@ejurka.com, list_usr@spacebox.net
  Subject: Re: Column is of type date but expression is of type text
  In-Reply-To: <alpine.BSO.2.00.1002181708530.7153@leary.csoft.net>
  References: <1e11c2271002171814i704d31f4oca1d819dc5a02103@mail.gmail.com> <alpine.BSO.2.00.1002180017340.30823@leary.csoft.net> <1e11c2271002181327g52545a34u6a91c5b17cd1fdfd@mail.gmail.com> <alpine.BSO.2.00.1002181708530.7153@leary.csoft.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox