首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >insert into not work in function postgresql

insert into not work in function postgresql
EN

Stack Overflow用户
提问于 2017-05-15 23:47:02
回答 1查看 328关注 0票数 0

我有以下过程,当我运行它时,它显示控制台中的所有插入,字段ind_id增加,但不保存任何记录。

代码语言:javascript
复制
create or replace function renameDescripcionTramite() returns varchar as $$
declare 
    aguja record;
    pajar record;
    last_id integer;
begin
    for aguja in 
        select trim(t.tra_descripcion) tra_descripcion  from tab_tramite t 
        join tab_serietramite st on st.tra_id = t.tra_id 
        group by t.tra_descripcion
        order by t.tra_descripcion loop
            for pajar in
                select u.uni_id,s.ser_id,st.sts_id,t.tra_id,trim(t.tra_descripcion) tra_descripcion
                from tab_unidad u join tab_series s  on u.uni_id = s.uni_id
                join tab_serietramite st on st.ser_id = s.ser_id 
                join tab_tramite t on t.tra_id = st.tra_id
                order by u.uni_id,s.ser_id,t.tra_id loop
                if aguja.tra_descripcion = pajar.tra_descripcion then
                    insert into tab_indexpediente (uni_id,ser_id,tra_id) values (pajar.uni_id,pajar.ser_id,pajar.tra_id);-- returning ind_id into last_id;
                    --update tab_serietramite set wid = last_id where sts_id = pajar.sts_id;
                    RAISE NOTICE 'insert into tab_indexpediente (uni_id,ser_id,tra_id) values (%',cast(pajar.uni_id as text) 
                        || ',' || cast(pajar.ser_id as text) || ',' || cast(pajar.tra_id as text) || ')';
                end if;
            end loop;
        --RAISE NOTICE '  ANTERIOR ES %',aguja;
    end loop;
    return tra_descripcion;
end;
$$ LANGUAGE plpgsql;

有人能帮帮我吗?

EN

回答 1

Stack Overflow用户

发布于 2017-05-16 02:03:46

是的,我不知道这会影响程序。

感谢laurenz Albe

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43983765

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档