Select_customer_accounts() {
account_type *account_p;
account_type_ref *account_ref_p;
sql_cursor account_cur;
char accountname[20];
int custid;
EXEC SQL DECLARE custaccount_cur CURSOR FOR
SELECT c.id, CURSOR(SELECT * FROM TABLE(c.accounts))
FROM customers c;
EXEC SQL OPEN custaccount_cur;
EXEC SQL ALLOCATE :account_cur;
EXEC SQL ALLOCATE :account_ref_p;
while(1){
EXEC SQL FETCH custaccount_cur INTO :custid, :account_cur;
cout << "Customer ID : " << custid << " has the following accounts : \n \n";
while(1){
EXEC SQL FETCH :account_cur INTO :account_ref_p;
EXEC SQL OBJECT DEREF :account_ref_p INTO :account_p;
EXEC SQL OBJECT GET name FROM :account_p INTO :accountname;
cout << accountname << "\n";
}
}
EXEC SQL CLOSE custaccount_cur;
EXEC SQL CLOSE :account_cur;
EXEC SQL FREE :account_cur;
EXEC SQL FREE :account_ref_p;
}
Wyszukiwarka
Podobne podstrony:
sql framework aug94sqlsqltips portable sql1590595270 1 listing01listing10sql createtableSql ib1590595270 1 listing12więcej podobnych podstron