小编mi *_* ho的帖子

postgresql:USING CURSOR用于从一个数据库中提取数据并将它们插入另一个数据库

这是使用光标的另一种算法,但我很难修复它的错误...

CREATE OR REPLACE FUNCTION extractstudent()
RETURNS VOID AS 
$BODY$
DECLARE
    studcur SCROLL cursor FOR SELECT fname, lname, mname, address FROM student;
BEGIN    
    open studcur; 

    Loop
    --fetching 1 row at a time
    FETCH First FROM studcur;
    --every row fetched is being inserted to another database on the local site
    --myconT is the name of the connection to the other database in the local site
    execute 'SELECT * from dblink_exec(''myconT'', ''insert into temp_student values(studcur)'')';
    --move to the next row and execute …
Run Code Online (Sandbox Code Playgroud)

postgresql plpgsql

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

plpgsql ×1

postgresql ×1