如何使用spring jdbc复制表的一行

时间:2012-10-22 12:23:53

标签: oracle spring jdbc

我需要使用spring jdbc复制除一列之外的行,该列是另一行的唯一键。即使我检查空值,我也会得到nullpointer异常。有没有其他好方法来实现这一目标?帮我。谢谢。请在下面找到我的代码:

insert.update(new Object[] { 
                    argModel.getKey(),
                    CommonUtils.isNotNull(argModel.getPage_Key())?argModel.getPage_Key():"",
                    CommonUtils.isNotNull(argModel.getNoteBookRef())?argModel.getNoteBookRef():"", 
                    argModel.getBatchNum(),
                    alStructKey,
                    identifiedStructKey,
                    reactionKey,
                    argModel.getAnalysisType(),
                    CommonUtils.isNotNull(argModel.getSubmitted_Amt())?argModel.getSubmitted_Amt():"0",
                    CommonUtils.isNotNull(argModel.getEstimated_Purity())?argModel.getEstimated_Purity():"0",
                    CommonUtils.isNotNull(argModel.getKey_Nmr_Exp())?argModel.getKey_Nmr_Exp():"",
                    CommonUtils.isNotNull(argModel.getSolvent_Used())?argModel.getSolvent_Used():"",
                    CommonUtils.isNotNull(argModel.getProbe_Used())?argModel.getProbe_Used():"",
                    CommonUtils.isNotNull(argModel.getSamp_Temp())?argModel.getSamp_Temp():"0",
                    CommonUtils.isNotNull(argModel.getAchiral_Purity())?new Float(argModel.getAchiral_Purity()):0.0,
                    CommonUtils.isNotNull(argModel.getChiral_Purity())?new Float(argModel.getChiral_Purity()):0.0,
                    CommonUtils.isNotNull(argModel.getPeak1_Amt())?argModel.getPeak1_Amt():"0",
                    CommonUtils.isNotNull(argModel.getPeak2_Amt())?argModel.getPeak2_Amt():"0",
                    CommonUtils.isNotNull(argModel.getRequestId())?argModel.getRequestId():"0",
                    CommonUtils.isNotNull(argModel.getSubmissionComments())?argModel.getSubmissionComments():"",
                    CommonUtils.isNotNull(argModel.getStatusComments())?argModel.getStatusComments():"",
                    CommonUtils.isNotNull(argModel.getCcList())?argModel.getCcList():"",
                    argModel.isSaveSampleForPickUp()?"YES":"NO",
                    CommonUtils.isNotNull(argModel.getAnalyticalContact())?argModel.getAnalyticalContact():"",
                    argModel.getSubmittedOn(),
                    argModel.getAcceptedOn(),
                    CommonUtils.isNotNull(argModel.getSubmissionStatus())?argModel.getSubmissionStatus():"",
                    CommonUtils.isNotNull(argModel.getSubmitter())?argModel.getSubmitter():"",
                    CommonUtils.isNotNull(argModel.getTherapetuicArea())?argModel.getTherapetuicArea():"",
                    CommonUtils.isNotNull(argModel.getProjectCode())?argModel.getProjectCode():"",
                    CommonUtils.isNotNull(argModel.getCro())?argModel.getCro():"",
                    CommonUtils.isNotNull(argModel.getSiteCode())?argModel.getSiteCode():"",
                    CommonUtils.isNotNull(argModel.getAnalysisXml())?StorageUtils.toClobObject(CommonUtils.replaceSpecialCharsinXML(argModel.getAnalysisXml())):""
                    });

1 个答案:

答案 0 :(得分:1)

insert into submitted_batch select (your_new_page_key, n1, n2, n3, ...) from submitted_batch where analytical_page_key='24695d63ac1e31a8730de255639e5b2c8f7972d8';

其中your_new_page_key是您的新密钥,n1,n2,n3,...是所有非​​主键列。