免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1370 | 回复: 2
打印 上一主题 下一主题

[b]pro*c 问题[/b] [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-03-13 20:37 |只看该作者 |倒序浏览
:wink: 在pro*c中,声明sql变量时可不可以声明结构体类型的变量?如果可以,怎样把表中的字段存入结构体变量的域中?

论坛徽章:
0
2 [报告]
发表于 2003-03-13 20:59 |只看该作者

[b]pro*c 问题[/b]

仔细看看:



/*
*  sample1.pc
*
*  Prompts the user for an employee number,
*  then queries the emp table for the employee's
*  name, salary and commission.  Uses indicator
*  variables (in an indicator struct) to determine
*  if the commission is NULL.
*
*/

#include <stdio.h>;
#include <string.h>;
#include <stdlib.h>;
#include <sqlda.h>;
#include <sqlcpr.h>;

/* Define constants for VARCHAR lengths. */
#define     UNAME_LEN      20
#define     PWD_LEN        40

/* Declare variables.  No declare section is
   needed if MODE=ORACLE. */
VARCHAR     username[UNAME_LEN];  /* VARCHAR is an Oracle-supplied struct */
varchar     password[PWD_LEN];    /* varchar can be in lower case also. */

/* Define a host structure for the output values of
   a SELECT statement.  */
struct
{
    VARCHAR   emp_name[UNAME_LEN];
    float     salary;
    float     commission;
} emprec;

/* Define an indicator struct to correspond
   to the host output struct. */
struct
{
    short     emp_name_ind;
    short     sal_ind;
    short     comm_ind;
} emprec_ind;
。。。。。。。。。。。。。。。


如果你装了Oralce 客户端pro*C的话在你的硬盘里有

论坛徽章:
0
3 [报告]
发表于 2003-03-13 21:27 |只看该作者

[b]pro*c 问题[/b]

谢谢楼上的大哥,可是如何将数据库中的字段检索到结构体中,可以直接检索到结构体变量吗,还是检索到结构体的域中??多谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP