设为首页 加入收藏

TOP

[转]什么是Pro*C/C++,嵌入式SQL,第一个pro*c程序,pro*c++,Makefile,Proc增删改查(三)
2017-10-12 17:39:09 】 浏览:1617
Tags:什么 Pro C/C 嵌入式 SQL 一个 pro 程序 Makefile Proc 删改
ca.sqlcode;

printf("EXEC SQL connect:err, %d\n", ret);

return ret;

}

printf("connect ok\n");

deptno = 50;

strcpy(dname, "50name");

strcpy(loc, "50loc");

//增加数据

EXEC SQL insert into dept (deptno, dname, loc) values(:deptno, :dname, :loc);

EXEC SQL commit;

printf("enter key ... update \n");

getchar();

getchar();

strcpy(loc, "50locloc");

EXEC SQL update dept set loc = :loc where deptno=:deptno;

//EXEC SQL delete from dept where deptno=:deptno;

EXEC SQL COMMIT RELEASE; //提交事务断开连接

return ret;

}

执行结果:

\

数据库中的结果:

\

查询并显示结果:

#include <stdio.h>

#include <string.h>

#include <string.h>

#include "sqlca.h"

//定义宿主变量 serverid

EXEC SQL BEGIN DECLARE SECTION ;

char *serverid = "scott/123456@orcl";

int deptno;

char dname[20];

char loc[20] ;

int deptno2;

char dname2[20];

char loc2[20] ;

EXEC SQL END DECLARE SECTION;

//获取

int main()

int ret = 0;

printf("hello....\n");

//在C中是宿主变量

printf("serverid:%s \n", serverid);

//嵌入式SQL语言必须要以 EXEC SQL开头

//:serverid

EXEC SQL connect :serverid;

if (sqlca.sqlcode != 0)

{

ret = sqlca.sqlcode;

printf("EXEC SQL connect:err, %d\n", ret);

return ret;

}

printf("connect ok\n");

deptno = 50;

strcpy(dname, "50name");

strcpy(loc, "50loc");

EXEC SQL select deptno, dname, loc into :deptno2, :dname2, :loc2 from dept where deptno=:deptno;

 

printf("%d, %s, %s\n", deptno2, dname2, loc2);

 

EXEC SQL COMMIT RELEASE; //提交事务断开连接

 

return ret;

}

原文地址:http://www.2cto.com/database/201410/342324.html

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C基础 寻找随机函数的G点 下一篇【001:ubuntu下搭建ESP8266开发..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目