我用proc把两个基本一致的pc文件生成了两个.cpp文件,在vc下运行结果一个正确运行,另一个不能运行。这是为什么啊?大家帮忙解决一下可以么?
第一个pc和.cpp
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include <sqlca.h>
#include <oraca.h>EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[20];
VARCHAR passwd[20];
VARCHAR user_name[20];
VARCHAR password[20];
VARCHAR email[40];
VARCHAR SQLSTATE[6];
char db_name[20];
char input[20];
float m_ratio;
float m_total;
float m_user;
EXEC SQL END DECLARE SECTION;
void sql_error()
/*char *msg;*/
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
/*printf("\n%s", msg);*/
printf("Connect error:");
printf("\n%.70s \n", sqlca.sqlerrm.sqlerrmc);
EXEC SQL ROLLBACK WORK RELEASE;
exit(EXIT_FAILURE);
} void connect()
{
/* init user and passwd */
strcpy(username.arr,"ies_his");
strcpy(passwd.arr,"iesapp");
username.len = strlen(username.arr);
passwd.len = strlen(passwd.arr);
memset(db_name,'\0',20);
strcpy(db_name,"history");
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL CONNECT:username IDENTIFIED BY:passwd USING:db_name;
if(sqlca.sqlcode == 0)
printf("\nConnected to ORACLE as user: %s\n", username.arr);
else
printf("Connected to ORACLE failed!!!!\n");
}float tsFun()
{
EXEC SQL SELECT round(SUM(bytes) / 1024 / 1024) totalspace
INTO :m_total
FROM dba_data_files
where tablespace_name = :("USERS")
GROUP by tablespace_name;
EXEC SQL SELECT round(SUM(bytes) / 1024 / 1024) freespace
INTO :m_user
FROM dba_free_space
WHERE tablespace_name = :("USERS")
GROUP BY tablespace_name;
printf("total = %f\n", m_total);
printf("user = %f\n", m_user);
m_ratio = (1-m_total/m_user)*100;
printf("tablespace ratio : %f\n",m_ratio);
EXEC SQL COMMIT WORK RELEASE;
}
第一个pc和.cpp
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include <sqlca.h>
#include <oraca.h>EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR username[20];
VARCHAR passwd[20];
VARCHAR user_name[20];
VARCHAR password[20];
VARCHAR email[40];
VARCHAR SQLSTATE[6];
char db_name[20];
char input[20];
float m_ratio;
float m_total;
float m_user;
EXEC SQL END DECLARE SECTION;
void sql_error()
/*char *msg;*/
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
/*printf("\n%s", msg);*/
printf("Connect error:");
printf("\n%.70s \n", sqlca.sqlerrm.sqlerrmc);
EXEC SQL ROLLBACK WORK RELEASE;
exit(EXIT_FAILURE);
} void connect()
{
/* init user and passwd */
strcpy(username.arr,"ies_his");
strcpy(passwd.arr,"iesapp");
username.len = strlen(username.arr);
passwd.len = strlen(passwd.arr);
memset(db_name,'\0',20);
strcpy(db_name,"history");
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL CONNECT:username IDENTIFIED BY:passwd USING:db_name;
if(sqlca.sqlcode == 0)
printf("\nConnected to ORACLE as user: %s\n", username.arr);
else
printf("Connected to ORACLE failed!!!!\n");
}float tsFun()
{
EXEC SQL SELECT round(SUM(bytes) / 1024 / 1024) totalspace
INTO :m_total
FROM dba_data_files
where tablespace_name = :("USERS")
GROUP by tablespace_name;
EXEC SQL SELECT round(SUM(bytes) / 1024 / 1024) freespace
INTO :m_user
FROM dba_free_space
WHERE tablespace_name = :("USERS")
GROUP BY tablespace_name;
printf("total = %f\n", m_total);
printf("user = %f\n", m_user);
m_ratio = (1-m_total/m_user)*100;
printf("tablespace ratio : %f\n",m_ratio);
EXEC SQL COMMIT WORK RELEASE;
}
//#define SQLCA_STORAGE_CLASS extern "C"#include <stdio.h>
#include <stdlib.h>
#include<string.h>
//#include <sqlca.h>
//#include <oraca.h>
//EXEC SQL INCLUDE SQLCA;
EXEC SQL INCLUDE "D:\myProgram\sqlexample\querytabspaceratio.h";QueryTabSpaceRatio::QueryTabSpaceRatio()
{
}QueryTabSpaceRatio::~QueryTabSpaceRatio()
{
}void QueryTabSpaceRatio::sql_error()
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("Connect error:");
printf("\n%.70s \n", sqlca.sqlerrm.sqlerrmc);
EXEC SQL ROLLBACK WORK;
exit(EXIT_FAILURE);
}void QueryTabSpaceRatio::connect()
{
strcpy(username.arr,"ies_his");
strcpy(passwd.arr,"iesapp");
username.len = strlen(username.arr);
passwd.len = strlen(passwd.arr);
memset(db_name,'\0',20);
strcpy(db_name,"history");
memset(tsname,'\0',40);
strcpy(tsname,"USERS");
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL CONNECT:username IDENTIFIED BY:passwd USING:db_name;
if(sqlca.sqlcode == 0)
printf("\nConnected to ORACLE as user: %s\n", username.arr);
else
printf("Connected to ORACLE failed!!!!\n");
}float QueryTabSpaceRatio::queryRatio()
{
EXEC SQL SELECT round(SUM(bytes) / 1024 / 1024) totalspace
INTO :m_total
FROM dba_data_files
where tablespace_name = :("USERS")
GROUP by tablespace_name;
EXEC SQL SELECT round(SUM(bytes) / 1024 / 1024) freespace
INTO :m_user
FROM dba_free_space
WHERE tablespace_name = :("USERS")
GROUP BY tablespace_name;
printf("total = %f\n", m_total);
printf("user = %f\n", m_user);
m_ratio = (1-m_total/m_user)*100;
printf("tablespace ratio : %f\n",m_ratio);
EXEC SQL COMMIT WORK RELEASE;
return m_ratio;
}void main()
{
QueryTabSpaceRatio a;
a.connect();
printf("ratio = %f", a.tsFUN());
}