Checking if row movement option is enabled in a view - view

DB2 allows to enable or disable row movement in a UNION ALL view:
CREATE OR REPLACE VIEW TEST.TWO_TABLES_V
AS
SELECT *
FROM TEST.TABLE_1
UNION ALL
SELECT *
FROM TEST.TABLE_2
WITH ROW MOVEMENT;
The last line in the above example turns on row movement.
I need to divide views by this property, and I've tried to find the metadata attribute responsible for the property, in the following SYSCAT views:
VIEWS
TABLES
TABCONST
CHECKS
But no luck. Could anyone give directions to a catalog view and column(s) I should check?

I would do it like this:
SELECT VIEWSCHEMA, VIEWNAME
FROM SYSCAT.VIEWS
WHERE LOCATE('ROW MOVEMENT',TEXT) > 0

Related

BIRT allow user to dynamically select report's columns

I want to add an option for the user when creating the report to select the columns that the report will show. See the attached image below on how it is suppose to look.
Is there a way to do that?
I don't know about the parameter dialog, but assuming that your column names are in an array.
You can have an SQL query with all possible column names
(probably you should use special comments to mark the beginning and end of the select list).
E.g.
select
'X' as dummy
-- BEGIN COLS
, column1
, column2
...
-- END COLS
from ...
where ...
order by ...
Then, in the beforeOpen event of the query, you can access and modify the query with this.queryText (IIRC) and remove all those lines ("," + columnname) in the marked part for which columnname is not contained in the array.

Creating a Column Link in an Interactive Report -Oracle Apex

I am using Apex 20.1.0.00.13, trying to create link on a column of a Classic Report.
I have followed the step to create the link for a column and redirect it to a page in the same application as the steps below :
To create a link to another page, in the Link Builder - Target dialog:
Type - Select Page in this Application.
Page - Specify the target page number.
Set Items - Select a Name and Value to specify session state for an item.
Clear Session State, Clear Cache - Specify the page numbers on which to clear cache. To specify multiple page, enter a comma-delimited list of page numbers.
Rest Pagination - Select Yes to reset pagination for this page.v
Advanced, Request - Specify the request to be used.
Click OK.
But when I am setting the item and values to specify session state for an item, the Set Items : Name doesn't populate the columns, it appears blank, Could someone let me know where I am going wrong.
I am trying to achieve a link from page 1 say a row with dept no - 2, to be directed to page 2 with details of dept 2 . Is there any other way to do it. Since its a column and not an item I am unable to pass it as a parameter to the next page.
Thanks in advance !
Right; there are no "items" here, you have to create hyperlinks within the report.
Suppose that this is classic report's query:
with test (id, name) as
(select 1, 'Google' from dual union all
select 2, 'Yahoo' from dual union all
select 3, 'Bing' from dual
)
select
id,
'<a href="' || case
when name = 'Google' then 'https://www.google.com'
when name = 'Yahoo' then 'https://www.yahoo.com'
when name = 'Bing' then 'https://www.bing.com'
end
|| '" target="_blank">' || name || '</a>' as link
from test
order by name;
Go to LINK column's properties and set "Escape special characters" to "No". Run the report; everything should work OK.
If - as you say - use it to navigate to another page in your application and set some items to some values (from the IR), then you'd do something like this:
SELECT
'f?p=&APP_ID.:217' ||
':&APP_SESSION.::NO::P217_ID' ||
':' || r.id
as link, ...
FROM my_table r ...
In other words: it navigates to page 217 and passes r.id column value into P217_ID item which is located on page 217.
link column from such a query can be referenced when creating a link column. It would be a
link to custom target
target type = URL
URL = #link# (literally, type #link#)
Probably you could change and merge these two pages into one Master-Detail page. This way you could use the built in lookup function.

SQLAlchemy: substitute a view for a table when selecting

I've a normal select:
e = session.query(MyTable).filter(MyTable.pk=='abc').all()
Where MyTable is mapped to my_table in db.
I've also created a derived view my_view in database that has the exact same named columns as my_table.
Is there a way to substitute in my_view for my_table at query time so that I get back rows from the view? Obviously the resulting objects would need to be read only - am not intending to alter them.
So basically I'd want the SQL to be
FROM my_view AS my_table
instead of
FROM my_table
With everything else the same in the query.
I'd prefer not to create another mapper unless it can be done automatically somehow as MyView has over 60 columns same as MyTable.
Update: select_entity_from seems to be what I need, but in this case it just adds to the FROM tables, instead of replacing:
v = Table('my_view', metadata, autoload=True)
print session.query(MyTable).select_entity_from(v).filter(MyTable.pk=='abc')
"SELECT ... FROM my_table, my_view WHERE my_table.pk = 'abc';"
But the following only has one FROM entity:
print session.query(MyTable).\
select_entity_from(select([MyTable])).\
filter(MyTable.pk=='abc')
"SELECT ... FROM (SELECT ... FROM my_tabl) AS anon_1 WHERE anon_1.pk = 'abc';"
Further digging has got me closer to the answer but no joy. Posting progress here in case it solicits further thoughts:
from sqlalchemy.orm.util import aliased
session.query(MyTable).select_entity_from(
select([aliased(MyTable, alias=v, adapt_on_names=True)])).\
filter(MyTable.pk=='abc')
adapt_on_names seems to be what I need, and I've double checked that the view has the exact same column names as the table, but the above still produces two froms.
Filed what I thought was a bug: https://bitbucket.org/zzzeek/sqlalchemy/issues/3933/allow-passing-aliased-to
Final answer was:
session.query(MyTable).select_entity_from(
text('SELECT * FROM my_view').columns(*MyTable.__table__.columns)).\
filter(MyTable.pk=='abc')

How to select a row in a table and select a specific radio button next to it

I would like to select a specific row in a table on a website and select a button next to it. The problem I have is each time I select the button it remembers the last button by position xpath=(//a[#id='DeleteLnkBtn'])[4] but i would like to select the row by name and select the button unique to that row. There are multiple rows with the same buttons all having the same name (Delete).
HTML:
<td>Auto Missed Session 2</td> <a id="DeleteLnkBtn" >Delete</a>
My aim is to reference the row by a text in the table "Auto Missed Session 2" and click on the delete button.
Here is what I've tried so far.
Option 1 - driver.findElement(By.xpath("//tr/td[contains(text() = 'Auto Missed ssion 2', + 'DeleteLnkBtn')]")).click();
Option 2 - driver.findElement(By.xpath("(//tr/td[contains(text(),'Auto Missed Session 2' + 'Delete')])")).click();
The above fails stating this is not a valid Xpath expresssion on Option 1 and No such element: unable to locate element on Option 2
The table data looks like this
td> Auto Missed Session 2 /td> - This is the name of the row in the table i would like to select.
a id= "DeleteLnkBtn" This is the button i would like to select.
Xpath of the button is //*[#id="DeleteLnkBtn"]
Thanks.
Try below code and let me know the result:
driver.findElement(By.xpath("//td[text() = 'Auto Missed Session 2']/following::a[text()='Delete']")).click();

How to know the number of results of a Table-Group?

There is a Table in a report , then I inserted a Group within it. Then I added a footer row within the Table. I want to hide this row if the Group has just 1 row result. So how to know the number of results of the Group ?
Select the table -> binding tab -> Add aggregation
Select "count" as function, select any field as expression and set "aggregate on" to the group. Then use this new binding in visibility expression of the footer row.

Resources