You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-cs@ibatis.apache.org by Angel Valero <an...@yahoo.es> on 2005/09/27 09:12:32 UTC

oracle select key doesn't work?

   Hi, I'm trying to do an insert with a selectKey
(oracle database) statement like the next one, but it
doesn´t assign the sequence value to the especified
field. Any wrong in the next xml fragment?
 
<insert id="insertDocumento"
parameterClass="Documento">
		    <selectKey resultClass="int"
keyProperty="ID_DOCUMENTO" > 
	           SELECT DOCUMENTOS_SEQ.nextval AS
ID_DOCUMENTO FROM DUAL
            </selectKey>
			insert into gco_documentos
				(ID_DOCUMENTO, 
				 ID_TEMPORADA, 
				 FECHA, 
				 DESCRIPCION, 
				 FICHERO, 
				 TIPO_DOC)
			values
				(#ID_DOCUMENTO#, 
				 #ID_TEMPORADA#, 
				 #FECHA#, 
				 #DESCRIPCION#, 
				 #FICHERO#, 
				 #TIPO_DOC# )
		</insert>

Thanks in advance


		
______________________________________________ 
Renovamos el Correo Yahoo! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es

Re: oracle select key doesn't work?

Posted by Angel Valero <an...@yahoo.es>.
Thanks for the answer Ron. Its seems that the problem
is the "type" attribute. I'm going to change my map
file ;)



 --- Ron Grabowski <ro...@yahoo.com> escribió:

> According to the test cases:
> 
> http://tinyurl.com/77dbg
>
http://svn.apache.org/repos/asf/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Category.xml
> 
> This should be the correct syntax:
> 
>  <insert id="InsertCategoryNull"
> parameterMap="insert-null-params">
>   <selectKey property="Id" type="pre"
> resultClass="int">
>    select s_categories.nextval as value from dual
>   </selectKey>
>   insert into Categories (Category_Id,
> Category_Name, Category_Guid)
>   values (?,?,?)
>  </insert>
> 
> It looks like your selectKey node is incorrect. The
> .Net version has a
> slightly different syntax than the Java version. For
> example there is
> no jdbcType attribute in the xml config files for
> .Net. It is replaced
> by dbType. I suggest reading the IBatisNet
> documentation for more
> information:
> 
>  http://ibatis.apache.org/downloads.html
> 
> --- Angel Valero <an...@yahoo.es> wrote:
> 
> >    Hi, I'm trying to do an insert with a selectKey
> > (oracle database) statement like the next one, but
> it
> > doesn´t assign the sequence value to the
> especified
> > field. Any wrong in the next xml fragment?
> >  
> > <insert id="insertDocumento"
> > parameterClass="Documento">
> > 		    <selectKey resultClass="int"
> > keyProperty="ID_DOCUMENTO" > 
> > 	           SELECT DOCUMENTOS_SEQ.nextval AS
> > ID_DOCUMENTO FROM DUAL
> >             </selectKey>
> > 			insert into gco_documentos
> > 				(ID_DOCUMENTO, 
> > 				 ID_TEMPORADA, 
> > 				 FECHA, 
> > 				 DESCRIPCION, 
> > 				 FICHERO, 
> > 				 TIPO_DOC)
> > 			values
> > 				(#ID_DOCUMENTO#, 
> > 				 #ID_TEMPORADA#, 
> > 				 #FECHA#, 
> > 				 #DESCRIPCION#, 
> > 				 #FICHERO#, 
> > 				 #TIPO_DOC# )
> > 		</insert>
> > 
> > Thanks in advance
> > 
> > 
> > 		
> > ______________________________________________ 
> > Renovamos el Correo Yahoo! 
> > Nuevos servicios, más seguridad 
> > http://correo.yahoo.es
> > 
> 
> 



		
______________________________________________ 
Renovamos el Correo Yahoo! 
Nuevos servicios, más seguridad 
http://correo.yahoo.es

Re: oracle select key doesn't work?

Posted by Ron Grabowski <ro...@yahoo.com>.
According to the test cases:

http://tinyurl.com/77dbg
http://svn.apache.org/repos/asf/ibatis/trunk/cs/mapper/IBatisNet.DataMapper.Test/Maps/Oracle/OracleClient/Category.xml

This should be the correct syntax:

 <insert id="InsertCategoryNull" parameterMap="insert-null-params">
  <selectKey property="Id" type="pre" resultClass="int">
   select s_categories.nextval as value from dual
  </selectKey>
  insert into Categories (Category_Id, Category_Name, Category_Guid)
  values (?,?,?)
 </insert>

It looks like your selectKey node is incorrect. The .Net version has a
slightly different syntax than the Java version. For example there is
no jdbcType attribute in the xml config files for .Net. It is replaced
by dbType. I suggest reading the IBatisNet documentation for more
information:

 http://ibatis.apache.org/downloads.html

--- Angel Valero <an...@yahoo.es> wrote:

>    Hi, I'm trying to do an insert with a selectKey
> (oracle database) statement like the next one, but it
> doesn´t assign the sequence value to the especified
> field. Any wrong in the next xml fragment?
>  
> <insert id="insertDocumento"
> parameterClass="Documento">
> 		    <selectKey resultClass="int"
> keyProperty="ID_DOCUMENTO" > 
> 	           SELECT DOCUMENTOS_SEQ.nextval AS
> ID_DOCUMENTO FROM DUAL
>             </selectKey>
> 			insert into gco_documentos
> 				(ID_DOCUMENTO, 
> 				 ID_TEMPORADA, 
> 				 FECHA, 
> 				 DESCRIPCION, 
> 				 FICHERO, 
> 				 TIPO_DOC)
> 			values
> 				(#ID_DOCUMENTO#, 
> 				 #ID_TEMPORADA#, 
> 				 #FECHA#, 
> 				 #DESCRIPCION#, 
> 				 #FICHERO#, 
> 				 #TIPO_DOC# )
> 		</insert>
> 
> Thanks in advance
> 
> 
> 		
> ______________________________________________ 
> Renovamos el Correo Yahoo! 
> Nuevos servicios, más seguridad 
> http://correo.yahoo.es
>