Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 在Postgres 8.2中执行动态SQL_Postgresql - Fatal编程技术网

Postgresql 在Postgres 8.2中执行动态SQL

Postgresql 在Postgres 8.2中执行动态SQL,postgresql,Postgresql,我试图使用动态SQL在函数内创建一个表,并立即将其复制到另一个表中 execute 'create table week_temp as select w.*, ww.* from employer_weekly w left join employer_weekly_' || $1 || '_2 ww on w.w_employer::int = ww.emp_' || $1 || '::int'; drop table if exists empl

我试图使用动态SQL在函数内创建一个表,并立即将其复制到另一个表中

execute 'create table week_temp as 
    select w.*, ww.*
    from employer_weekly w
    left join employer_weekly_' || $1 || '_2 ww
        on w.w_employer::int = ww.emp_' || $1 || '::int';

drop table if exists employer_weekly;
create table employer_weekly as select * from week_temp;
我收到以下错误:

错误:错误:与OID 9288742的关系不存在

上下文:SQL语句“创建雇主表作为select*from” 每周临时工“

通过手动检查,我可以看到week_temp并可以正确访问它


如果有任何线索,我将不胜感激

一匹没有名字的马说了什么


但是,您看到的问题是,正在编译函数中的非动态语句。这意味着“FROM week_temp”正在查看不再存在的week_temp的旧版本。让这句话也成为动态SQL,它应该会起作用。

Postgres 8.2早已过时并被遗忘。您现在应该升级到维护的(=支持的版本)。