使用PL / SQL从表中选择所有内容

时间:2016-04-28 01:31:44

标签: plsql

因此,在我的作业中,我必须从特定表格中选择所有内容并输出它。我们给出的示例代码是:

declare
    current_bldg_code varchar2(5);
    cursor location_cursor is
        select room
        from location
        where bldg_code = current_bldg_code;
    current_room location.room%type;
begin
    current_bldg_code := 'LIB';
    open location_cursor;
    loop
        fetch location_cursor into current_room;
        exit when location_cursor%notfound;
        dbms_output.put_line(
            'The current room is ' || 
             current_bldg_code || ' ' || 
            current_room
    );
    end loop;
    close location_cursor;
end;
/

现在我想出了我自己的版本来摆脱我们正在使用的表格而且我没有得到任何数据。这就是我所拥有的:

解决:

declare
    c_first varchar2(30000);
    c_last varchar2(30000);
    c_mi char(10000);
    c_address varchar2(30000);
    c_dphone varchar2(10000);
    cursor customer_cursor is
        select c_first, c_mi, c_last, c_address, c_dphone
        from customer;
begin
    open customer_cursor;
    dbms_output.put_line('Clearwater Traders Mailing List');
    loop
        fetch customer_cursor into c_first, c_last, c_mi, c_address, c_dphone;
        exit when customer_cursor%notfound;
        dbms_output.put_line(c_first || ' ' || c_last || ' ' || c_mi || ' ' || c_address || ' ' || c_dphone);
    end loop;
    close customer_cursor;
end;
/

1 个答案:

答案 0 :(得分:1)

我建议在游标中使用ROWTYPE变量:

RewriteCond %{HTTP_HOST} ^domain1.com$ [NC]
RewriteRule ^aa/bb-l(/.*)?$ http://www.domain2.com/ssd/sdew;as [R=301,L,NC]