起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 2012|回复: 5

[结贴] KSQL实现插入

[复制链接]

15

主题

67

帖子

118

积分

初级会员

Rank: 2

积分
118
QQ
发表于 2014-12-6 11:43:46 | 显示全部楼层 |阅读模式
版本: 小版本号:
数据库: 服务器操作系统: 应用服务器:
客户端操作系统: 浏览器:
通过自己写的Action 进行数据插入,想实现从A表查询数据插入B表中,可是那个data只填写一个呀,应该怎么解决 代码如下

sql = " INSERT INTO ddt_assignment_project (fID,version,project_id_ass,tnumber,tname,description,org_id,status,amount,aror,paymentype,financing_term,targetType,loan_purpose,funds_operation,"+
     "venturecapital_description,start_time,end_time,finish_time,createor,create_time,modifier,modified_time,remarks,service_rate,manage_rate,guarantee_rate,loan_period,file_content,file_path,apply_company_id)"+
     "SELECT fID,version,project_id,tnumber,tname,description,org_id,status,amount,aror,paymentype,financing_term,targetType,loan_purpose,funds_operation,venturecapital_description,start_time,end_time,finish_time,"+
     "createor,create_time,modifier,modified_time,remarks,service_rate,manage_rate,guarantee_rate,loan_period,file_content,file_path,apply_user_id FROM ddt_direct_project WHERE tnumber = 'ZT00000194' " ;
   KSQL.executeUpdate(sql, null, "/loan/assignmentApply/data", null);

这个KSQL执行之后会报错,求大神帮帮忙呀...在线等!!!

12

主题

2627

帖子

2866

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2866
发表于 2014-12-6 11:46:54 | 显示全部楼层
将控制台的错误信息存为文件发上来看看
回复 支持 反对

使用道具 举报

12

主题

2627

帖子

2866

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2866
发表于 2014-12-6 11:49:54 | 显示全部楼层
建议你先看看api手册中关于ksql语法的说明, 例如:
1.  SELECT语法

SELECT [DISTINCT] <查出列表>

       FROM <概念1> <别名1> [[OPTIONAL] JOIN <概念2> <别名2> ON <条件> ...]

        [WHERE <条件>]

        [GROUP BY <分组列表> [HAVING <条件>]]

        [ORDER BY <排序列表>]

        [UNION ...]

        [LIMIT ..]

2.  INSERT语法

        INSERT INTO <概念> <别名> (<修改关系列表>) VALUES (<插入的值>)

        INSERT INTO <概念> <别名> (<修改关系列表>) <子查询>

        INSERT INTO <多值关系> (<概念名>, <关系名>) VALUES (<插入的值>)

INSERT INTO SA_OPPerson p (p, p.sName, p.sCode) (SELECT :newid , p1.sName, p1.sCode FROM SA_OPPerson p1 WHERE p1.sName = 'ZHANGSAN')
回复 支持 反对

使用道具 举报

15

主题

67

帖子

118

积分

初级会员

Rank: 2

积分
118
QQ
 楼主| 发表于 2014-12-6 11:53:23 | 显示全部楼层
hecr 发表于 2014-12-6 11:46
将控制台的错误信息存为文件发上来看看

文件传不上去呀...


