proc的delete操作

/*
 *功能:proc的delete操作
 *源文件:delete.pc
 */

 

#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>

EXEC SQL INCLUDE SQLCA;

EXEC SQL BEGIN DECLARE SECTION;
    char db_name[25] = "dbname";
EXEC SQL END DECLARE SECTION;

void errorHandle(char *sm)
{
    char buf[1024];
    long bufLen,msgLen,fc;

    sprintf(buf, "执行数据库操作(%s)失败, ORA ERROR:%.70s,

SQLCA.SQLCODE=%d", sm, sqlca.sqlerrm.sqlerrmc, sqlca.sqlcode);

    printf("%s/n", buf);
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    EXEC SQL AT :db_name ROLLBACK WORK;

    return;
}

void connect()
{
    EXEC SQL BEGIN DECLARE SECTION;
    char connString[25] = "nmc/nmc@atest_229";
    EXEC SQL END DECLARE SECTION;

    EXEC SQL WHENEVER SQLERROR DO errorHandle("Connect

Database");
    EXEC SQL AT :db_name CONNECT :connString;
}

void disconnect()
{
    EXEC SQL WHENEVER SQLERROR DO errorHandle("Disconnect

Database");
    EXEC SQL AT :db_name COMMIT WORK RELEASE;
}

void deleteOp()
{
    EXEC SQL WHENEVER SQLERROR DO errorHandle("delete object_ex

error");
    EXEC SQL AT :db_name DELETE FROM object_ex
    WHERE int_id = 10;
    EXEC SQL AT :db_name COMMIT WORK;

    printf("delete database ok/n");
}

int main()
{
    connect();
    printf("Connect database ok/n");
    deleteOp();
    disconnect();
    printf("Disconnect database ok/n");
    return 0;
}

 

 

阅读更多
个人分类: proc开发
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