package demo;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) </p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

import joyistar.eip.db.*;
import joyistar.eip.bs.*;
import joyistar.eip.vo.*;

public class MasterDetail extends BusinessObjectBean {
    private String dbName = "sysdb";
    // master SQL
    private String SQL = "select * from SALE";
    // master table
    private String tableName = "SALE";
    // detail SQL
    private String detailSQL = "select * from ITEM";
    // detail table
    private String detailTableName = "ITEM";
    
    public MasterDetail() {
    }
    
    public joyistar.eip.vo.XmlRequest query_XML(joyistar.eip.vo.XmlRequest xmlRequest) throws Exception {
        xmlRequest.SetDatabase(dbName);
        Param param1=xmlRequest.GetParam("SALE_ID");
        if(param1!=null) {
            SQL += " where SALE_ID=?";
        }
        xmlRequest.SetSQL(SQL);
        // set detail[0] SQL
		        xmlRequest.GetDetail(0).SetSQL(detailSQL);
        return super.query_XML(xmlRequest);
    }
    
    public joyistar.eip.vo.XmlPost update_XML(joyistar.eip.vo.XmlPost xmlPost) throws Exception {
        xmlPost.SetDatabase(dbName);
        xmlPost.SetTableName(tableName);
        // set detail[0] tablename
        xmlPost.GetDetail(0).SetTableName(detailTableName);

        return super.update_XML(xmlPost);
    }
    
}
