Long time lurker and learner, first time question here. I'm working a project for a local library to pull some data from their database to help the employees pull books put on hold for patrons. The catch here is the access to the database is read only. I cannot create any temporary tables or views.
We've created a long query to generate the data needed, I used a couple CTEs to whittle things down and then there's some logic based on which location the book may reside in to show where it should pick from. All in all, we're happy with the query results.
When I try to implement it using jdbcTemplate, I can't seem to find a way to get anything other than SELECT * to work.
WITH holdCTE1 (holdID, itemID, ...) AS (
SELECT *
FROM
table 1,
table 2,
table 3
WHERE
yada yada
This will give me results if I then do a SELECT * FROM holdCTE1.
If instead I specify columns, like this
WITH holdCTE1 (holdID, itemID, ...) AS (
SELECT t1.holdID, t2.itemID, t3.title
FROM
table 1,
table 2,
table 3
WHERE
yada yada
I get a syntax error at the first from table, regardless. I've tried adjusting all my table JOINs and using aliases and just about everything I can come across, but it doesn't seem to help.
A couple of things we're using to help the filtering and such, since we can't create a view to make it easy, is to call out the subqueries, so for example, in CTE1 we add a final column
'bib hold' AS hold_type
Even with the SELECT *, 'bib hold AS hold_type, I get the same syntax error. The actual wording of the error is:
StatementCallback; bad SQL grammar ... then my query ... nested exception is org.postgresql.util.PSQLException: ERROR: syntax error at or near ... the first thing under the FROM line
The library is using a Postgresql database, and I'm using Spring with jdbcTemplate for the SQL side.
Thanks in advance for looking.
Sorry for the poorly worded question, but I think I stumbled across an answer this evening. I was checking all of my queries I'd noted in pgAdmin, and I did a copy/paste into my java class.
With the escape characters, the code seems to run just fine. So this looks like it is passing info correctly to the query
WITH hold_bib (hold_id, item_id, birl_bib, patron, status, hold_type) AS (SELECT\n"
+ " h.id,\n"
+ " i.record_id,\n"
+ " birl.bib_record_id,\n"
+ " h.patron_record_id,\n"
+ " i.item_status_code,\n"
+ " 'bib'AS hold_type\n"
The function looks like this at the beginning now:
public List<Hold> libraryNotPicked() {
String sql = "\n"
+ "WITH hold_bib (hold_id, item_id, birl_bib, patron, status, hold_type) AS (SELECT\n"
+ " h.id,\n"
+ " i.record_id,\n"
+ " birl.bib_record_id,\n"
+ " h.patron_record_id,\n"
+ " i.item_status_code,\n"
+ " 'bib'AS hold_type\n"
...
+ " ;
List<Hold> holds = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(Hold.class));
return holds;
Seems to me the key is the \n type characters in the query.
I want to know whether it is possible to automatically generate stories to train the chatbot using RASA.
I have built my training data using the online training session to generate the stories and I found it very impractical. I would like to know whether there is some automatic way to do the story conversion of any conversation.
You can use interactive learning to create training data while speaking to the bot. See the docs here for more information on how to use interactive learning.
This is probably too late of a response but it is for the rest of the community who might still need an answer to this. A few months ago, I personally experienced that it would take too long to conduct interactive learning to train your RASA bot (especially when you have hundreds of intents and actions).
What I did was:
1) Compile all my named intents and actions(utter_) into a .csv file with following column headers : [subject] | [intent_name] | [utter_name]
2) Parse the intent name along with its respective action name in the same row into Markdown(.md) format while adding the respective strings to follow the formatting of the stories.md file
Package this into a function and call in a for loop:
subcell = "## " + column[0] + "\n" # [subject] header for stories
subcell += "* " + column[1] + "\n" + " - " + column[2] + "\n" + "\n" # [intent_name] + [utter_name]
3) The generated stories.md output will have all the direct intent-action pairings for your simple conversation flows. Likewise, you can apply this concept for generating domain.yml
Hope this helps!
I'm trying to put together a report to track our record reviews. In order to not have duplicates I have a condition to suppress a row if it's a duplicate
{review.clientNo} = Previous({review.clientNo})
and it works fine.
For who knows reasons one of our employees who does not do record reviews has access to two fields that relate to the tables of the record reviews and they keep checking off these fields even though they don't need to. So even if that particular record was not reviewed it still shows up on the report because two fields within it have entries. Until we can undo that we still want to run the reports. So I want to have two conditions to suppress either the one i have typed or the one in which only those fields are present and all others a null
This is what I have so far but crystal reports isn't liking it.
{review.clientNo} = Previous({review.clientNo})
or isnull( {review.initialDate} + {review.followUp} +
{review.code47A} +{review.clientSales} + {review.totalSales} +
{review.salesQuantity} +{review.clientSatisfaction} + {review.clientAddress}
+ {review.clientEmail} +{review.clientNumber} + {review.orderNumber} +
{review.orderTrack} + {review.orderFill} + {review.orderAmount} +
{review.orderSize} +{review.deliveryMethod} + {review.salesDate} + {review.orderDate})
Create a formula called suppression
if
{review.clientNo} = Previous({review.clientNo}
or
(
isnull({review.initialDate})
AND isnull({review.followUp})
AND isnull({review.code47A})
AND isnull({review.clientSales})
AND isnull({review.totalSales})
AND isnull({review.salesQuantity})
AND isnull({review.clientSatisfaction})
AND isnull({review.clientAddress})
AND isnull({review.clientEmail})
AND isnull({review.clientNumber})
AND isnull({review.orderNumber})
AND isnull({review.orderTrack})
AND isnull({review.orderFill})
AND isnull({review.orderAmount})
AND isnull({review.orderSize})
AND isnull({review.deliveryMethod})
AND isnull({review.salesDate})
AND isnull({review.orderDate})
)
then 1 else 0
in the suppression for your header and footer try this
sum({#suppression},{fieldgroupedon}) =0
You could also, by the way, now change your detail record suppression to just
{#suppression} = 1
I hope I got all that right!
I'm creating a new view for a customized PoS module for my restaurant. It's a specific view for kitchen, already filtered to show just kitchen's related items of a PoS order.
Now I would like to show a particular series of product with the name starting with "#" in a field populated by a function side by side with the "standard" products. In fact I'm speaking of a set of instructions coded as products to be available on PoS and to suit my needs I decided to create kitchen instructions as a product (service). In my PoS there are 3 categories that are not products but instructions (ADD, SUBTRACT, ADDITIONAL NOTE).
A typical order will show as:
Product Quantity
[1007] Pom. Secchi 1
# + Búfala 1
# - Mussarela 1
[2002] Nutella banana 1
# + Mussarela 1
What I would like to archive is a view like:
Product Note Quantity
[1007] Pom. Secchi # + Búfala # - Mussarela 1
[2002] Nutella banana # + Mussarela 1
I need to select just the strings starting with the "#" between two internal code starting with "[code]" and this is the hard thing to do. I don't need to delete the values I "move" because I need the stock view when I print the receipt.
I will call this function using python (and psycopg2 on postgresql 9.4) with on_change or extending the workflow when an order is marked as "paid". I don't think if doing it directly in Python is viable.
I've tried with string_agg(,) but with bad results.
Any tips about what should be the correct path to start coding? Thanks.
I am dealing with a whole load of Word documents that make heavy use of fields and cross-references (internally and between documents).
To update these and make everything consistent again after a change I have to open each file, select the entire file's content (equivalent of hitting Ctrl-A) and update all fields (the equivalent of hitting F9). And I have to do this twice for all files, so that also all inter-file cross-references are also updated properly.
Since this is a rather tedious and lengthy process I wanted to write me a little PowerShell-script that does that for me. The relevant function to update a file looks like this:
...
function UpdateDoc([object]$word, [object]$fileHandle) {
Write-Host("Updating: '" + $fileHandle.Name + "' ('" + $fileHandle.FullName + "'):")
# open the document:
$doc = $word.Documents.Open($fileHandle.FullName)
# select the entire document:
???
# update it:
???
# then save it:
$doc.Save
$doc.Close
Write-Host("'" + $fileHandle.Name + "' updated.")
}
...
But I am stuck on how to select the file's content and update it all, i.e. what has to go into this code instead of the two ???-markers to achieve what I want?
Did you try:
$doc.Fields | %{$_.Update()}
That should update all the fields