Re: [SQL] INSERT query (using insert from a Java application, concerning String input)

From: "Brett W(dot) McCoy" <bmccoy(at)lan2wan(dot)com>
To: Atika <agoswa(at)essex(dot)ac(dot)uk>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] INSERT query (using insert from a Java application, concerning String input)
Date: 1999-02-18 00:22:59
Message-ID: Pine.BSI.3.91.990217191629.22885D-100000@access1.lan2wan.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Wed, 17 Feb 1999, Atika wrote:

> String input = "This is a String";
>
> myConn.updateQuery("insert into myDB values(input)");
>
> but get an error when I run it saying:
> ERROR: attribute input not found
> java.sql.SQLException: ERROR: attribute input not found
>
> I am also going to have to insert integer and other such values but am not
> going to know their values when I use the insert statement.

I don't know the details of the Java interface (perhaps you should pose
your question to the interfaces list?), but you still need the single
quotes else the term ends up in the SQL querytree as an attribute rather
than as data to insert into an attribute. All of the language interfaces
I have used still require the single quotes, even if you are
interpolating string variables inside of the SQL statement. Or is the
JDBC completely different in this? Can you prepare your query string
beforehand and then pass the entire string as a varaible rather than as
a literal to the updateQuery method?

Brett W. McCoy
http://www.lan2wan.com/~bmccoy
-----------------------------------------------------------------------
Labor, n.:
One of the processes by which A acquires property for B.
-- Ambrose Bierce, "The Devil's Dictionary"

----- BEGIN GEEK CODE BLOCK -----
Version: 3.12
GAT dpu s:-- a C++++ UL++++$ P+ L+++ E W++ N- o K- w--- O@ M-@ !V PS+++
PE Y+ PGP- t++ 5- X+ R+@ tv b+++ DI+++ D+ e>++ h+ r++ y++++
------ END GEEK CODE BLOCK ------

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Peter Garner 1999-02-18 00:46:14 Re: [SQL] INSERT query (using insert from a Java application, concerning String input)
Previous Message Atika 1999-02-17 21:10:46 INSERT query (using insert from a Java application, concerning String input)