linuxoraclec语言
A. 怎么在linux环境下通过c/c++语言连接oracle数据库
推荐你使用pc语言,用这个编写代码很容易对数据库oracle进行操作.各种操作都非常简单.
例如:
EXEC sql CONNECT :UserName IDENTIFIED BY :PassWord using :ServerName;
这样一个简单语句就可以实现连接数据库.
EXEC SQL CALL insert_data_sms(:spnumber,:usernumber,:content,:flag,:priority,:spnode,:sequenid_sp,:iresult);
EXEC SQL COMMIT;/*提交事务*/
可调用存储过程.
你可以找找这方便的书看看
B. linux下c++远程连接oracle数据库
你说的复合结构应该是结构体吧。若是举个例子给你看看
/*
* sample2.pc
*
* This program connects to ORACLE, declares and opens a cursor,
* fetches the names, salaries, and commissions of all
* salespeople, displays the results, then closes the cursor.
*/
#include <stdio.h>
#include <sqlca.h>
#define UNAME_LEN 20
#define PWD_LEN 40
/*
* Use the precompiler typedef’ing capability to create
* null-terminated strings for the authentication host
* variables. (This isn’t really necessary--plain char *’s
* does work as well. This is just for illustration.)
*/
typedef char asciiz[PWD_LEN];
EXEC SQL TYPE asciiz IS STRING(PWD_LEN) REFERENCE;
asciiz username;
asciiz password;
struct emp_info
{
asciiz emp_name;
float salary;
float commission;
};
/* Declare function to handle unrecoverable errors. */
void sql_error();
main()
{
struct emp_info *emp_rec_ptr;
/* Allocate memory for emp_info struct. */
if ((emp_rec_ptr =
(struct emp_info *) malloc(sizeof(struct emp_info))) == 0)
{
fprintf(stderr, "Memory allocation error. ");
exit(1);
}
/* Connect to ORACLE. */
strcpy(username, "SCOTT");
strcpy(password, "TIGER");
EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--");
EXEC SQL CONNECT :username IDENTIFIED BY :password;
printf(" Connected to ORACLE as user: %s ", username);
/* Declare the cursor. All static SQL explicit cursors
* contain SELECT commands. ’salespeople’ is a SQL identifier,
* not a (C) host variable.
*/
EXEC SQL DECLARE salespeople CURSOR FOR
SELECT ENAME, SAL, COMM FROM EMP WHERE JOB LIKE ’SALES%’;
/* Open the cursor. */
EXEC SQL OPEN salespeople;
/* Get ready to print results. */
printf(" The company’s salespeople are-- ");
printf("Salesperson Salary Commission ");
printf("----------- ------ ---------- ");
/* Loop, fetching all salesperson’s statistics.
* Cause the program to break the loop when no more
* data can be retrieved on the cursor.
*/
EXEC SQL WHENEVER NOT FOUND DO break;
for (;;)
{
EXEC SQL FETCH salespeople INTO :emp_rec_ptr;
printf("%-11s%9.2f%13.2f ", emp_rec_ptr->emp_name,emp_rec_ptr->salary, emp_rec_ptr->commission);
}
/* Close the cursor. */
EXEC SQL CLOSE salespeople;
printf(" Arrivederci. ");
EXEC SQL COMMIT WORK RELEASE;
exit(0);
}
void sql_error(msg) char *msg;
{
char err_msg[512];
int buf_len, msg_len;
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf(" %s ", msg);
/* Call sqlglm() to get the complete text of the
* error message.
*/
buf_len = sizeof (err_msg);
sqlglm(err_msg, &buf_len, &msg_len);
printf("%.*s ", msg_len, err_msg);
EXEC SQL ROLLBACK RELEASE;
exit(1);
}
C. 关于linux方面找工作
你现在已经学习了linux的一些通用招式。我觉得你找一个系统管理员的工作应该问题不大。
如果要做开发工作,你就面临选择。你可以根据兴趣或者行业前景,要知道linux能做的事情很多,比如oracle的数据库,Java, Apache等都是最先在linux下实现的。C语言也是随着Unix诞生的。还有现在很火的移动终端android, 其内核还是linux。
所以,你要选择一个方向学习,比如你学习数据库,那可以用做金融,游戏,科研等;你学习内核,那你可以做驱动。
建议你接受zkx1217童鞋的建议。先投简历!!!!
D. LINUX C/C++用什么连接oracle数据库啊解决办法
在Windows的控制面板中,查找ODBC数据源,配置一个能够连接Oracle的数据源,并测试能够成功连接。然后在VS中连接这个数据源即可。
E. 我想在linux下用C语言连接远程oracle,可以不装客户端而用代码实现连接并操作吗如果可以,怎么连
必须使用orcale数据库提供的客户端开发库中的函数来和oracle数据库服务器来进行通讯。