postgresql - 我必须在 Postgres plpgsql 过程的每次迭代中将变量重置为 null 吗?
问题描述
我有这个简单的 plpgsql 语言的 postgres 过程(示例)。在调用 select into 之前我必须执行“_current_id = null”吗?or _current_id always will be null when select not found any matching row?. 我知道我可以测试,但我不想将来因为不好的做法而受苦。但也不想添加不必要的额外代码行
BEGIN
DECLARE
_current_id integer;
_row record;
BEGIN
FOR _row IN select * from my_table LOOP
select id into _current_id from my_second_table where name=row.name;
if (_current_id is null) then
--my code here
end if;
END LOOP;
END;
解决方案
推荐阅读
- jquery - Jquery滚动到偏移目标div总是
- android - ScrollView里面的MotionLayout在状态改变后不更新高度
- svn - 如何代理或模拟另一个 SVN 服务器的用户?
- android - 当用户持有项目时,在回收站视图中展开和折叠项目
- templates - 所有模板内容的集合
- python - 正则表达式删除
- python - 如何将一个数组中的元素数据匹配到另一个数组中的索引
- angular - How to access property in item from a ngFor loop?
- python - Python用可变参数实现抽象方法并满足linter
- spss - 如何创建一个循环通过日期和唯一客户 ID 的指标?