listing1701 sql


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 aug94
sql
sql
tips portable sql
1590595270 1 listing01
listing10
sql createtable
Sql ib
1590595270 1 listing12

więcej podobnych podstron