How to pass current date from one UniQuery paragraph to another

551 views Asked by At

How can I pass the current date from one PA to another in UniQuery? A colleague taught me the trick of having the date written by cron to a file and using a inline prompt to read it with <<F(HOLD,X.DATE.TODAY,1)>>, but that adds extra parts that can fail and I would rather keep it simple (aka one time the file didn't get updated, oops).

I basically need something like this.

AE VOC MY.PROCESS.TODAY
001: PA
002: MY.PROCESS ?????

To run my second PA with the current date.

AE VOC MY.PROCESS
001: PA
002: SELECT PERSON WITH PER.CHANGE.DATE EQ <<I2,Enter Date:>>

This does work, MY.PROCESS <<F(HOLD,X.DATE.TODAY,1)>>, but is there anyway I could pass the results using something more reliable like DATE() as the argument into the second paragraph?

2

There are 2 answers

2
Ian McGowan On BEST ANSWER

You will likely get answers saying "don't do that in a paragraph", and to some extent that's right - anything except for a simple list of commands can get complicated.

That said, the below works for me:

AE VOC MY.PROCESS
001: PA
002: CLEARPROMPTS
003: SELECT PERSON WITH PER.CHANGE.DATE EQ <<I2,Enter Date:>>

From: https://docs.rocketsoftware.com/nxt/gateway.dll/RKBnew20/unidata/v8.2.1/unidata_userguide_v821.pdf

I use the I option while testing: "The I and S options are similar to the C option. The In option prompts for text if n is not specified, and the Sn option passes the value of n to called paragraphs."

Also read the section just above that "Always prompting with an inline prompt", to explain why CLEARPROMPTS is needed. Without that, if you don't pass a parameter it will gladly use the last one provided.

[Edit: to provide BASIC option] Paragraphs are great for really simple things, and there's probably a way to finagle things. But it's a one-line basic program to get something working:

EXECUTE "MY.PROCESS ":OCONV(DATE(),"D4/")

Is there a hard requirement that MY.PROCESS.TODAY be a paragraph? If you compile and catalog this one-line program as BP MY.PROCESS.TODAY then it will work exactly as needed.

0
PhilipZU2 On

You could also create a Vitrual Dictionary item that his today's date

ED DICT PERSON TODAYSDATE

I @DATE D2/ TODAY'S DATE 10L S

Then your select statement becomes:

SELECT PERSON WITH PER.CHANGE.DATE EQ TODAYSDATE

This admittedly will run slower than looking at a stored date as it is being calculated against each record queried rather than being stored. If PERSONS is a large file, this might not be a good idea.