PreparedStatement

Поиск
Список
Период
Сортировка
От Nathan Crause
Тема PreparedStatement
Дата
Msg-id 4155A54D.10002@uniclear.com
обсуждение исходный текст
Ответы Re: PreparedStatement
Список pgsql-jdbc
Hi guys,<br /><br /> First time posting to this mailing list, so please be patient with me.<br /><br /> I have a need
forthe Connection.prepareStatement(String sql, int autoGeneratedKeys) method to be functional. Obviously, such keys
wouldonly ever be generated during an INSERT (as per the Java API specification: "This parameter is ignored if the SQL
statementis not an <code>INSERT</code> statement").<br /><br /> Unless someone strongly objects, I am going to be
lookinginto coding such functionality. I do have several questions, though. Now, I personally have only ever seen
INSERTstatements for a single table. Is it even vaguely possible for an INSERT statement to directly affect more than
onetable (by directly, I mean excluding any tables which may be affected by a trigger)?<br /><br /> If not, then what I
amproposing is for the Connection.prepareStatement() method to use regular expression parsing (via the java.util.regex
package)to extract the table name being inserted into, and querying the system tables to check for an int (or bigint)
columnswhich contain a default which refers to the "NEXTVAL" function, and which do NOT form part of the actual insert
statement(i.e. the default value will be inserted, hence using the sequence number system).<br /><br /> I would
obviouslyneed to create a special PreparedStatement implentation which would store these column names. Upon execution
ofthis prepared statement, the class would then internally execute all "CURRVAL()" queries for the columns known to
havebeen autogenerated.<br /><br /> So, I'm thinking that someone is probably wondering why the heck I want to do this?
SurelyI could just code the "CURRVAL()" queries right within my program. Well, my motivation is that the company I am
workingfor is trying to move our systems from a MySQL database to PostgreSQL. Many of the data insertion areas on the
systemuse the auto-generated-keys resultset feature, and I personally don't want to fish through all the programs and
changethem. Hehehe - lazy dude <span class="moz-smiley-s4"><span> :-P </span></span><br /><br /><br /> 

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Simon Moses
Дата:
Сообщение: Arrays Question? -Simon Moses
Следующее
От: Kris Jurka
Дата:
Сообщение: Re: PreparedStatement