Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.5.4
-
Fix Version/s: 1.5.5, 1.6-beta-1
-
Component/s: SQL processing
-
Labels:None
-
Environment:Windows XP
-
Testcase included:yes
-
Number of attachments :
Description
Running this script:
import groovy.sql.Sql Sql sql = Sql.newInstance("jdbc:oracle:oci:@???, "???", "???", "oracle.jdbc.driver.OracleDriver") sql.execute "CREATE TABLE TEST (A INT, B INT)" sql.execute " insert into test (A,B) values (?,?)", [10, 20] // works OK sql.execute " insert into test (A,B) values (?,?)", [10, null] // fails
Results in:
Caught: java.sql.SQLException: ORA-01008: not all variables bound at test.run(test.groovy:11) at test.main(test.groovy)
AFAIK, th problem lies with the following code (groovy.sql.Sql.java: 1390)
if (value != null) { setObject(statement, i++, value);
I think it should be
if (value != null) { setObject(statement, i++, value); else statement.setNull(i, in.getType());
Issue Links
| This issue is related to: | ||||
| GROOVY-2146 | Can't insert null values into database |
|
|
|
Looks similar to
GROOVY-2146, perhaps the previous fixes weren't as generic as they needed to be. We should try to test on e.g. Oracle, hsql and mysql this time.GROOVY-2146, perhaps the previous fixes weren't as generic as they needed to be. We should try to test on e.g. Oracle, hsql and mysql this time.