2014-12-06 11:22:31 action:<?xml version="1.0" encoding="UTF-8"?>
<action direct-execute="false" process="/loan/assignmentApply/process/assignmentApply/assignmentApplyProcess" activity="mainActivity" action-flag="__action_0__" executor="79D93770E3EA4A31B03E93E91978C508" execute-context="" name="createAssignmentProject"><parameters xmlns:xbiz="http://www.justep.com/xbiz#"><parameter name="customer_id"><xbiz:simple type="http://www.w3.org/2001/XMLSchema#String"><![CDATA[CP2014111209284]]></xbiz:simple></parameter><parameter name="old_project_number"><xbiz:simple type="http://www.w3.org/2001/XMLSchema#String"><![CDATA[ZT00000194]]></xbiz:simple></parameter><parameter name="assignment_type"><xbiz:simple type="http://www.w3.org/2001/XMLSchema#String"><![CDATA[1]]></xbiz:simple></parameter><parameter name="discount"><xbiz:simple type="http://www.w3.org/2001/XMLSchema#Double">1231</xbiz:simple></parameter><parameter name="assignmentID"><xbiz:simple type="http://www.w3.org/2001/XMLSchema#String"><![CDATA[45E2D7A15B494155ABB5DEF11942B039]]></xbiz:simple></parameter></parameters></action>
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at com.justep.system.action.Engine.invokeActions(Native Method)
at com.justep.system.action.Engine.invokeActions(Unknown Source)
at com.justep.business.server.BusinessServer.doAction(Unknown Source)
at com.justep.business.server.BusinessServer.doExcute(Unknown Source)
at com.justep.business.server.BusinessServer.excute(Unknown Source)
at com.justep.business.server.BusinessServerServlet.execService(Unknown Source)
at com.justep.business.server.BusinessServerServlet.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at com.justep.x.bs.BusinessServerServlet.service(Unknown Source)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:861)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1584)
at java.lang.Thread.run(Thread.java:595)
Caused by: com.justep.exception.BusinessException: 编码: JUSTEP150210; 提示: 执行KSQL出错, KSQL: INSERT INTO ddt_assignment_project (fID,version,project_id_ass,tnumber,tname,description,org_id,status,amount,aror,paymentype,financing_term,targetType,loan_purpose,funds_operation,venturecapital_description,start_time,end_time,finish_time,createor,create_time,modifier,modified_time,remarks,service_rate,manage_rate,guarantee_rate,loan_period,file_content,file_path,apply_company_id)SELECT fID,version,project_id,tnumber,tname,description,org_id,status,amount,aror,paymentype,financing_term,targetType,loan_purpose,funds_operation,venturecapital_description,start_time,end_time,finish_time,createor,create_time,modifier,modified_time,remarks,service_rate,manage_rate,guarantee_rate,loan_period,file_content,file_path,apply_user_id FROM ddt_direct_project WHERE tnumber = 'ZT00000194'
at com.justep.exception.BusinessException.create(Unknown Source)
at com.justep.system.data.impl.TableUtilsImplement.ksqlInsert(Unknown Source)
at com.justep.system.data.impl.TableUtilsImplement.ksqlExecuteUpdate(Unknown Source)
at com.justep.system.data.KSQL.executeUpdate(Unknown Source)
at com.justep.system.data.KSQL.executeUpdate(Unknown Source)
at com.justep.system.data.KSQL.executeUpdate(Unknown Source)
at AssignmentApply.createAssignmentProject(AssignmentApply.java:26)
... 26 more
Caused by: com.justep.exception.KSQLException: 编码: JUSTEP154115; 提示: KSQL语法错误, gnment_project ^^(fID,version,pr中未找到需要的元素, 位置35期望是<Identifier>
at com.justep.exception.KSQLException.create(Unknown Source)
at com.justep.system.ksql.token.TokenManager.matchToken(Unknown Source)
at com.justep.system.ksql.token.TokenManager.match(Unknown Source)
at com.justep.system.ksql.parser.AbstractParser.modifyConceptNode(Unknown Source)
at com.justep.system.ksql.parser.InsertParser.start(Unknown Source)
at com.justep.system.ksql.parser.InsertParser.start(Unknown Source)
at com.justep.system.ksql.parser.AbstractParser.parse(Unknown Source)
... 32 more
回复 支持 反对

使用道具 举报

15

主题

67

帖子

118

积分

初级会员

Rank: 2

积分
118
QQ
 楼主| 发表于 2014-12-6 11:57:31 | 显示全部楼层
hecr 发表于 2014-12-6 11:49
建议你先看看api手册中关于ksql语法的说明, 例如:
1.  SELECT语法

这个要在Action中直接使用KSQL 不是得用 kSQL.executeUpdate()方法吗,
回复 支持 反对

使用道具 举报

12

主题

2627

帖子

2866

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2866
发表于 2014-12-7 13:03:16 | 显示全部楼层
对, 你是做insert, 需要用kSQL.executeUpdate(), 同时,你的ksql有错误, 在insert into和select中,需要对概念取别名, 例如 INSERT INTO <概念> <别名>
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-5-20 12:58 , Processed in 0.089003 second(s), 25 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表