Tags: atatic, built, columns, database, delimiter, dynamic, include, mysql, oracle, output, select, sql, statement, static, text

How do you include static text in select statement in Dynamic pl/sql

On Database » Oracle

1,876 words with 2 Comments; publish: Fri, 08 Feb 2008 23:41:00 GMT; (25062.50, « »)

I want to include some atatic text and get the output of 4 columns joined with a ":" delimiter within them in a select statement built using Dynamic PL/SQL. How do I build it.

e.g.

Normal select statement would be

select 'MY SKU IS : ', col1||':'||col2||':'||col3||':'||col4 from table1 where ...where condition

and output looks like :

MY SKU IS A:B:C:D

MY SKU IS a:b:c:d

...

Dynamically I have -

SQL_Stmt := 'select 'MY SKU IS : ', col1||':'||col2||':'||col3||':'||col4 from table1 where '|| wherecondition;

I understand that this does not work because the single quote terminates the string. But my question is how do I achieve the same result with dynamic PL/SQL ? How do I include the static strings and the delimiters. I have tried using double quote, '\'...

??

All Comments

Leave a comment...

  • 2 Comments
    • SQL_Stmt := 'select ''MY SKU is ' || col1 || '':'' || col2 || '':'' || col3 || '':'' || col4 || ' from table1 where ' || wherecondition;

      #1; Thu, 21 Feb 2008 22:31:00 GMT
    • Correction:

      SQL_Stmt := 'select ''MY SKU is '' || col1 || '':'' || col2 || '':'' || col3 || '':'' || col4 from table1 where ' || wherecondition;

      #2; Thu, 21 Feb 2008 22:32:00 GMT