Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > Autres langages pour le Web > Coldfusion
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 05/07/2007, 18h02   #1
Invité régulier
 
Inscription : décembre 2006
Messages : 25
Détails du profil
Informations forums :
Inscription : décembre 2006
Messages : 25
Points : 8
Points : 8
Par défaut Insertion de BLOB,CLOB,xml avec oracle 10g

Bonjour,

J'ai une table test qui est constitué des champs suivants:

n_id (number) ,c_char(char), c_vchar(varchar2), d_date(date),
c_lob(clob), b_lob(blob),x_xml(xml)

le formulaire:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<cfinclude template="../dsp_header.cfm">
    <BODY>
	     <cfform method="POST" action="../index.cfm?fuseaction=insert_data" >
		     <!--- <cfinput type="hidden" name="validate" value="true"> --->
		     <cfinput type="text" name="nombre" value="21"> - Un nombre<BR>
		     <cfinput type="text" name="unchar" value="abc"> - Un char<BR>
		     <cfinput type="text" name="unstring" value="un string"> - Un string<BR>
		     <cfinput type="text" name="unedate" value=""> - Une date<BR>
		     <cfinput type="file" name="clob" value=""> -Un clob<BR>
		     <cfinput type="file" name="blob" value=""> - Un blob<BR>
		      <cfinput type="file" name="xml" value=""> - Un fichier Xml<BR>  
		     <cfinput type="submit" name="Submit" value="Submit">
	
    	 </cfform>
    </BODY>
<cfinclude template="../dsp_footer.cfm">
la page index.cfm

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
<cfinclude template="app_globals.cfm">
<cfparam name="attributes.fuseaction" default="hello">
<cfswitch expression="#attributes.fuseaction#">
	<cfcase value="goodbye">
		<cfinclude template="monCircuit/dsp_goodbye.cfm">
	</cfcase>
	
	<cfcase value="hello">
		<cfinclude template="monCircuit/dsp_hello.cfm">
	</cfcase>
	
	<cfdefaultcase>
		<cfinclude template="monCircuit/dsp_hello.cfm">
	</cfdefaultcase>
	
	<cfcase value="dsp_data">
		<!--- <cfinclude template="monCircuit/qry_readDb.cfm"> --->
		<cfinclude template="monCircuit/dsp_viewData.cfm"/>
	</cfcase>
	
	<cfcase value="insert_data">
		<cfinclude template="monCircuit/qry_writteDb.cfm"/>
		<cfinclude template="monCircuit/dsp_viewData.cfm">
	</cfcase>

</cfswitch>
Code :
1
2
3
<cfquery name="inputData" datasource="SG_CDVISA">
insert into OJTEST(n_id,c_char,c_vchar,d_date,c_lob ,b_lob ) values(#attributes.nombre#,'#attributes.unchar#','#attributes.unstring#','#attributes.unedate#','#attributes.clob#',"#attributes.blob#","#attributes.xml#" )
J'ai essayé de les inserer un par un et ça marche jusqu'au clob. Je n'arrive pas à inserer des blob ni xml.

Une idée ?

mon environement:
Windows xp sp2
eclipse 3.2 avec cfeclipse
coldfusion MX7
Oracle 10g
Dx_ter est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/07/2007, 11h34   #2
Membre Expert
 
Homme Fabio
Développeur Java
Inscription : octobre 2002
Messages : 1 348
Détails du profil
Informations personnelles :
Nom : Homme Fabio
Localisation : Suisse

Informations professionnelles :
Activité : Développeur Java
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : octobre 2002
Messages : 1 348
Points : 1 824
Points : 1 824
Envoyer un message via Skype™ à jowo
Bonjour,

Je te conseille d'utiliser le tag cfqueryparam pour les interrogations SQL (SELECT, DELETE, INSERT, UPDATE). Ce tag permet partiellement de vérifier que les données sont du type correct et en plus il garde son code contre les SQL-Injection.

Documentation cfqueryparam MX7


Pour xml, je ne sais pas quel type choisir. 10g est trop nouveau pour moi, mais il se peut que tu trouves de l'information sur Internet.

Code :
1
2
3
4
5
6
7
8
9
10
11
<cfquery name="inputData" datasource="SG_CDVISA">
   insert into OJTEST (n_id, c_char, c_vchar, d_date, c_lob , b_lob ) 
                    values(<cfqueryparam value="#attributes.nombre#" cfsqltype="CF_SQL_INTEGER">,
                           <cfqueryparam value="#attributes.unchar#" cfsqltype="CF_SQL_CHAR">,
                           <cfqueryparam value="#attributes.unstring#" cfsqltype="CF_SQL_VARCHAR">,
                           <cfqueryparam value="#attributes.unedate#" cfsqltype="CF_SQL_TIMESTAMP">,
                           <cfqueryparam value="#attributes.clob#" cfsqltype="CF_SQL_CLOB>,
                           <cfqueryparam value="#attributes.blob#" cfsqltype="CF_SQL_BLOB">,
                           <cfqueryparam value="#attributes.xml#" cfsqltype="???">)
</cfquery>
un peu verbeux mais beaucoup plus sûr
__________________
Bien le bonjour chez vous
Jowo
jowo est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 08h16.


 
 
 
 
Partenaires

Hébergement Web