Oracle SQL, concaténation de plusieurs colonnes + ajout de texte

En gros, je veux afficher ceci (une ligne entière dans une colonne) :

J'aime [colonne type] le gâteau avec [colonne glaçage] et [colonne fruits].

Le résultat devrait être :

Cake_Column
----------------

I like chocolate cake with whipped_cream and a cherry.

I like strawberry cake with vanilla_cream and a lemon_slice.

etc.

etc.

J'ai besoin d'une sorte d'instruction TO_CHAR qui fasse ([column] "some text&quot ; [column]) "new_column_name" ;

Qu'est-ce que je suis censé savoir ?

Vous disposez de deux options pour concaténer des chaînes de caractères dans Oracle :

  • [CONCAT][1]
  • [Utilisation de ||][2]

Exemple de CONCAT :

CONCAT(
  CONCAT(
    CONCAT(
      CONCAT(
        CONCAT('I like ', t.type_desc_column), 
        ' cake with '), 
      t.icing_desc_column),
    ' and a '),
  t.fruit_desc_column)

Utilisation de || exemple :

'I like ' || t.type_desc_column || ' cake with ' || t.icing_desc_column || ' and a ' || t.fruit_desc_column

[1] : http://techonthenet.com/oracle/functions/concat.php [2] : http://techonthenet.com/oracle/functions/concat2.php

Commentaires (2)

Avez-vous essayé l'opérateur || ?

[Documentation sur l'opérateur de concaténation d'Oracle >>>][1]

[1] : http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/fundamentals.htm#CIHHHEJG

Commentaires (0)
select 'i like' || type_column || ' with' ect....
Commentaires (1)