Hi,

The scenario:
1. SELECT id_product FROM products WHERE product_code='PRD-030';

Now I want to insert id_product into another table :

2. INSERT INTO product_sales( id_product, sale_date)
    INSERT INTO product_sales( id_product, sale_date)
    INSERT INTO product_sales( id_product, sale_date)

As you can see the 'id_product' is not known. I know one solution:
INSERT INTO product_sales(  (SELECT id_product FROM products WHERE 
product_code='PRD-030'), sale_date)
... but I don't like it very mutch.

Can I set id_product from statement 1 to a variable and use that variable into 
statements 2.


Thanks.

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

Reply via email to