Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/67.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中打印其值_Sql_Postgresql_Psql - Fatal编程技术网

正在尝试声明表类型的变量,并在PostgreSQL中打印其值

正在尝试声明表类型的变量,并在PostgreSQL中打印其值,sql,postgresql,psql,Sql,Postgresql,Psql,下面是我使用的语法 declare v_data emp_tab ; BEGIN select * into v_data from emp_tab where emp_id= 121 limit 1; raise notice 'Value: %', v_data.emp_info; END; 这是一个错误。“emp_选项卡处或附近出现语法错误” 请帮忙。试试这个: do $$ declare v_data emp_tab

下面是我使用的语法

 declare
      v_data emp_tab ;
    BEGIN
      select * into v_data from emp_tab where emp_id= 121 limit 1;
      raise notice 'Value: %', v_data.emp_info;
    END;
这是一个错误。“emp_选项卡处或附近出现语法错误” 请帮忙。

试试这个:

do $$
    declare
    v_data emp_tab ;
    BEGIN
        select * into v_data from emp_tab where emp_id= 121 limit 1;
        raise notice 'Value: %', v_data.emp_info;
    END;
$$ language plpgsql