[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

11/07/2009 at 03:48PM PST, ID: 24881005 | Points: 500
[x]
Attachment Details

Embedded SQL queries

Asked by fghost00 in PL / SQL, Databases Miscellaneous, Embedded Databases

Tags: Sql, database

Hi, I have the following problem and been stuck on it for a while
I have 4 relations:
Product(maker,model, type)
PC(model, speed, ram, hd, price)
Laptop(model, speed, ram, hd, screen, price)
Printer(model, color, type,price)

The question is as follows:
Ask the user for a manufacturer. Print the specifications of all products
by that manufacturer. That is, print the model number, product-type.
and all the attributes of whichever relation is appropriate for that type.

This is what I have done so far (not sure is correct)
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
void specs()
	EXEC SQL BEGIN DECLARE SECTION;
	char manf[30], SQLSTATE[6];
	char type[15];
	int model, speed, ram, hd, price, screen;
	boolean color,
	int tempModel, tempSpeed, tempRam, tempHD,tempPrice,tempScreen;
	EXEC SQL END DECLARE SECTION;
	EXEC SQL DECLARE pCursor CURSOR FOR
		      SELECT model, type FROM Product;
	
	EXEC SQL OPEN pCursor;
	manf = reader.readChar() // read manufacturer from the user and store in manf
	EXEC SQL FETCH FROM pCursor INTO : model, : type;
	
	//if Product is empty there's no answer and we should exit
	
	while(1) {
		EXEC SQL FETCH pcCursor INTO: tempModel, : tempType;
		
		if(type == PC){
[+][-]11/08/09 08:31 AM, ID: 25770912

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625