Link to home
Start Free TrialLog in
Avatar of Decisionisti
DecisionistiFlag for Italy

asked on

Java JDBC: number of rows returned by a "CREATE TABLE AS SELECT" instruction

Hi,

Executing in Java, on a Oracle database, the sql statement:

int rows = stm.executeUpdate("CREATE TABLE A as select * from MONTHS")

 the table A in created and the int variable "rows" contains the number of written rows in the table.

Executing the same statement in SQL Server, with the correct sintax:

int rows = stm.executeUpdate("SELECT * into A from MONTHS");

The rows variable is "-1".

The different databases implement in a different way that JDBC method and don't return the number of written rows? Is there a way to do that on SQL Server?

Thank you in advance

Antonio Vivalda
Avatar of for_yan
for_yan
Flag of United States of America image

what happens if you craete table as select * where rownum = 1

and then run "insert into table_a select *..." in a separate stateemnt - will that one return number of rows?

I guess you even can sya "where rownum = 0";

or you can then truncate this row or delete it

I hope insert into should return number of rows
Avatar of Decisionisti

ASKER

Yes the insert return the number of rows, but I need it in the "select * into A from MONTHS" sql statement
ASKER CERTIFIED SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No comment