检查在字符串数组整数 [英] Check for integer in string array
问题描述
我想检查一个字符串数组已转换的整数的存在。这坐着一个过程里面其中:
I am trying to check a string array for existence of a converted integer number. This sits inside of a procedure where:
nc_ecosite
是整数
变量结果 current_consite
是一个字符串数组结果生态园
是整数
结果 current_ecosite_nc
是双击
nc_ecosite
is an integer
variable
current_consite
is a string array
ecosite
is an integer
current_ecosite_nc
is double
IF to_char(nc_ecosite, '999') IN
(select current_consite from current_site_record
where current_ecosite_nc::integer = nc_ecosite) THEN
ecosite := nc_ecosite;
结果总是来自于 ELSIF
后面的第一个如果
。这发生在 nc_ecosite
是数组(从检查)英寸为什么生态园
未与 nc_ecosite
填充当值匹配?
The result always comes from the ELSIF
that follows the first IF
. This occurs when nc_ecosite
is in the array (from checks). Why is ecosite
not being populated with nc_ecosite
when values are matching?
我在Postgres 9.3里pgAdmin的工作。
I am working with Postgres 9.3 inside pgAdmin.
推荐答案
我发现下面来提供所需的结果:
I found the following to provide the desired result:
IF nc_ecosite in
(select (unnest(string_to_array(current_consite, ',')))::integer
from current_site_record
where current_ecosite_nc::integer = nc_ecosite) THEN
ecosite := nc_ecosite::integer;
这篇关于检查在字符串数组整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!