Précédent   Forum des professionnels en informatique > Bases de données > MySQL > SQL Procédural
SQL Procédural Forum d'entraide sur les triggers, les procédures stockées et les fonctions en MySQL
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 19/03/2007, 16h15   #1
Membre à l'essai
 
Inscription : octobre 2002
Messages : 84
Détails du profil
Informations forums :
Inscription : octobre 2002
Messages : 84
Points : 24
Points : 24
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.
jackfirst72 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/03/2007, 18h39   #2
Membre habitué
 
Avatar de giltonic
 
Inscription : juillet 2002
Messages : 109
Détails du profil
Informations personnelles :
Âge : 38

Informations forums :
Inscription : juillet 2002
Messages : 109
Points : 124
Points : 124
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
giltonic est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/03/2007, 08h12   #3
Membre à l'essai
 
Inscription : octobre 2002
Messages : 84
Détails du profil
Informations forums :
Inscription : octobre 2002
Messages : 84
Points : 24
Points : 24
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.
jackfirst72 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/03/2007, 09h56   #4
Membre éclairé
 
Avatar de Mamilie
 
Inscription : février 2007
Messages : 289
Détails du profil
Informations personnelles :
Âge : 32

Informations forums :
Inscription : février 2007
Messages : 289
Points : 315
Points : 315
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
Mamilie est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/03/2007, 10h57   #5
Membre à l'essai
 
Inscription : octobre 2002
Messages : 84
Détails du profil
Informations forums :
Inscription : octobre 2002
Messages : 84
Points : 24
Points : 24
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.
jackfirst72 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/03/2007, 11h57   #6
Membre habitué
 
Avatar de giltonic
 
Inscription : juillet 2002
Messages : 109
Détails du profil
Informations personnelles :
Âge : 38

Informations forums :
Inscription : juillet 2002
Messages : 109
Points : 124
Points : 124
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 :
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
giltonic est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/03/2007, 12h03   #7
Membre éclairé
 
Avatar de Mamilie
 
Inscription : février 2007
Messages : 289
Détails du profil
Informations personnelles :
Âge : 32

Informations forums :
Inscription : février 2007
Messages : 289
Points : 315
Points : 315
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.
Mamilie est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/08/2007, 09h52   #8
Membre à l'essai
 
Inscription : octobre 2002
Messages : 84
Détails du profil
Informations forums :
Inscription : octobre 2002
Messages : 84
Points : 24
Points : 24
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".
jackfirst72 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 29/07/2009, 10h30   #9
Membre habitué
 
Inscription : février 2004
Messages : 319
Détails du profil
Informations forums :
Inscription : février 2004
Messages : 319
Points : 114
Points : 114
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 :
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

fourchette est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 09h45.


 
 
 
 
Partenaires

Hébergement Web