IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SQL Procédural MySQL Discussion :

Convertir des champs "text" contenant du RichText


Sujet :

SQL Procédural MySQL

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    84
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Octobre 2002
    Messages : 84
    Par défaut Convertir des champs "text" contenant du RichText
    Hello,
    Dans une procédure stockée, je cherche à convertir le contenu d'une colonne de type "text" contenant une chaîne représentant du RichText en texte brut.
    Existe-t-il une fonction SQL qui effectue cette transformation ?
    Merci d'avance.

  2. #2
    Membre éprouvé Avatar de giltonic
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    109
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 109
    Par défaut
    Citation Envoyé par jackfirst72
    Hello,
    Dans une procédure stockée, je cherche à convertir le contenu d'une colonne de type "text" contenant une chaîne représentant du RichText en texte brut.
    Existe-t-il une fonction SQL qui effectue cette transformation ?
    Merci d'avance.
    Pas à ma connaissance... Par contre certains composants (en Delphi notament) permettent de le faire.
    Je te conseille donc de regarder plutot au niveau applicatif et pas au niveau de la base de données.

    Salutations

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    84
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Octobre 2002
    Messages : 84
    Par défaut
    En effet, j'ai déjà récupéré et modifié une fonction Delphi pour faire cela au niveau applicatif, mais cela ne me suffit pas.
    Je dois faire une recherche à partir d'une procédure stockée sous MySql 5 et certaines des colonnes sont de type "text" et contiennent du "RichText". Je dois pouvoir rechercher des chaînes de caractères dans ces colonnes quelle que soit leur mise en forme. De plus, il m'est impossible de récupérer tous les enregistrements et de les traiter au niveau soft car il y a beaucoup trop de lignes (il s'agit d'articles).
    Donc le sujet reste ouvert et la palme à celui qui m'aidera.
    Merci quand même giltonic.

  4. #4
    Membre éclairé Avatar de Mamilie
    Inscrit en
    Février 2007
    Messages
    288
    Détails du profil
    Informations personnelles :
    Âge : 45

    Informations forums :
    Inscription : Février 2007
    Messages : 288
    Par défaut
    Salut

    Je ne suis pas sûre de mon coup mais tu devrais peut être utiliser la recherche en texte intégral.
    Pour cela tu as les index FULLTEXT et la fonction MATCH().
    Tu devrais trouver ça dans la doc du site MySQL.

    Edit:
    http://dev.mysql.com/doc/refman/5.0/...xt-search.html

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    84
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Octobre 2002
    Messages : 84
    Par défaut
    Merci de l'info, mais d'après ce que je connais du "FullText", ceci n'est applicable qu'aux tables de type "MyIsam". Et bien sûr je travaille avec le moteur "InnoDb"
    Merci quand même. Je travaille toujours sur cette quête.

  6. #6
    Membre éprouvé Avatar de giltonic
    Profil pro
    Inscrit en
    Juillet 2002
    Messages
    109
    Détails du profil
    Informations personnelles :
    Âge : 51
    Localisation : France

    Informations forums :
    Inscription : Juillet 2002
    Messages : 109
    Par défaut
    Perso j'avais essayé de faire une transformation au niveau SQL de la requete grace à l'applicatif (requetes dynamiques)... mais j'ai abandonné pour réaliser un champs calculé. Et finalement j'ai egalement abandonné car j'ai trouvé des composants qui le faisaient à ma place...

    Voici quand meme ma routine de de transformation Rtf2Str... C'est pas le pieds mais ca peut t'aider, notament pour les transformations.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    function Rtf2Str(AString:string):String;
    var temptext : string;
        start,i : integer;
    begin
         temptext := AString;
         // Effacement de la première ligne
         Delete(temptext,1,Pos(Chr(13)+Chr(10),temptext)+1);
         //
         temptext := stringreplaceall (temptext,'\'+chr(39)+'e7','ç');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'e8','è');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'e9','é');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'e1','é');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'e0','à');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'f9','ù');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'fb','û');
         temptext := stringreplaceall (temptext,'\}','#]#');
         temptext := stringreplaceall (temptext,'\{','#[#');
         temptext := stringreplaceall (temptext,'{\fonttbl','');
         temptext := stringreplaceall (temptext,'{\f0\fnil MS Sans Serif;}','');
         temptext := stringreplaceall (temptext,'{\f0\fnil\fcharset0 Verdana;}','');
         temptext := stringreplaceall (temptext,'{\f0\fnil\fcharset0 Arial;}','');
         temptext := stringreplaceall (temptext,'{\f1\fnil\fcharset2 Symbol;}','');
         temptext := stringreplaceall (temptext,'{\f2\fswiss\fprq2 System;}}','');
         temptext := stringreplaceall (temptext,'{\colortbl\red0\green0\blue0;}','');
         temptext := stringreplaceall (temptext,'\cf0','');
         temptext := stringreplaceall (temptext,'\deflang','');
         temptext := stringreplaceall (temptext,'{\rtf1\ansi\ansicpg1252\deff0}','');
         temptext := stringreplaceall (temptext,'{\pntext\f1\'+chr(39)+'B7\tab}','');
         temptext := stringreplaceall (temptext,'{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'+char(39)+'B7}}\fi-200\li200 ','');
         while pos ('\fs',temptext) >0 do
                 begin
                      application.processmessages;
                      start := pos ('\fs',temptext);
                      Delete(temptext,start,5);
                 end;
         temptext := stringreplaceall (temptext,'\viewkind4\uc1\pard\lang1036 ','');
         temptext := stringreplaceall (temptext,'\viewkind4\uc1\pard\lang1036\f0 ','');
         temptext := stringreplaceall (temptext,'\b0','');
         temptext := stringreplaceall (temptext,'\i0','');
         temptext := stringreplaceall (temptext,'\b','');
     
         temptext := stringreplaceall (temptext,'\i','');
         temptext := stringreplaceall (temptext,'\f1','');
         temptext := stringreplaceall (temptext,'\par }','');
         temptext := stringreplaceall (temptext,'\pard','');
         temptext := stringreplaceall (temptext,'\par'+#13+#10,'. ');
         temptext := stringreplaceall (temptext,'}','');
         temptext := stringreplaceall (temptext,'#]#','}');
         temptext := stringreplaceall (temptext,'#[#','{');
         temptext := stringreplaceall (temptext,'\\','\');
         result := temptext;
    end;
    Bonne Chance

  7. #7
    Membre éclairé Avatar de Mamilie
    Inscrit en
    Février 2007
    Messages
    288
    Détails du profil
    Informations personnelles :
    Âge : 45

    Informations forums :
    Inscription : Février 2007
    Messages : 288
    Par défaut
    Citation Envoyé par jackfirst72
    Merci de l'info, mais d'après ce que je connais du "FullText", ceci n'est applicable qu'aux tables de type "MyIsam". Et bien sûr je travaille avec le moteur "InnoDb"
    Oui désolée j'y avais plus pensé...
    Un contributeur acharné d'un forum MySQL a posté ça Sphinx
    Je ne sais pas ce que ça vaut mais si tu n'as vraiment pas d'autres solutions, tu peux toujours faire un test.

  8. #8
    Membre confirmé
    Profil pro
    Inscrit en
    Octobre 2002
    Messages
    84
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Octobre 2002
    Messages : 84
    Par défaut
    Merci à tous, mais finalement je me suis rabattu sur une solution simple mais occupant un peu plus d'espace dans la base.
    POut tout champ contenu du RichText sur lequel je dois faire des recherches, je crée un second champ (généralement dans une autre table) qui contient le texte "plain". Je gère la synchronisation des 2 types de champs lors de la sauvegarde depuis mon soft. Ainsi, pour les recherches, j'utilise les champs de type "plain".

  9. #9
    Membre éclairé

    Inscrit en
    Février 2004
    Messages
    342
    Détails du profil
    Informations forums :
    Inscription : Février 2004
    Messages : 342
    Par défaut
    Citation Envoyé par giltonic Voir le message
    Perso j'avais essayé de faire une transformation au niveau SQL de la requete grace à l'applicatif (requetes dynamiques)... mais j'ai abandonné pour réaliser un champs calculé.

    Voici quand meme ma routine de de transformation Rtf2Str... C'est pas le pieds mais ca peut t'aider, notament pour les transformations.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    function Rtf2Str(AString:string):String;
    var temptext : string;
        start,i : integer;
    begin
         temptext := AString;
         // Effacement de la première ligne
         Delete(temptext,1,Pos(Chr(13)+Chr(10),temptext)+1);
         //
         temptext := stringreplaceall (temptext,'\'+chr(39)+'e7','ç');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'e8','è');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'e9','é');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'e1','é');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'e0','à');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'f9','ù');
         temptext := stringreplaceall (temptext,'\'+chr(39)+'fb','û');
         temptext := stringreplaceall (temptext,'\}','#]#');
         temptext := stringreplaceall (temptext,'\{','#[#');
         temptext := stringreplaceall (temptext,'{\fonttbl','');
         temptext := stringreplaceall (temptext,'{\f0\fnil MS Sans Serif;}','');
         temptext := stringreplaceall (temptext,'{\f0\fnil\fcharset0 Verdana;}','');
         temptext := stringreplaceall (temptext,'{\f0\fnil\fcharset0 Arial;}','');
         temptext := stringreplaceall (temptext,'{\f1\fnil\fcharset2 Symbol;}','');
         temptext := stringreplaceall (temptext,'{\f2\fswiss\fprq2 System;}}','');
         temptext := stringreplaceall (temptext,'{\colortbl\red0\green0\blue0;}','');
         temptext := stringreplaceall (temptext,'\cf0','');
         temptext := stringreplaceall (temptext,'\deflang','');
         temptext := stringreplaceall (temptext,'{\rtf1\ansi\ansicpg1252\deff0}','');
         temptext := stringreplaceall (temptext,'{\pntext\f1\'+chr(39)+'B7\tab}','');
         temptext := stringreplaceall (temptext,'{\*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'+char(39)+'B7}}\fi-200\li200 ','');
         while pos ('\fs',temptext) >0 do
                 begin
                      application.processmessages;
                      start := pos ('\fs',temptext);
                      Delete(temptext,start,5);
                 end;
         temptext := stringreplaceall (temptext,'\viewkind4\uc1\pard\lang1036 ','');
         temptext := stringreplaceall (temptext,'\viewkind4\uc1\pard\lang1036\f0 ','');
         temptext := stringreplaceall (temptext,'\b0','');
         temptext := stringreplaceall (temptext,'\i0','');
         temptext := stringreplaceall (temptext,'\b','');
     
         temptext := stringreplaceall (temptext,'\i','');
         temptext := stringreplaceall (temptext,'\f1','');
         temptext := stringreplaceall (temptext,'\par }','');
         temptext := stringreplaceall (temptext,'\pard','');
         temptext := stringreplaceall (temptext,'\par'+#13+#10,'. ');
         temptext := stringreplaceall (temptext,'}','');
         temptext := stringreplaceall (temptext,'#]#','}');
         temptext := stringreplaceall (temptext,'#[#','{');
         temptext := stringreplaceall (temptext,'\\','\');
         result := temptext;
    end;
    j'ai deux questions par rapport à ce code ci-dessus

    1. on est d'accord que c'est bien une function mysql ?


    2. si oui,
    comment ca se fait qu'une recherche de "stringreplaceall" sur http://dev.mysql.com
    ne retrouve aucun résultat ?

    http://search.mysql.com/search?q=str...ang_en&x=0&y=0

    ===> dois-je en déduire que ca fait appel à une autre function custom de giltonic ?

    comme je n'ai pas encore fait de function custom en slq, je voudrais juste vérifier que je n'ai pas raté qqch d'évident


+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Récuperation des donnees depuis un tableau contenant des champs de texte
    Par dev2010 dans le forum Développement Web en Java
    Réponses: 0
    Dernier message: 06/09/2010, 14h12
  2. rendre visible des champs de texte
    Par lnikolanta dans le forum Général JavaScript
    Réponses: 17
    Dernier message: 16/09/2005, 18h07
  3. Réponses: 5
    Dernier message: 06/07/2005, 21h14

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo