PLSQL Select more than one values and put it into more than one variable

时间:2019-01-29 11:37:19

标签: sql oracle plsql

is it possible to write a PLSQL Select Into Statement for many values?

Pseudocode:

SELECT X,Y,Z INTO v1,v2,v3 FROM.....

If so, can anyone show me an example?

2 个答案:

答案 0 :(得分:2)

您可以对多个变量使用INTO子句。我为您创建了一个示例块。

declare 
x int;
y int;
z int;
begin
select 1,2,3 into x,y,z from dual;
 dbms_output.Put_line('x='||x||',y='||y||',z='||z);
end;

答案 1 :(得分:1)

我知道您在这里询问有关INSERT INTO语句的问题,但是我想在这里显示的另一种选择是使用游标。

class gBase
{
public:
    // The user will implement a vector of a vector of functions that can be called as g[i][alpha](k)
    virtual std::vector<std::function<double(double)> > operator[] (uint i) = 0;
};

class g : public gBase
{
public:
    g() : g_funcs({{[this](double k){ return g_00(k); }, [this](double k){ return g_01(k); }}}) {}
    std::vector<std::function<double(double)> > operator[] (uint i)
    {
        return g_funcs[i];
    }
private:
    std::vector<std::vector<std::function<double(double)> > > g_funcs;

    // define each function.
    cdouble g_00(double k)
    {
        return 5.0;
    }

    cdouble g_01(double k)
    {
        return 3.0;
    }
};