Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 14: XML Publishing & Storage

Similar presentations


Presentation on theme: "Lecture 14: XML Publishing & Storage"— Presentation transcript:

1 Lecture 14: XML Publishing & Storage
Monday, November 1, 2004

2 Example Product (pname, price, quantity, maker) Company (cname, city)

3 XML Publishing with Cursors
Void simpleInsert() { EXEC SQL BEGIN DECLARE SECTION; char n[20], c[30], city[30]; /* product-name, company-name, city */ int p, q; /* price, quantity */ char SQLSTATE[6]; EXEC SQL END DECLARE SECTION;

4 XML Publishing with Cursors
EXEC SQL DECLARE crsCompany CURSOR FOR SELECT cname, city FROM company; EXEC SQL DECLARE crsProduct CURSOR FOR SELECT pname, price, quantity FROM Product WHERE maker = :c;

5 XML Publishing with Cursors
EXEC SQL OPEN crsCompany; EXEC SQL FETCH FROM crsCompany INTO :c, :city; Printf(“<company> <name> %s </name> <city> %s </city>”, c, city); while (1) { EXEC SQL FETCH FROM crsProduct INTO :n, :p, :q; if (NO_MORE_TUPLES) break; printf(“ <product>\n”); printf(“ <name> %s </name>\n”, n); printf(“ <price> %d </price>\n”, p); printf(“ <quantity> %d </quantity>\n”, q); printf(“ <maker> %s </maker>\n”, c); printf(“ </product>\n”); } EXECT SQL CLOSE crs; printf(“</company>\n”);

6 What is NO_MORE_TUPLES ?
#define NO_MORE_TUPLES !(strcmp(SQLSTATE,”02000”))


Download ppt "Lecture 14: XML Publishing & Storage"

Similar presentations


Ads by Google