【问题标题】:query has no destination for result data postgresql查询没有结果数据 postgresql 的目的地
【发布时间】:2015-11-16 07:19:09
【问题描述】:

我正在尝试通过函数使用 dblink 从不同的数据库中获取数据,但出现错误“查询没有结果的目的地 数据”
错误:查询没有结果数据的目的地
提示:如果 如果您想丢弃 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);

【问题讨论】:

  • 问题看不懂,请补充详细信息(存储过程在哪里??)

标签: postgresql plpgsql


【解决方案1】:

执行此操作:

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

【讨论】:

    猜你喜欢
    • 2016-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 2021-11-07
    相关资源
    最近更新 更多