当前用户吧。
drop table tbname;
create table tbname ...;pl/sql里面
begin
execute immediate 'drop table tbname';
exception when others then
null;
end;
execute immediate 'create table tbname ...'
...
drop table tbname;
create table tbname ...;pl/sql里面
begin
execute immediate 'drop table tbname';
exception when others then
null;
end;
execute immediate 'create table tbname ...'
...
我感觉你这里是把所有的表删除了,所以没有判断的必要,直接先drop再重建就可以了呀!
if num=0 then
str:='create table '||tabname||'....';
else
str:='drop table '||tabname;
end if;
execute immediate str;
另外:大家都说用存储过程,存储过程能在前台的web程序里面使用吗?
如果能使用,那么怎么用呢?
直接调用存储过程就可以了。
private static String getContent(String type, String startDate,
String endDate) throws
DAOException {
DBconn db = null;
String sql = null;
ResultSet rs = null;
Connection con = null;
CallableStatement call = null;
try {
db = new DBconn();
con = db.getConnection();
call = con.prepareCall("call p_dtsgfztj_getsql(?,?,?,?)");
call.registerOutParameter(4, java.sql.Types.VARCHAR);
call.setString(1, startDate);
call.setString(2, endDate);
call.setString(3, type);
rs = call.executeQuery();
sql = call.getString(4);
}
catch (ConnectionException e) {
throw new DAOException(e, "统计报表失败!");
}
catch (SQLException e) {
throw new DAOException(e);
}
finally {
if (rs != null) {
try {
rs.close(); //关闭结果集
}
catch (Exception e) {
e.printStackTrace();
}
}
if (call != null) {
try {
call.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
if (con != null) {
try {
con.close(); //关闭连接
}
catch (Exception e) {
e.printStackTrace();
}
}
}
return sql;
}
Set DataConn = Server.CreateObject("ADODB.Connection")sql = " execute procedure sp1(1,2,...) "
DataConn.Execute sql