查询没有结果数据postgresql的目标

时间:2015-11-16 07:19:09

标签: postgresql plpgsql

  

我试图通过使用dblink through function从不同的数据库中获取数据,但是收到错误"查询没有结果的目的地   数据"
  错误:查询没有结果数据的目的地
  提示:如果   如果要放弃SELECT的结果,请改用PERFORM。

这是我的查询

-- ns_core_customer_group

  insert into 
  ns_core_customer_group(customer_group_id,
  customer_group_code,
  customer_group_name,
  advance_percent,
  discount_percent,
  sync_id,
  is_active,

  is_deleted,
  created_stamp,
  created_user,
  last_modified_stamp,
  last_modified_user)

  select customer_group_id,
  concat(local_store_id,'-',customer_group_id),
  customer_group_name,
  advance_percent,
  discount_percent,
  3,
  is_active,
  is_deleted,
  created_stamp,
  created_user,
  last_modified_stamp,
  last_modified_user

  from dblink('host=localhost user=postgres password=admin dbname=Fulfil_1.9.1','select customer_group_id,
  customer_group_code,
  customer_group_name,
  advance_percent,
  discount_percent,
  is_active,
  is_deleted,
  created_stamp,
  created_user,
  last_modified_stamp,
  last_modified_user from ns_core_customer_group')

  AS t1(customer_group_id integer,
  customer_group_code character varying(50),
  customer_group_name character varying(255),
  advance_percent numeric(5,2),
  discount_percent numeric(5,2),
  is_active integer,
  is_deleted integer,
  created_stamp timestamp without time zone,
  created_user integer,
  last_modified_stamp timestamp without time zone,
  last_modified_user integer);

  select setval('ns_core_customer_group_id_seq', (select coalesce(max(customer_group_id),0)+1 from ns_core_customer_group), false);

1 个答案:

答案 0 :(得分:0)

执行此操作:

setval(
  'ns_core_customer_group_id_seq', 
  (select coalesce(max(customer_group_id),0)+1 from ns_core_customer_group), 
  false
  );