forester
May 28th, 2005, 03:49 AM
I just began to write a database program using ODBC, and got 2 problems.
the 1st was: I used the m_db.ExecuteSQL(), but failed, get error info as "ORA-00911 invalid string "
here is the sample code:
CString sql="drop table employee cascade constraints create table employee (name varchar2(90) not null, ID number(6) not null);";
m_db.ExecuteSQL(sql);
this piece of code failed, I don't kown where is wrong .
the another similiar SQL command is below
CString sql="insert into employee values('a',1); insert into employee values('b',2);";
m_db.ExecuteSQL(sql);
this snippet didn't work too. the same error occured !
----------------------------------------------------------------------------
the 2nd questions is, How can I know if a table exists or not, if the table doesn't exist, the
command
m_db.ExecuteSQL("drop table employee ;")
always failed with erro info "the table or view doesn't exist;"
By executing this snippet, what I want to do is to drop the table first , then create the table again, and import some records, just do a new complete installation.
pseudocode below:
if(table exists)
drop table and create table again
else
create table without drop table or an errror showing "the table or view doesn't exist" prompted.
I don't known how to resolve these problems, Any help will be appreciated
the 1st was: I used the m_db.ExecuteSQL(), but failed, get error info as "ORA-00911 invalid string "
here is the sample code:
CString sql="drop table employee cascade constraints create table employee (name varchar2(90) not null, ID number(6) not null);";
m_db.ExecuteSQL(sql);
this piece of code failed, I don't kown where is wrong .
the another similiar SQL command is below
CString sql="insert into employee values('a',1); insert into employee values('b',2);";
m_db.ExecuteSQL(sql);
this snippet didn't work too. the same error occured !
----------------------------------------------------------------------------
the 2nd questions is, How can I know if a table exists or not, if the table doesn't exist, the
command
m_db.ExecuteSQL("drop table employee ;")
always failed with erro info "the table or view doesn't exist;"
By executing this snippet, what I want to do is to drop the table first , then create the table again, and import some records, just do a new complete installation.
pseudocode below:
if(table exists)
drop table and create table again
else
create table without drop table or an errror showing "the table or view doesn't exist" prompted.
I don't known how to resolve these problems, Any help will be appreciated