How to write Liquibase script to hash the data of a column using update command - database-migration

While I was trying to hash the owner_name column with this set of Liquibase Script as suggested by the Corda here:
I have used the PostgreSQL DB
<changeSet author="My_Company" id="replace owner_name with owner_name_hash">
<addColumn tableName="iou_states">
<column name="owner_name_hash" type="nvarchar(130)"/>
</addColumn>
<update tableName="iou_states">
<column name="owner_name_hash" valueComputed="hash(owner_name)"/>
</update>
<dropColumn tableName="iou_states" columnName="owner_name"/>
I was getting the following error:
Reason: liquibase.exception.DatabaseException: Invalid parameter count for "HASH", expected count: "2..3"; SQL statement
The reason I am not understanding here what are the other fields we need to give to the hash function.
Can any one help me with this, and provide the correct script which will do the hashing of the column in table. Many Thanks in Advance.

Liquibase is doing what you're telling it to do correctly, but the syntax is not valid because it needs an additional parameter for the HASH. The PostgreSQL docs don't have a lot of information about the available parameters, but here are a couple of links that have more details.
https://www.postgresql.org/docs/14/functions-binarystring.html
https://www.postgresql.org/docs/14/functions-string.html

Related

OBIEE: how to set 'is prompted' values in saved filter

My task is to automate testing of OBIEE report data. The main step is to get report's logical SQL.
I have dashboard with reports. Every report has named filter (not inline one) attached. So, I'd like to find a way to set up filter values and programmatically run generation of report SQL (so that WHERE clause is filled in with my values), play it and retrieve data. I have tried the following approaches:
OBIEE WebServices. First, I use generateReportSQL, then call for executeSQLQuery. This approach works fine for inline filters, I managed to set them up in . But I can not get it working with saved filters. How to generate report with values set up for columns in attached saved filter? No information in documentation or in internet found.
Generate Dashboard URL with all prompts set, run it and then read usage tracking tables to retrieve SQL queries. But it seems a bit strange approach, I believe there must be a simpler way to do the task. Moreover, usage tracking does not put information about report execution in its DB immediately, it has some timeout. Is there a way to avoid it?
runcat.sh + nqcmd - still, have not found a way to set values for saved filter.
So, my question is: how generate report's logical SQL with prompt values set for saved filter attached?
Thanks in advance,
Jol
UPDATE
Some examples:
XML of my usage tracking analysis contains the following:
<saw:filter>
<sawx:expr xsi:type="sawx:logical" op="and">
<sawx:expr xsi:type="sawx:special" op="prompted">
<sawx:expr xsi:type="sawx:sqlExpression">"S_NQ_ACCT"."START_DT"</sawx:expr>
</sawx:expr>
<sawx:expr xsi:type="sawx:special" op="prompted">
<sawx:expr xsi:type="sawx:sqlExpression">"S_NQ_ACCT"."USER_NAME"</sawx:expr>
</sawx:expr>
<sawx:expr xsi:type="sawx:special" op="prompted">
<sawx:expr xsi:type="sawx:sqlExpression">"S_NQ_ACCT"."SAW_DASHBOARD_PG"</sawx:expr>
</sawx:expr>
</sawx:expr>
I can use filterExpressions tag of generateReportSQL to create logicalSQL that includes my values in WHERE clause. Everything is OK if tag filter is included in analysis's XML (the case of inline filters, as in the example above):
<v7:generateReportSQL>
<v7:reportRef>
<v7:reportPath>report path</v7:reportPath>
</v7:reportRef>
<v7:reportParams>
<!--Zero or more repetitions:-->
<v7:filterExpressions>
<![CDATA[<sawx:expr xsi:type="sawx:string" op="equal" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:saw="com.siebel.analytics.web/report/v1.1" xmlns:sawx="com.siebel.analytics.web/expression/v1.1" subjectArea="Usage Tracking">
<sawx:expr xsi:type="sawx:sqlExpression">"S_NQ_ACCT"."USER_NAME"</sawx:expr>
<sawx:expr xsi:type="sawx:string">testuser</sawx:expr></sawx:expr>
]]>
</v7:filterExpressions>
.............................
</v7:reportParams>
<v7:sessionID>...</v7:sessionID>
</v7:generateReportSQL>
XML of my test analysis contains the following:
<saw:filter>
<sawx:expr xsi:type="sawx:savedFilter" path="/shared/myproject/_filters/myroject/my saved filter" name="my saved filter" /></saw:filter>
'my saved filter' has 'is prompted' columns that I'd like to set to my values and run an analysis to get dataset. But how to do it?
if webservices are useless here, what could be used?
Since those are normally used for completely dynamic population in terms of content (instantiated variables pulled from user profiles, stuff gotten from prompts, etc....) you won't get them in the LSQL.
tl;dr - Robin wrote a bice post about load testing with LSQL https://www.rittmanmead.com/blog/2014/03/built-in-obiee-load-testing-with-nqcmd/
Edit: Baseline Validation Tool (BVT) was proposed and is the answer.

