How to do a nested loop or something like that?

08 May '16, 09:15 PM
3,024 Views
No Forum Badges

Hi,
 

My classmates and I are trying to do a nested loop for an exercise but ther is no progress even we dont know if we really need a nested loop or not. The problem to resolve is:

With a Selector we get all tuples of "Carrito". "Carrito" has an oid and oidProduct, ProductName, Quantity, ProductPrice... to the first loop we pass oid to imputArray and OidProducto to oidProducto and from this loop we pass nextelement(oidProducto) to imputArray, OidProducto_PASSING to oidProducto and in the iterationCount the quantity of the Product. Then we do a connect between "Pedido" and "Producto", and back to the inner loop and when it's finish, back to the external looop.

we want in the table of the relationship n:m of "Pedido" "Producto" this result:

oid           pedido_oid         Producto_oid

1                 1                              3

2                 1                              3

3                 1                             4

4                 2                             3

and we obtein as result:

oid          pedido_oid                Producto_oid

1                 1                                   3

2                 1                                   4

3                 2                                   3

PD: the quantity attribute in the Carrito is te n-times we need to do the connect between a "Producto" and "Pedido".

Thanks in advace and sorry for my english.

MIguel Angel Holgado.

 
x 0
Follow
Answer Answer at this question and get points!
No Forum Badges

Can you please post the flow chart for the logical flaow you plan to have?

 
x 0
No Forum Badges

Hi Rafique,

Sorry by the delay (I was in exam season), it´s no longer necessary the answer because of we delivered the project without that part.

We notice that there is no problem in the nested loop intead the error was in my understanding of the table "pedido-producto". There are two columns intead of three, the first colum is not a column per se. I was watching the table of the n:m relationship in pgadmin3 so the first column is the number of the tuple (my mistake). the primary key is the other two real columns so it's not allowed to have repeited values.

It was a nooby mistake. thanks for your interst.

Best regards Miguel Angel Holgado.

 
x 0
Answer at this question and get points!