I'm using Mondrian 3.4 as the Olap Server to my application written in Java. Currently i wanted to perform some typical Olap operations in a cube, but i could't find any pointers that guided me to how to perform a drilldown operation in a cube with Mondrian. I could't find methods in the Mondrian API to do this. Is this possible? How should i do it?
Thks in advance.
I think you can check MDDataSet_Tabular inner class within mondrian.xmla.XmlaHandler, it provides API functions to store dimension values and names into MDDataSet object when you perform drilldown operation. I'm using Mondrian 3.1, but I think the source code should be the same in 3.4.
If you have additional problem, please let me know.. Good luck
There are two ways to do a drilldown. You can either get a drilldown a MDX query, or a drilldown of a particular cell.
To run a drilldown query, in olap4j, you do:
ResultSet rs =
olapConnection.createStatement().executeQuery(
"DRILLTHROUGH\n"
+ "SELECT {[Measures].[Unit Sales]} on columns\n"
+ "from [Sales]\n"
+ "where ([Promotions].[One Day Sale],\n"
+ " [Store].[Store City].[Walla Walla],\n"
+ " [Product].[Product Category].[Bread])\n"
+ "RETURN [Customers].[Name], [Gender].[Gender]");
The RETURN clause is optional and specifies which fields you want returned. To drilldown on a particular cell, you run a query, access the cell you want and call:
org.olap4j.Cell.drillthrough()
Related
I first created a SQL query and now I'm converting it into an AOT query in AX 2012 R3. I have everything else working except for one thing. I have a join in my SQL that is: JOIN dbo.INVENTJOURNALTABLE AS INV3 ON INV.INVENTBATCHID LIKE left(INV3.DESCRIPTION,17). In SQL this works and returns the data that I need.
I don't know how to create this join in the AOT query though.
That INV3.DESCRIPTION is a string that contains the InventBatchID.
Is there a way to do this kind of join?
In order to accomplish what you want with a Query object, it's difficult/unusual, and AX isn't designed to do this in a straight forward way and requires a very creative solution.
I would generally push towards writing a pure x++ query as I don't believe LEFT and LIKE can be natively combined, especially in a query. You can use * in the value for "like" as an option.
You may be able to accomplish using expressions in query ranges somehow.
If you must have a query, a way I can think is by combining a View, Computed Column, and a Query...and I can't guarantee it will work, but I can give you enough to have something to test with. Some of the information in this answer is pretty concentrated so look closely at everything to understand it.
Create a View, add the below computed column, then add it to a Query as pictured below. For the computed column, you need to add a new String field to the view and set the ViewMethod property to the name of the method. See here for more info about adding Computed Columns.
The Computed Column accomplishes the left(..., 17) part and you can browse the view to confirm.
The last part is trying to join either by a relation (pictured below, but it does not accomplish the like) or setting the Value property using an expression by following the link above. You may need to create a custom expression in \Classes\SysQueryRangeUtil. You have some experimenting to do to see if it works.
private static server str compColDescLeft()
{
#define.ViewName(InventJournalTableView)
#define.DataSourceName("InventJournalTable_1")
#define.FieldDescription("Description")
#define.LeftCount("17")
str sReturn;
str sLeftDesc;
DictView dictView;
dictView = new DictView(tableNum(#ViewName));
sLeftDesc = dictView.computedColumnString(#DataSourceName, #FieldDescription, FieldNameGenerationMode::FieldList, true);
sReturn = "left(" + sLeftDesc + ", " + #LeftCount + ")";
return sReturn;
}
I've been attempting to increase my knowledge and trying out some challenges. I've been going at this for a solid two weeks now finished most of the challenge but this one part remains. The error is shown below, what am i not understanding?
Error in sqlite query: update users set last_browser= 'mozilla' + select sql from sqlite_master'', last_time= '13-04-2019' where id = '14'
edited for clarity:
I'm trying a CTF challenge and I'm completely new to this kind of thing so I'm learning as I go. There is a login page with test credentials we can use for obtaining many of the flags. I have obtained most of the flags and this is the last one that remains.
After I login on the webapp with the provided test credentials, the following messages appear: this link
The question for the flag is "What value is hidden in the database table secret?"
So from the previous image, I have attempted to use sql injection to obtain value. This is done by using burp suite and attempting to inject through the user-agent.
I have gone through trying to use many variants of the injection attempt shown above. Im struggling to find out where I am going wrong, especially since the second single-quote is added automatically in the query. I've gone through the sqlite documentation and examples of sql injection, but I cannot sem to understand what I am doing wrong or how to get that to work.
A subquery such as select sql from sqlite_master should be enclosed in brackets.
So you'd want
update user set last_browser= 'mozilla' + (select sql from sqlite_master''), last_time= '13-04-2019' where id = '14';
Although I don't think that will achieve what you want, which isn't clear. A simple test results in :-
You may want a concatenation of the strings, so instead of + use ||. e.g.
update user set last_browser= 'mozilla' || (select sql from sqlite_master''), last_time= '13-04-2019' where id = '14';
In which case you'd get something like :-
Thanks for everyone's input, I've worked this out.
The sql query was set up like this:
update users set last_browser= '$user-agent', last_time= '$current_date' where id = '$id_of_user'
edited user-agent with burp suite to be:
Mozilla', last_browser=(select sql from sqlite_master where type='table' limit 0,1), last_time='13-04-2019
Iterated with that found all tables and columns and flags. Rather time consuming but could not find a way to optimise.
I already used the search here (and other forums as well) but haven't found an answer exacty to what I'm trying to do.
I know that it can easily be done in some other way, and this is just a small sandbox-framework I'm coding for a University course... in a real environment I'd just take Spring, Hibernate etc.
So what I did was coding myself a small generic Data Access Layer with POJOs, working with generic methods to retrieve, check or insert data to the database (Oracle). Most of this is done through PreparedStatements.
This is working as long as I don't have joins... is it possible to put in a Column as parameter?
Example:
Table A has Attribute X + others
Table B has Attribute Y + others
PreparedStatement with query SELECT * FROM A,B WHERE "A"."X" = ?
And then fill in "B"."Y" as the parameter...
The database doesn't throw me an error or exception, but the ResultSet returned after executing the statement is empty. Is it just not possible to do, or am I just missing some escaping?
I'm using PreparedStatement.setString(int index, String value) to fill in the parameter... in lack of ideas which other setX method I could use...
Again, in a real project I'd never code that myself, but rather use something like Spring or Hibernate and not re-invent the wheel, but I see it as an interesting exercise to code such a generic small data access layer myself.
No, JDBC does not allow this. Only column values can be set. If you want to make dynamic changes to the sql statement you will have to do it before you create the PreparedStatement.
One of our hibernate query uses view v_abc instead of table abc.
Issue is when i use view, the query is taking much time to execute instead when i use base table query is executing very fast, even though explain plan for both shows exact same reading (cost ,cardinality, joins).
Can anybody help what could be the reason for same ?
Please note: View v_abc is 'select * from abc';
Also, the hibernate query is as simple as below:
select v.*
from v_abc v ,pqr p
where v.col_1 =p.col_1
and p_col_2 = 123
;
Thanks
I want to generate a data model diagram from an existing oracle database.
I've tried to use SQL Developer 3.2.20.09 and followed the steps in another post and the demonstration of oracle.
But I didn't succeed. It's a little strange because I can see all the other types of objects except tables.
Here is my steps:
File -> Data Modeler -> Import -> Data Dictionary -> current database connection -> Next -> Current Schema -> Next
Do you have any idea?
Thanks in advance.
EDIT:
I think it's a specific problem in my database. I can't figure it out with SQL Developer.
Finally, I've used TOAD Data Modeler to generate E/R diagram.
As there are not solutions proposed by others, I'll mark my "solution" as answer.
I think it's a specific problem in my database.
I can't figure it out with SQL Developer. Finally, I've used TOAD Data Modeler to generate E/R diagram.
Here's what we're running to get a list of tables in version 4.1 of SQL Developer Data Modeler:
SELECT TABLE_NAME, TABLE_TYPE, TABLE_TYPE_OWNER
FROM dba_all_tables a
WHERE IOT_NAME IS NULL
AND (IOT_TYPE IS NULL
OR IOT_TYPE = 'IOT')
AND NESTED ='NO'
AND a.OWNER =?
AND SECONDARY ='N'
AND NOT EXISTS
(SELECT 1
FROM dba_queue_tables c
WHERE OWNER =?
AND c.QUEUE_TABLE = a.TABLE_NAME
)
ORDER BY TABLE_NAME
Does your connection have access to the DBA_ views?
If we don't see access to the DBA_ views, we drop down to the ALL_ views.
You can follow this tutorial
https://www.youtube.com/watch?v=bpKJmCoBy2c.
I suggest another approach for more convenience: You can drag and drop table from connection into relational screen to generate model and follow the step in the above tutorial for creating diagram.
Hope this help :)