does not fetch the information from the database

Hi, i'm doing this proC project about purchasing. i've been stuck on this coding for about a week.Can anyone help me?

int main()
{
EXEC SQL BEGIN DECLARE SECTION;
char mat_id[11],MAT_code[10],MAT_name[10],MAT_price[20],SUPP_id[10];
EXEC SQL END DECLARE SECTION;

int totalMATERIAL=0;

fnConnectDB();
system("cls");
cout<<endl<<endl;
cout<<"\t\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"<<endl;
cout<<"\t\t* *"<<endl;
cout<<"\t\t* \t\t M A T E R I A L L I S T \t\t *"<<endl;
cout<<"\t\t* *"<<endl;
cout<<"\t\t* * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"<<endl<<endl;
cout<<"\n";
cout<<"Supplier ID : ";
cin>>SUPP_id;
cout<<endl;
strncpy_s(mat_id,SUPP_id,10);

EXEC SQL SELECT SUPP_id INTO :SUPP_id FROM MATERIAL WHERE SUPP_id = :SUPP_id;
if (sqlca.sqlcode==0)
{
cout<<setfill('-')<<setw(80)<<"-"<<endl<<endl;
cout<<"CODE\t\tNAME\t\tPRICE\n";
cout<<"\n";
cout<<setfill('-')<<setw(80)<<"-"<<endl;

EXEC SQL DECLARE MATERIALCursor CURSOR FOR
select * from MATERIAL;

EXEC SQL OPEN MATERIALCursor;

/* loop through the cursor and break the loop when end*/
EXEC SQL WHENEVER NOT FOUND DO break;
while (1)
{
/* fetch the data from cursor and display*/
EXEC SQL FETCH MATERIALCursor
INTO :MAT_code,:MAT_name,:MAT_price;
cout<<MAT_code<<"\t"<<MAT_name<<"\t"<<MAT_price<<endl;
cout<<setfill('-')<<setw(80)<<"-"<<endl;
totalMATERIAL++;

}
EXEC SQL WHENEVER NOT FOUND CONTINUE;

EXEC SQL CLOSE MATERIALCursor;

cout<<"\n\nTotal Material : "<<totalMATERIAL<<endl;
cout<<">> Press Any Key to Continue"<<endl;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cin.get();
system("cls");
}
else
{
cout<<"Supplier not found . . . "<<endl;
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cin.get();
}
}




why does it not fetch the information from the database?
Last edited on
Because c++ has no build in SQL-statements. You need a library like this

http://www.sqlapi.com/

or other in order to make it work
coder777 >> It's ProC, not standard C++... So it HAS build-in SQL.

firefly >> diffcult to say...
- Are you sure your DB connection is OK ?
- Have you "total material" equals 0 or "supplier not found" ?

Say more...
a have never heard about proC. Mind to provide a link?
Topic archived. No new replies allowed.