【问题标题】:SQL ORACLE Creating a column name with using htf (hypertext functions)SQL ORACLE 使用 htf(超文本函数)创建列名
【发布时间】:2018-07-20 20:29:55
【问题描述】:

我正在处理 SQL ORACLE DATABASE 并且我创建了一个表,而不是进入 foor lob 并使用 htf 将表转换为 html 格式。

set define off

create table show_mail (id number, data varchar2(25));

insert into show_mail values(101, 'one hundred & one')
insert into show_mail values(202, 'two hundred & two')
insert into show_mail values(303, 'three hundred & three')


declare
v_html varchar2(32767);
begin
v_html := htf.tableopen;
for i in (select * from show_mail) loop
v_html := v_html || htf.tableopen('border="1px"');
v_html := v_html || htf.tablerowopen;
v_html := v_html || htf.tableheader('ID');
v_html := v_html || htf.tableheader('DATA');
v_html := v_html || htf.tablerowclose;
v_html := v_html || htf.tablerowopen;
v_html := v_html || htf.tabledata(i.id);
v_html := v_html || htf.tabledata(htf.escape_sc(i.data));  
v_html := v_html || htf.tablerowclose;
v_html := v_html || htf.tableclose;
end loop;
v_html := v_html || htf.tableclose;
dbms_output.put_line(v_html);
end;

我使用这段代码和类似的结果;

ID  DATA
101 one hundred & one
ID  DATA
202 two hundred & two
ID  DATA
303 three hundred & three

是否可能只有一个列名而不重复?

【问题讨论】:

    标签: sql oracle plsql


    【解决方案1】:

    这样做:

    DECLARE
        v_html VARCHAR2(32767);
    BEGIN
        v_html := v_html || HTF.TABLEOPEN('border="1px"');
        v_html := v_html || HTF.TABLEROWOPEN;
        v_html := v_html || HTF.TABLEHEADER('ID');
        v_html := v_html || HTF.TABLEHEADER('DATA');
        v_html := v_html || HTF.TABLEROWCLOSE;
        FOR i IN (SELECT * FROM show_mail) LOOP
            v_html := v_html || HTF.TABLEROWOPEN;
            v_html := v_html || HTF.TABLEDATA(i.id);
            v_html := v_html || HTF.TABLEDATA(HTF.ESCAPE_SC(i.data));  
            v_html := v_html || HTF.TABLEROWCLOSE;
        END LOOP;
        v_html := v_html || HTF.TABLECLOSE;
    
        DBMS_OUTPUT.PUT_LINE(v_html);
    end;
    

    【讨论】:

    • 你太棒了。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-30
    • 2014-12-02
    • 2011-11-15
    • 2012-01-04
    • 1970-01-01
    • 2021-01-21
    • 1970-01-01
    相关资源
    最近更新 更多