在制作报表的过程中,子表是必不可少的,今天就研究了一下制作子表的几种方式 一、连接数据库创建子表 以MySQL为例: 1)iReport 创建父表 这个就是创建一个新的表,不过记得数据源要选择mySQL ,其他的数据库数据源也一样的。 2)创建好之后,我们来创建子表
在制作报表的过程中,子表是必不可少的,今天就研究了一下制作子表的几种方式
一、连接数据库创建子表
以MySQL为例:
1)iReport 创建父表
这个就是创建一个新的表格,不过记得数据源要选择mySQL ,其他的数据库数据源也一样的。
2)创建好之后,我们来创建子表,在组件面板找到拖动到父表当中的任意一个地方,我是放到detail里面的
它会产生一个向导
一路next下去,只是在最后一项选择use empty datasource,不过选其他的也行,待会我们还要修改
3)说一下原理:这种方式就是利用每张报表都有的Parameters属性,在iReport4.6中,点击子报表在右侧属性栏的最下面有两个属性
一个是Parameters属性,他可以用来向子表传递数据接下来我会说到,第二个是Return Values很明显这个可以用来将子表的数据返回,这个有时间再说。
下面子表属性进行设置:
有两个属性需要注意,一个是Subreport Expression用来指出子表的路径,这个新建之后一边不需要修改
另外一个是connect type,这个要选择Use a datasource express 创建子表时候选择默认值,就是父连接,这个现在不是重点,不过在之后的方式中,这个是很有用的
下面是重点:
设置点击Parameters打开这样一个窗口,点击add之后
这就是你自定义Parameters的地方,名字可以随便取,我的是如下设置:名字是id我要传递给子表的是数据库的ID字段,到此,我们对于主表这边的设置结束
4)下面设置子表这里有一个关键点,就是在子表左边栏Parameters属性这边要新建一个Parameters,右键-》新建名字要和上面我们创建的一样而字段的类型要和从主表传递过来的字段一样:我定义的是id同时在我的数据库中定义的ID字段是String类型的,所以是以下设置注意,Default Value Expection一定要设置为“”字符,不然会报错,折腾了我好几个小时
这个设置好之后打开数据连接窗口最左边的小按钮,打开后使用select语句不过要使用我们自定义的字段,如下图,
你会发现出现了一些属性字段选择添加,就OK啦
我的字段和子表设置
下面是预览结果
源码发过去,希望能共同学习
回家了,明天继续写

The steps for upgrading MySQL database include: 1. Backup the database, 2. Stop the current MySQL service, 3. Install the new version of MySQL, 4. Start the new version of MySQL service, 5. Recover the database. Compatibility issues are required during the upgrade process, and advanced tools such as PerconaToolkit can be used for testing and optimization.

MySQL backup policies include logical backup, physical backup, incremental backup, replication-based backup, and cloud backup. 1. Logical backup uses mysqldump to export database structure and data, which is suitable for small databases and version migrations. 2. Physical backups are fast and comprehensive by copying data files, but require database consistency. 3. Incremental backup uses binary logging to record changes, which is suitable for large databases. 4. Replication-based backup reduces the impact on the production system by backing up from the server. 5. Cloud backups such as AmazonRDS provide automation solutions, but costs and control need to be considered. When selecting a policy, database size, downtime tolerance, recovery time, and recovery point goals should be considered.

MySQLclusteringenhancesdatabaserobustnessandscalabilitybydistributingdataacrossmultiplenodes.ItusestheNDBenginefordatareplicationandfaulttolerance,ensuringhighavailability.Setupinvolvesconfiguringmanagement,data,andSQLnodes,withcarefulmonitoringandpe

Optimizing database schema design in MySQL can improve performance through the following steps: 1. Index optimization: Create indexes on common query columns, balancing the overhead of query and inserting updates. 2. Table structure optimization: Reduce data redundancy through normalization or anti-normalization and improve access efficiency. 3. Data type selection: Use appropriate data types, such as INT instead of VARCHAR, to reduce storage space. 4. Partitioning and sub-table: For large data volumes, use partitioning and sub-table to disperse data to improve query and maintenance efficiency.

TooptimizeMySQLperformance,followthesesteps:1)Implementproperindexingtospeedupqueries,2)UseEXPLAINtoanalyzeandoptimizequeryperformance,3)Adjustserverconfigurationsettingslikeinnodb_buffer_pool_sizeandmax_connections,4)Usepartitioningforlargetablestoi

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Efficient methods for batch inserting data in MySQL include: 1. Using INSERTINTO...VALUES syntax, 2. Using LOADDATAINFILE command, 3. Using transaction processing, 4. Adjust batch size, 5. Disable indexing, 6. Using INSERTIGNORE or INSERT...ONDUPLICATEKEYUPDATE, these methods can significantly improve database operation efficiency.

In MySQL, add fields using ALTERTABLEtable_nameADDCOLUMNnew_columnVARCHAR(255)AFTERexisting_column, delete fields using ALTERTABLEtable_nameDROPCOLUMNcolumn_to_drop. When adding fields, you need to specify a location to optimize query performance and data structure; before deleting fields, you need to confirm that the operation is irreversible; modifying table structure using online DDL, backup data, test environment, and low-load time periods is performance optimization and best practice.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 English version
Recommended: Win version, supports code prompts!

Notepad++7.3.1
Easy-to-use and free code editor
