[pgsql-jp: 32154] Re: Rule と Lock

Tatsuo Ishii t-ishii @ sra.co.jp
2004年 1月 29日 (木) 14:38:19 JST


石井です.

> 補足ですが、
> 
> On Thu, 29 Jan 2004 13:39:17 +0900
> TANIDA Yutaka <tanida @ sra.co.jp> wrote:
> 
> > > # executeQuery に insert 文を入れるのはかなり違和感があります(笑。
> > それを言うなら検索結果を返すinsert文の方がよっぽど違和感が・・・:-)
> 
> Statement#executeQuery()のjavadocには
> --
> Executes the given SQL statement, which returns a single ResultSet object.
> --
> とあるので、insertであろうがなんだろうが、ResultSetを返すなら
> executeQuery()であって、仕様上何の問題もありません。
> 
> # 抵抗感はありますが。

この件について本家MLで聞いたところ,JDBCドライバのメインテナ(?)の
Kris Jurkaさんから,

> On Thu, 29 Jan 2004, Tatsuo Ishii wrote:
> 
> > Hi,
> >
> > It seems JDBC driver does not handle if a INSERT SQL statement
> > performed by executeUpdate() is actually a SELECT, which is rewritten
> > by the rule system.
> 
> 
> The JDBC spec says an exception should be thrown if "the given SQL
> statement produces a ResultSet object" which it does.  As you note using
> executeQuery works, but won't if there isn't a rule.  Perhaps using plain
> execute() would be the most appropriate thing to do.
> 
> Kris Jurka

ということで,executeUpdate()が例外を投げるのは仕様通り.こういうケー
スでは,execute()を使うのがいいのではないか,というフォローがありまし
た.
--
Tatsuo Ishii



pgsql-jp メーリングリストの案内