String s1 = "create table testing " +
"(id number NOT NULL PRIMARY KEY, " +
"url varchar(1000) NOT NULL, " +
"urlHash varchar(1000) NOT NULL, " +
"contentHash varchar(1000), " +
"modDate date, " +
"contentLocation varchar(1000), " +
"status integer, " +
"lastCrawlDate date) ";
String s2 = "create sequence " +sequenceName+ " start with 1 increment by 1 nomaxvalue";
stmt=conn.createStatement();
stmt.executeUpdate(s1);
stmt.executeUpdate(s2);
下面的合并语句有什么问题,我总是得到错误作为
Missing IN or OUT parameter at index:: 8
我在准备状态中尝试将oracle中的字符串日期时间转换为dataType。
ps = conn.prepareStatement(
"MERGE INTO testing " +
"USING ( SELECT ? AS url, " + // We will maybe add this record
" ? AS urlHash, " +
" ? AS contentHash, "+
" TO_DATE(?, 'YYYY-MM-DD'T'HH24:MI:SS'Z'') AS modDate, "+
" ? AS contentLocation, "+
" ? AS status, "+
" TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS') AS lastCrawlDate "+
" FROM dual ) maybe "+
" ON (maybe.urlHash = testing.urlHash) "+
" WHEN MATCHED THEN "+
// We only need update the fields that might have changed
" UPDATE SET testing.contentHash = maybe.contentHash, "+
" testing.modDate = maybe.modDate, "+
" testing.contentLocation = maybe.contentLocation, "+
" testing.status = maybe.status, "+
" testing.lastCrawlDate = maybe.lastCrawlDate "+
// But only if the new record is more recent
" WHERE TO_CHAR(testing.modDate, 'YYYY-MM-DD'T'HH24:MI:SS'Z'') < TO_CHAR(maybe.modDate, ''YYYY-MM-DD'T'HH24:MI:SS'Z''') "+
" WHEN NOT MATCHED THEN "+
// Insert new URL record
" INSERT VALUES (test_seq.nextval, maybe.url, maybe.urlHash, maybe.contentHash, maybe.modDate, maybe.contentLocation, maybe.status, maybe.lastCrawlDate)");
ps.setString (1, "http://www.computergeeks.com");
ps.setString (2, "ahsasoiowiewie");
ps.setString (3, "sgasjwhwueybdbfndf");
ps.setString (4, "2011-07-28T23:54:14Z");
ps.setString (5, "c://");
ps.setLong (6, 0);
ps.setString (7, "2010-09-24 23:34:14");
ps.executeUpdate();
ps.close();
发布于 2011-10-27 21:01:22
第一个TO_DATE
调用中的日期格式是不好的--您试图在单引号字符串中使用单引号,因此它最终没有被正确地括起来。这可能会使解析器适应,从而产生一个不太明智的错误消息。
在Oracle日期格式中,文字位需要用双引号括起来,而不是单引号:
select TO_DATE('2011-07-28T23:54:14Z', 'YYYY-MM-DD"T"HH24:MI:SS"Z"') from dual;
您需要将格式'YYYY-MM-DD"T"HH24:MI:SS"Z"'
嵌入到SQL语句中。确保正确地转义双引号,这样它们就不会终止Java字符串。
发布于 2012-07-10 21:43:06
这可能与您的问题无关,但我也收到了相同的错误,我在SQL开始时碰巧有两行注释行。我把它们移到底部,错误就消失了。
https://stackoverflow.com/questions/7921720
复制相似问题