/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Dao;

import LoginDb.DbHandler;
import java.sql.CallableStatement;
import java.sql.Connection;
import oracle.jdbc.OracleTypes;

/**
 *
 * @author 1004242
 */
public class AgentMappingDao {


     public String createOrUpdateAgentMapping(String tellerId, String pacsId,String accNo,String agntId,String txnType ) {
        Connection con = null;
        CallableStatement proc = null;
        String res = null;
        System.out.println("CreateOrUpdateAgentMapping for user Id :" + tellerId +" ops type:"+txnType);
        try {
            con = DbHandler.getDBConnection();
            proc = con.prepareCall("{ call operations1.DDS_ACCT_AGENT_MAPPING(?,?,?,?,?,?) }");

                          proc.setString(1, tellerId);
                          proc.setString(2, pacsId);
                          proc.setString(3, accNo);
                          proc.setString(4, agntId);
                          proc.setString(5, txnType);
                          proc.registerOutParameter(6, OracleTypes.VARCHAR);



                          proc.executeUpdate();

                         // res = proc.getString(6);//error message from dds procedure

        } catch (Exception e) {
           // e.printStackTrace();
           // System.out.println("Exception occured  in createOrUpdateAgentMapping for user Id :" + tellerId);
           System.out.println("Error occurred during processing.");
        } finally {
            try {
                if (con != null) {
                   // con.commit();
                    con.close();
                }
            } catch (Exception e) {
               // e.printStackTrace();
               System.out.println("Error occurred during connection close.");
            }
        }

        return res;
    }

}