insert into query not working in coldfusion?

Please check my query below
<cfquery datasource="quackit" name="insertuser">
INSERT INTO user (user_id, group_id)
VALUES (#form.usr_id#,#form.access_flg#)
</cfquery>
But I am getting Error executing database query
I am able to fetch the data ,Please correct me where I am doing wrong
Use cfqueryparam. You are wide open to sql injection right now. The error probably comes from one of your form variables being blank, which you will need to check for either way.
We can't give more precise advice without details on the specific database error. If it's not due to the form feeding in bad data, it has something to do with your database structure (perhaps you are trying to insert an invalid foreign key, or leaving off a required field).

How can I get stock option chains using YQL?

I am trying to get stock option chains from Yahoo using YQL. I have tried this command in the YQL console:
select * from yahoo.finance.options
However, I get this error XML:
<?xml version="1.0" encoding="UTF-8"?>
<error xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:lang="en-US">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
</diagnostics>
<description>No definition found for Table yahoo.finance.options</description>
</error>
It looks like this table doesn't exist anymore. Does anyone know what the correct table is?
You have to provide at least one where clause to make this query work. Like this:
select * from yahoo.finance.options where symbol='MMM'
or,
select * from yahoo.finance.options where symbol='A'
or,
select * from yahoo.finance.options where symbol='YHOO'
All the above queries work fine. If you want more specific data then you have to provide more conditions to filter out your desired data out of the whole data.
yahoo.finance.options is a community table. To read about community tables check here. From the link I just posted:
In order to use YQL with the community tables, you must pass in the datatables env file. You can do this on the YQL console as part of a YQL statement, or by passing in a query parameter.
The YQL console to test this can be found here
Something I just figured out today is that you can just use this to get the option data from yahoo
https://query2.finance.yahoo.com/v7/finance/options/SPXS?straddle=true
Since the middle of 2014 YQL has the problem, so the option chain from yahoo.finance with scraping could be get by the following codes with: Python and Matlab

Sorting results in Advanced System Reporter in Sitecore

In Sitecore's Advanced System Reporter (v1.3) shared source module, is there an out-of-the-box way of sorting the results before the results are displayed to email/screen or will I need to implement something myself?
In a standard ASR install, I can see the Media Viewer viewer configuration item has a sort parameter in the attributes field but it's using ASR.Reports.Items.ItemViewer class which, after checking in reflector, doesn't respect the sort parameter. I take this to mean that the class might have respected the sort parameter previously but doesn't now.
As a side thought, I would have thought that a Scanner class would be a much more logical place to put sorting logic than at the Viewer class level.
Ok, found the answer. The sort parameter I found is actually used when running the report by the ASR module.
The sort parameter is set up in the attributes and is in the following format:
sort=ColumnName,ASC|DESC,[DateTime]
where Column Name is the display name of the column, ASC or DESC is the sort direction and is required and DateTime is to be set if the column is a date time value.
Example:
Given the column formatting of
<Columns>
<Column name="item name">Item Name</Column>
<Column name="publish date">Publish Date</Column>
</Columns>
to sort by publish date descending, the appropriate sort parameter would be
sort=Publish Date,DESC,DateTime
and to sort by item name, the sort parameter would be
sort=Item Name,ASC
I'm not sure anyone can answer your question immediately, apart from probably the module author. But you have a huge advantage in this case - the module sources. Instead of browsing the assemblies with the Reflector, you can check out the latest sources and just debug it. One debug session can answer more questions than a bunch of SO posts. ;-)
Also, as a side note, you might have noticed special Sitecore logos on that page - this blog post will tell you what it means.

<cfquery> not retrieving DATA

I am unable to retrieve any data from my cfquery. Same query when i run in sql developer i get the result.
Any reason why ?
Hi all, thanks for the responses. Sorry, it was my fault.
It was a data issue. I was retrieving uncommited data from CF.
You can also build the query in CFEclipse, test it and then paste the query in your CFQuery tag.
Also check how you have put the query name in the CFoutput tag, so many times I've put #queryname# instead of queryname in cfoutput.
Is the query actually being ran?
If you can turn debugging on, does the query show as being executed?
Also when you run the same query do you mean you copy/paste the query from the debugger into sql developer?
Perhaps the same values are not being included (if you are using variables in there)