This is my code and it's working, I hope it helps.

It's PostgreSQL and IBatis.Net. I first select the generated key from the sequence and then insert the rest of the fields.

<insert id="InsertarPermiso" parameterClass="Permiso">
        <selectKey property="IdPermiso" type="post" resultClass="int">
                SELECT cast(last_value as int) AS value
                FROM permisos_id_permiso_seq
        </selectKey>

        INSERT INTO permisos ... (all values except key)

</insert>

See you,

Pablo.

Keslar, Jeremy wrote:
I am trying to return the generated value of my key field after an insert statement using the <selectKey> stanza. My SQLMapper returns 0 every time. Any ideas?



Jeremy




Reply via email to