在数据库中新建条目后自动创建PDF

时间:2022-09-26 07:42:49

I am not sure if this is even the right site for this but I'll ask anyways. Does anybody know a program that can create a PDF with data from a database with a complex SQL statement? When an employee finishes a request for a customer, I want that the program is triggered by the new entry in a database table and fills out a pre built PDF with data that it pulls from a database. It needs to be a complex program that can process big SQL statements.

我不确定这是不是合适的网站,但我还是要问。有人知道一个程序可以用一个复杂的SQL语句从数据库中创建一个PDF文档吗?当员工完成对客户的请求时,我希望程序由数据库表中的新条目触发,并使用从数据库中提取的数据填充预构建的PDF。它需要是一个能够处理大型SQL语句的复杂程序。

2 个解决方案

#1


1  

The only thing you can do to run custom code in SQL Server is to create a CRL Stored Procedure and a trigger to start PDF processing in your specific use case. You can write a class library that connects to the database you are triggered from using a specific keyword in the connection string. You can pass in the key you need to use to select the whole dataset you need to fill the PDF as a SP parameter.

在SQL Server中运行自定义代码的惟一方法是创建一个CRL存储过程和一个触发器,以在特定的用例中启动PDF处理。您可以编写一个类库,该类库连接到使用连接字符串中的特定关键字触发的数据库。您可以传递您需要使用的键来选择要作为SP参数填充PDF所需的整个数据集。

https://msdn.microsoft.com/en-us/library/ms131094.aspx

https://msdn.microsoft.com/en-us/library/ms131094.aspx

In the class library you can reference third part libraries to interact with an editable PDF and fill the flieds you need with the data retrieved from the database. I suggest you to have a look about security concerns releted to CLR use in SQL Server. Basically your code runs within the SQLServer.exe process, sharing resources and access privileges.

在类库中,可以引用第三部分库与可编辑的PDF进行交互,并使用从数据库检索的数据填充所需的flieds。我建议您看看SQL Server中与CLR使用相关的安全问题。基本上,您的代码在SQLServer中运行。exe进程,共享资源和访问特权。

https://msdn.microsoft.com/en-us/library/ms131071.aspx

https://msdn.microsoft.com/en-us/library/ms131071.aspx

#2


1  

SSRS can produce PDF. See if that table insert trigger can call a CLR that in turn will execute the report that can even be attached to an email.

SSRS可以产生PDF。看看这个表插入触发器是否可以调用CLR, CLR将执行甚至可以附加到电子邮件的报告。

The report can be as complex as you need, so long the report SP can populate the data based on the newly inserted row.

只要报表SP能够基于新插入的行填充数据,报表就可以尽可能地复杂。

For stability, let's not have a trigger, but the insert process itself should be done in an SP, in which that insertion SP shall call the CLR.

为了稳定,我们不需要触发器,但是插入过程本身应该在SP中完成,在SP中插入SP将调用CLR。

Further, instead of using CLR, we can use SSRS Data-Driven Subscription. When making the Subscription, we can make it as a one time scheduled Job. The SP can invoke this 'expired' Job from SQL Server Agent by using sp_start_job.

此外,我们可以使用SSRS数据驱动订阅,而不是使用CLR。在订阅时,我们可以将其作为一次性的工作安排。SP可以使用sp_start_job从SQL Server代理调用这个“过期”作业。

#1


1  

The only thing you can do to run custom code in SQL Server is to create a CRL Stored Procedure and a trigger to start PDF processing in your specific use case. You can write a class library that connects to the database you are triggered from using a specific keyword in the connection string. You can pass in the key you need to use to select the whole dataset you need to fill the PDF as a SP parameter.

在SQL Server中运行自定义代码的惟一方法是创建一个CRL存储过程和一个触发器,以在特定的用例中启动PDF处理。您可以编写一个类库,该类库连接到使用连接字符串中的特定关键字触发的数据库。您可以传递您需要使用的键来选择要作为SP参数填充PDF所需的整个数据集。

https://msdn.microsoft.com/en-us/library/ms131094.aspx

https://msdn.microsoft.com/en-us/library/ms131094.aspx

In the class library you can reference third part libraries to interact with an editable PDF and fill the flieds you need with the data retrieved from the database. I suggest you to have a look about security concerns releted to CLR use in SQL Server. Basically your code runs within the SQLServer.exe process, sharing resources and access privileges.

在类库中,可以引用第三部分库与可编辑的PDF进行交互,并使用从数据库检索的数据填充所需的flieds。我建议您看看SQL Server中与CLR使用相关的安全问题。基本上,您的代码在SQLServer中运行。exe进程,共享资源和访问特权。

https://msdn.microsoft.com/en-us/library/ms131071.aspx

https://msdn.microsoft.com/en-us/library/ms131071.aspx

#2


1  

SSRS can produce PDF. See if that table insert trigger can call a CLR that in turn will execute the report that can even be attached to an email.

SSRS可以产生PDF。看看这个表插入触发器是否可以调用CLR, CLR将执行甚至可以附加到电子邮件的报告。

The report can be as complex as you need, so long the report SP can populate the data based on the newly inserted row.

只要报表SP能够基于新插入的行填充数据,报表就可以尽可能地复杂。

For stability, let's not have a trigger, but the insert process itself should be done in an SP, in which that insertion SP shall call the CLR.

为了稳定,我们不需要触发器,但是插入过程本身应该在SP中完成,在SP中插入SP将调用CLR。

Further, instead of using CLR, we can use SSRS Data-Driven Subscription. When making the Subscription, we can make it as a one time scheduled Job. The SP can invoke this 'expired' Job from SQL Server Agent by using sp_start_job.

此外,我们可以使用SSRS数据驱动订阅,而不是使用CLR。在订阅时,我们可以将其作为一次性的工作安排。SP可以使用sp_start_job从SQL Server代理调用这个“过期”作业。