Re: Can I use variable to store sql data?

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Can I use variable to store sql data?
Дата
Msg-id 20051029150953.GA29677@wolff.to
обсуждение исходный текст
Список pgsql-general
Please post questions to relevant lists. This question did not belong on
the patches list. I have moved the discussion to the general list.

Please don't reply to other threads to start new ones. This messes up the
archives and won't help people see your question.

On Mon, Oct 17, 2005 at 09:55:50 +0300,
  NosyMan <nosyman@gmail.com> wrote:
> Hi,
>
> The scenario:
> SELECT id_product FROM products WHERE product_code='PRD-030';
>
> Now I want to insert id_product into another table :
>
> INSERT INTO product_sales( id_product, sale_date)
> INSERT INTO product_sales( id_product, sale_date)
> INSERT INTO product_sales( id_product, sale_date)

You can do something like:
INSERT INTO product_sales values (
  (SELECT id_product FROM products WHERE product_code='PRD-030'),
  sales_date);

Also if id_product was just assigned a value from a sequence in the same
session, you could use the currval function to get its value.

В списке pgsql-general по дате отправления:

Предыдущее
От: Oleg Bartunov
Дата:
Сообщение: Re: which charset use for cyrilic?
Следующее
От: Michael Fuhr
Дата:
Сообщение: Re: querying while copying into a table and optimizations