Jump to content

Writing to a database table


WMajor

Recommended Posts

Hi, once connected to a database table and retrieving data, is there a way to write to each record in the table to set a flag to say that the record is printed?

 

We have a database app which updates a table. We don't want the same records printed each time. In the event that we need a record reprinted, we could unset the "printed" flag for that record.

 

Is this possible?

Link to comment
Share on other sites

Accessing a database from FusionPro is a read-only operation. There's no way to write back to a database. Though in FusionPro VDP 10, you can write back to an ExternalDataFileEx object if it's in a flat-file (tab- or comma-delimited) format.

 

Also, technically, composing a record in FusionPro is not the same as "printing" it. Some print shops put a barcode on each output page, then scan the printed output to track which pages printed successfully or not so they can reprint pages. But it sounds like you're trying to remember which records were already composed. To me, that suggests a FusionPro VDP Server workflow, where your own application code both keeps track of what's been composed, and automatically invokes FusionPro VDP as needed.

Link to comment
Share on other sites

  • 5 months later...

Dan,

 

 

Can you elaborate when you say, "Though in FusionPro VDP 10, you can write back to an ExternalDataFileEx object if it's in a flat-file (tab- or comma-delimited) format." Do you have a sample template that does this? Or, what would a rule look like if I added it to the FrodoTravel example in the FusionPro tutorial folder, say (even though the outcome is obvious with the Frodo template) I want to capture the sheets used in the job using a rule, return FormatNumber("000000",((FusionPro.Composition.pageNumberInJob/2)))?

Link to comment
Share on other sites

Can you elaborate when you say, "Though in FusionPro VDP 10, you can write back to an ExternalDataFileEx object if it's in a flat-file (tab- or comma-delimited) format."

You can call the SetFieldValue and Save functions on your ExternalDataFileEx (XDF) object. The XDF file has to be in the Search Path, and has to be tab-delimited.

Do you have a sample template that does this?

No, not handy, though there is a partial example here:

http://forums.pti.com/showthread.php?p=21065

Or, what would a rule look like if I added it to the FrodoTravel example in the FusionPro tutorial folder, say (even though the outcome is obvious with the Frodo template)

Well, I'm not sure the outcome is obvious. At least it isn't to me. It depends what you're trying to do.

 

But you could do something like this in the Frodo job: Add a new field (a new value at the end of the first row, after a tab) to the XDF named "count", add "ExtraFiles" to the Search Path, and add this code to the OnRecordStart rule, after the "for" loop:

data.SetFieldValue(x, "Count", Int(data.GetFieldValue(x, "Count")) + 1);
data.Save();

You probably also want to put that in an if (!FusionPro.inValidation) conditional.

 

That will update the "count" field in the XDF for each time a record with that destination is composed (or previewed).

I want to capture the sheets used in the job using a rule, return FormatNumber("000000",((FusionPro.Composition.pageNumberInJob/2)))?

Well, again, you need to call the SetFieldValue and Save functions on an ExternalDataFileEx object, and write the data back to a particular record (row) and field (column) in the XDF. And I'm not sure putting FusionPro.Composition.pageNumberInJob in there would work, though again, it's not clear to me what you're ultimately trying to accomplish.

Link to comment
Share on other sites

Thanks Dan,

 

 

I will play around with the information you gave me. Our company has recently purchased a more intelligent inserter allowing us to have a job where each record will have different page counts. I have FusionPro creating a datamatrix barcode that captures information to talk to the inserter. I would like to log that information and have a total sheet count; per output file and per total job.

Link to comment
Share on other sites

I will play around with the information you gave me. Our company has recently purchased a more intelligent inserter allowing us to have a job where each record will have different page counts. I have FusionPro creating a datamatrix barcode that captures information to talk to the inserter. I would like to log that information and have a total sheet count; per output file and per total job.

That sounds like a job for the XML log file, which is a lot simpler. In OnJobStart, call FusionPro.Composition.CreateXMLLogFile(), optionally with a file name (and path), and the file will have the information you need at the end. You can use any XML parser on it.

 

Though as I noted earlier in this thread, many of your requirements suggest a FusionPro Server-based workflow. You can also add the "XMLLogFile=<path>" setting to the CFG file for any job, without the need to modify a rule.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...