📄 step2.cpp
字号:
#include <stdio.h> // for printf#include <SQLAPI.h> // main SQLAPI++ headerint main(int argc, char* argv[]){ SAConnection con; // connection object SACommand cmd; // create command object try { // connect to database (Oracle in our example) con.Connect("test", "tester", "tester", SA_Oracle_Client); // associate a command with connection // connection can also be specified in SACommand constructor cmd.setConnection(&con); // create table cmd.setCommandText( "Create table test_tbl(fid integer, fvarchar20 varchar(20), fblob blob)"); cmd.Execute(); // insert value cmd.setCommandText( "Insert into test_tbl(fid, fvarchar20) values (1, 'Some string (1)')"); cmd.Execute(); // commit changes on success con.Commit(); printf("Table created, row inserted!\n"); } catch(SAException &x) { // SAConnection::Rollback() // can also throw an exception // (if a network error for example), // we will be ready try { // on error rollback changes con.Rollback(); } catch(SAException &) { } // print error message printf("%s\n", (const char*)x.ErrText()); } return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -