Basic script, boleh modify lagi untuk PK, nullable dll.
...
SELECT ' "' || COLUMN_NAME || '" ' || DATA_TYPE || ' (' || data_length || ' ' || decode(char_used,'B','BYTE') || ') , '
FROM user_tab_columns
WHERE table_name='TABLE_NAME'
;
error, issue, RnD, notes for my colleagues ... anything related with my job. A good programmer should be a good and fast reader. This log just to cut the costs of my RnD. Nothing personal :)
SELECT ' "' || COLUMN_NAME || '" ' || DATA_TYPE || ' (' || data_length || ' ' || decode(char_used,'B','BYTE') || ') , '
FROM user_tab_columns
WHERE table_name='TABLE_NAME'
;
<procedure id="StaffAppraisal.updateKra" parameterClass="map">
<![CDATA[
{
#p_return_val,jdbcType=DECIMAL,mode=OUT# = call appraisal.update_kra(
#p_staff_id,jdbcType=VARCHAR,mode=IN#,
#p_appraisal_seq,jdbcType=VARCHAR,mode=IN#,
#p_session_code,jdbcType=VARCHAR,mode=IN#,
#p_year,jdbcType=VARCHAR,mode=IN#,
#p_kra,jdbcType=VARCHAR,mode=IN#,
#p_errmsg,jdbcType=VARCHAR,mode=OUT#
)
}
]]>
</procedure>
public String sendEmail (String formOwnerId, String emailType, String refCode)
{
String errorMesej = null;
Map<String,String> param = new HashMap<String,String>();
param.put("p_staff_id" , formOwnerId);
param.put("p_email_type", emailType);
param.put("p_ref" , refCode);
param.put("p_errmsg" , refCode);
this.getSqlMapClientTemplate().update("EMAIL.sendEmail", param);
errorMesej = param.get("p_errmsg");
return errorMesej;
}
<parameterMap class="map" id="getJobDescParam">
<parameter property="p_job_code" javaType="java.lang.String" jdbcType="VARCHAR" mode="IN"/>
</parameterMap>
<select id="getJobDesc" parameterMap="getJobDescParam" resultClass="java.lang.String">
select hr_util.get_job_desc(?) from dual
</select>
Contoh kod DAO
public String getJobDesc(String jobCode)
{
String returnString;
Map<String, Object> map = new HashMap<String, Object>();
map.put("p_job_code", jobCode);
// Reference com.icms.biz.dao.ibatis.maps.StaffMain.xml
returnString = (String)getSqlMapClientTemplate().queryForObject("getJobDesc",map);
if(StringUtils.isEmpty(returnString)){
returnString = "-";
}
return returnString;
}