PostgreSQL错误:当没有预期时返回结果

时间:2018-06-08 17:34:17

标签: postgresql function

我在PostgreSQL中创建了一个函数,假设它将数据输入到表中。第一行数据在表中,但后来我得到了这个错误:

org.postgresql.util.PSQLException:当没有人预期时返回结果。

除此之外,我的java和函数语法都可以,导致我的java程序停止。 这是我的postgreSQL代码:

    CREATE OR REPLACE FUNCTION public.populategdelt(globaleventid bigint,day bigint,actor1code character varying,actor1name character varying,actor1countrycode character varying,
actor1knowngroupcode character varying,actor1ethniccode character varying,actor1religion1code character varying,actor1religion2code character varying,actor1type1code character varying,
actor2code character varying,actor2name character varying,actor2countrycode character varying,actor2knowngroupcode character varying,actor2ethniccode character varying,
actor2religion1code character varying,actor2religion2code character varying,actor2type1code character varying,eventcode character varying,eventbasecode character varying,
quadclass bigint,goldsteinscale double precision,nummentions bigint,numsources bigint,avgtone double precision,actor1geo_type bigint,actor1geo_fullname character varying,actor1geo_countrycode character varying,actor1geo_adm1code character varying,actor1geo_adm2code character varying,actor1geo_lat double precision,actor1geo_long double precision,actor2geo_type bigint,actor2geo_fullname character varying,actor2geo_countrycode character varying,actor2geo_adm1code character varying,actor2geo_adm2code character varying,actor2geo_lat double precision,actor2geo_long double precision,actiongeo_type bigint,actiongeo_fullname character varying,actiongeo_countrycode character varying,actiongeo_adm1code character varying,actiongeo_adm2code character varying,actiongeo_lat double precision,actiongeo_long double precision,sourceurl character varying)
   RETURNS void

   LANGUAGE 'sql'
   VOLATILE
   PARALLEL UNSAFE
   COST 100
AS $BODY$insert into data values (  globaleventid, day, actor1code, actor1name, actor1countrycode, actor1knowngroupcode,
actor1ethniccode, actor1religion1code, actor1religion2code, actor1type1code, actor2code, actor2name, actor2countrycode,
actor2knowngroupcode, actor2ethniccode, actor2religion1code, actor2religion2code, actor2type1code, eventcode, eventbasecode,
quadclass, goldsteinscale, nummentions, numsources, avgtone, actor1geo_type, actor1geo_fullname, actor1geo_countrycode,
actor1geo_adm1code, actor1geo_adm2code, actor1geo_lat, actor1geo_long, actor2geo_type, actor2geo_fullname, actor2geo_countrycode,
actor2geo_adm1code, actor2geo_adm2code, actor2geo_lat, actor2geo_long, actiongeo_type, actiongeo_fullname, actiongeo_countrycode,
actiongeo_adm1Code, actiongeo_adm2code, actiongeo_lat, actiongeo_long, sourceurl);

$BODY$;

我需要不同的退货声明吗?因为我想要它做的是转到下一行数据,但是如果它因此错误而停止,则不能这样做。如果void不能用于此功能,我应该返回什么?

1 个答案:

答案 0 :(得分:0)

在Java中使用execute()代替executeUpdate()修复了问题!