Columns to String

Setup

Run the code on this page in SQL*Plus to create the sample tables, data, etc. used by the examples in this section.

Be sure to read Using SQL Snippets ™ before executing any of these setup steps.

create table t
(
  key   varchar2(10) ,
  val_1 varchar2(6)  ,
  val_2 varchar2(6)  ,
  val_3 varchar2(6)  ,
  note  varchar2(25)
);

insert into t values ( 'String 1' , 'a' , null, null , 'One NOT NULL, Two NULL'    );
insert into t values ( 'String 2' , null, 'b' , null , 'One NOT NULL, Two NULL'    );
insert into t values ( 'String 3' , null, null, 'c'  , 'One NOT NULL, Two NULL'    );
insert into t values ( 'String 4' , 'a' , 'b' , null , 'Two NOT NULL, One NULL'    );
insert into t values ( 'String 5' , 'a' , 'b' , 'c'  , 'Three NOT NULL, Zero NULL' );
insert into t values ( 'String 6' , null, null, null , 'Zero NOT NULL, Three NULL' );

commit;

column xml_string format a50

 



Linking to SQL Snippets ™

To link to this page in Oracle Technology Network Forums or OraFAQ Forums cut and paste this code.

  • [url=http://www.sqlsnippets.com/en/topic-12120.html]SQL Snippets: Columns to String - Setup[/url]

To link to this page in HTML documents or Blogger comments cut and paste this code.

  • <a href="http://www.sqlsnippets.com/en/topic-12120.html">SQL Snippets: Columns to String - Setup</a>

To link to this page in other web sites use the following values.

  • Link Text : SQL Snippets: Columns to String - Setup
  • URL (href): http://www.sqlsnippets.com/en/topic-12120.html