October 22, 2024
Chicago 12, Melborne City, USA
SQL

Migrate ibatis choose cases to native SQL


I have the following ibatis query which I want to migrate from Oracle to PostgreSQL with Hibernate.

                   BEGIN
                      INSERT INTO users(
                          user_id,
                          personal_id,
                          created_by,
                          modified_by
                      ) VALUES (
                          #{user_id},
                          #{personal_id},
                          <choose>
                            <when test="userCred == true">'profile'</when>
                            <otherwise>'basic'</otherwise>
                          </choose>,
                          <choose>
                            <when test="userCred == true">'profile'</when>
                            <otherwise>'basic'</otherwise>
                          </choose>
                      );
                    EXCEPTION WHEN HIST_INDEX THEN
                        UPDATE ..........
                    END;    


void insert(@Param("user_id") long user_id, @Param("userCred") boolean userCred);

Do you know how I can migrate properly <choose> statements for PostgreSQL and also migrate Begin...Exception block for PostgreSQL?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video