Re: INSERT question

От: Tom Lane
Тема: Re: INSERT question
Дата: ,
Msg-id: 25641.1102956494@sss.pgh.pa.us
(см: обсуждение, исходный текст)
Ответ на: INSERT question  (sarlav kumar)
Ответы: Re: INSERT question  (sarlav kumar)
Список: pgsql-novice

Скрыть дерево обсуждения

INSERT question  (sarlav kumar, )
 Re: INSERT question  (Bruno Wolff III, )
 Re: INSERT question  (Tom Lane, )
  Re: INSERT question  (sarlav kumar, )
 Re: [PERFORM] INSERT question  (george young, )

sarlav kumar <> writes:
> Is there a way to write the INSERT as follows?

> INSERT into merchant_buyer_country (merchant_id,country,enabled,group_id)  values (1203,
> (SELECT code FROM country WHERE send IS NOT NULL OR receive IS NOT NULL), 'true',1);

> I tried this, but I get the following problem:
> ERROR:  More than one tuple returned by a subselect used as an expression.

INSERT into merchant_buyer_country (merchant_id,country,enabled,group_id)
  SELECT 1203, code, 'true', 1 FROM country
  WHERE send IS NOT NULL OR receive IS NOT NULL;

            regards, tom lane


В списке pgsql-novice по дате сообщения:

От: sarlav kumar
Дата:
Сообщение: Re: INSERT question
От: "Tjibbe Rijpma"
Дата:
Сообщение: How to create a (recursive) function that get all parents from: a tree with loops in it.