简体   繁体   English

如何修改fieldgroup保存功能?

[英]How to modify fieldgroup save function?

I created a page to insert and modify data of an existing mysql- table. 我创建了一个页面来插入和修改现有mysql表的数据。 But based on my requirements and the structure of the table I have to modify the sql for inserting data. 但根据我的要求和表的结构,我必须修改sql以插入数据。

Because I am completly new on rapidclipse and java I need some hints/ examples how and where to modify this. 因为我在rapidclipse和java上完全是新的,我需要一些提示/示例如何以及在何处修改它。 Looking all rapidclipse videos did not give the right hint. 查看所有rapidclipse视频没有给出正确的提示。

I would like to insert three fields into a mysql-table 我想在mysql表中插入三个字段
One of the fields I have to edit manualy. 我必须手动编辑的其中一个字段。
The second field contains always the same value. 第二个字段始终包含相同的值。
The third field contains a calculated value, which I have to fetch while runtime from the database. 第三个字段包含一个计算值,我必须从数据库中获取运行时。

As sql I would use following code: 作为sql我会使用以下代码:

INSERT INTO OKM_DB_METADATA_VALUE (DMV_TABLE, DMV_COL00, DMV_COL01) 
VALUES ('T_supplier', (select * from (select max(cast(DMV_COL00 as
Integer)) +1 from OKM_DB_METADATA_VALUE as t2 where DMV_TABLE =
'T_supplier') as t3 ) , 'new suppliername');

The value for field DMV_Table will be always 'T_supplier' 字段DMV_Table的值将始终为“T_supplier”
The value for field DMV_COL00 is always the highest value in the col +1 字段DMV_COL00的值始终是col +1中的最高值
The value for field DMV_COL01 will be always entered manually 将始终手动输入字段DMV_COL01的值
(I am not able/ I don't want to modify/ use table form, -design and trigger, because it is a original table of OpenKM) (我不能/我不想修改/使用表格形式, - 设计和触发器,因为它是OpenKM的原始表格)

Thank you in advance! 先感谢您!
best regards 最好的祝福
OpaHeinz OpaHeinz

Just a suggestion for sql code .. Your code could be refactored in a more SQL like code .. You could avoid the innner subquery .. and use a normal insert select 只是对sql代码的建议..你的代码可以在更像SQL的代码中进行重构。你可以避免使用内部子查询..并使用普通的插入选择

  INSERT INTO OKM_DB_METADATA_VALUE (DMV_TABLE, DMV_COL00, DMV_COL01) 
  select 'T_supplier', max(cast(DMV_COL00 asInteger)) +1 , 'new suppliername'
  from OKM_DB_METADATA_VALUE 
  where DMV_TABLE ='T_supplier'

The first step to solution 解决方案的第一步

In the buttonClick event of save function I set the value of DMV_Table field with: 在save函数的buttonClick事件中,我使用以下命令设置DMV_Table字段的值:

... this.txtDmvTable.setValue("T_supplier"); 

The second step; 第二步; I created a view in the database wich delivers only the expected value: 我在数据库中创建了一个只提供预期值的视图:

 `CREATE
OR REPLACE
VIEW `okmdb`.`V_suppliers_newID` AS
select
    1 as "id",
    max(cast(DMV_COL00 as Integer)) +1 as "newSupId" 
from OKM_DB_METADATA_VALUE 
where DMV_TABLE = 'T_supplier'; `

After that I created an entity in rapidclipse, read the value out of the view and assigned it to the other field DMV_COL00. 之后我在rapidclipse中创建了一个实体,从视图中读取值并将其分配给另一个字段DMV_COL00。

This was all. 这就是全部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM