XForms: Delete trigger in table row (repeat) - repeat

I am using an XForms' repeat to build up a table (very similar to http://wiki.orbeon.com/forms/doc/developer-guide/xforms-repeat). Each row should get a delete trigger to remove it. The following code does only delete the selected item, is it somehow possible to use the current repeat index as a value for at?
<xforms:delete nodeset="employees" at="index('employee-repeat')"/>
Thank you for your help!

If you have a delete trigger for every row, then you don't need to use the index() function. Instead, just refer to the current node, as in:
<xforms:repeat nodeset="employees">
...
<xforms:trigger>
<xforms:label>Delete</xforms:label>
<xforms:delete ev:event="DOMActivate" nodeset="."/>
</xforms:trigger>
</xforms:repeat>
If you had just one trigger for the whole repeat (i.e. at the beginning and/or end of the table listing the employees), then you could use index() to refer to the "current" employee. That means that users would first need to click somewhere on that employee to make it the current one, and then click on the button. This is a somewhat unusual web UI, and so I would rather have one delete button per employee or use checkboxes for users to select which employees they want to act on.

Related

Limit a table to hold a max of 100 records and delete the oldest

Its my intention to implement a History function in my database where users can see what records they've previously worked on. To achieve this initially, I created an extra field in the table they we're looking at and added their name from the login screen and timestamp to the record. This works, but the problem is if another user loads up the record, it overrides the last person since its just one field and its inconsistent.
So instead I created a new table and added their names and timestamps in there as a new line. The issue here is that eventually there's going to be 1000's of records in a table eating away at my hard drive space over time and eventually since the max for a table is 2GB, its just going to break one day.
After researching, Queries have a max limit, but you've still got to link that to a table that holds the data. I would like a table that contains, lets say 100 records, and at the 101st record, the oldest line is overridden and so on.
There's no code to share since my problem isn't with VBA, but rather finding a work around for this, I would of assumed this would be implemented into Access by default. I just have a table called 'History' and in VBA, an 'open recordset' function and '.addnew' 'User' and 'Date'.
You could use an After Insert data macro to remove the oldest row when a new one is added:

How to get the values of a checkbox in after trigger in PL/SQL?

I have a form for creating new events in Oracle Apex. With that form I am able to create new events just fine. But at the bottom of that form is a checkbox where the user will specify the clubs that are involved in organizing the event.
The list of values for the checkbox which you can see at the bottom of the image above is set to a sql query which selects 'club_name' and 'club_id' from 'club' table.
Now what i want to do is after the events gets successfully created, the club_id of the checked clubs with the id of the newly created event needs to be inserted into the 'club_event' junction table which related each event with their organizing club. So for that I thought of creating after trigger on events table. But I couldn't find how can I access the id's of the club selected in the plsql code. So my question is how my I do so and is my approach for relating event with organizing club fine? Thank you.
With the suggestiong from "Koen" I tried to I tries to implement it through "Process". But I am having problem in making my script work.
DECLARE
type idarray IS VARRAY(10) OF VARCHAR2(10);
ids idarray;
BEGIN
ids := apex_string.split(:P72_CLUBS, ':');
FOR id IN ids LOOP
INSERT INTO club_event
VALUES(id, P72_EVENT_ID);
END LOOP;
END;
What are the things that I am doing wrong and how may I resolve it?
You don't need a trigger for that. Use a page process instead. The values of the page item (I assume that is P1_CLUB) will be passed on page submit as a colon separated list of return values (in your case club_id). Use apex_string.split to convert the colon separated list to a pl/sql array . Loop through the array and insert/update/delete the records in/from the clubs table .
In addition to Koen's answer, if you want to view the event and also want to populate the checkbox with the checked values, you will have to set the following attributes for the checkbox page item:
Source - Type = SQL Query (return colon separated value)
SQL Query = select club_id from my_club_to_event_table where event_id = :P1_EVENT_ID
Used = Always, replacing any existing value in session state
Assuming P1_EVENT_ID is the primary key page item on that page.

How to update records form a from whose data source is set to view in Oracle Apex?

My oracle apex application has an events page that has a v_event view as its data source. This view contains all the column that an event table contains plus it also has club_name column that holds the name of the organizing club. The report displays correctly as I want it for now.
When I try to update a record I get an error saying 'data manipulation operation not legal on this view'
This must be because the data source for the page is a view. How can I solve this problem ?
Also when I try to create new events I get an error:
First I thought that the '... non key-preserved table' occurred because the relationship between event and club_event(junction table between club and event) table was one to many and same event row was repeating multiple times if there were multiple clubs organizing it. So to solve this issue I "LISTAGG" clause to combine multiple club names for a single event in a single row using comma separation as you can see in the second row of the first image above. But it didn't solve the issue. What am I doing wrong?
By the way the entire page is a "report with form" that oracle apex provides. So I am able solve this problem by create a new page and setting its data source to event table. But I just wanted to learn if there is a way that I can create a new event through the view table.
Also one final question. How can I map the values in 'From College' and 'From Community' column in the first image to be "yes" if the value in the table is 1 and "no" is the value is 0 ?
Thank you.
As far as I remember, there are several tables involved here. Even if it weren't for Apex, the answer is to create an instead of trigger which fires when view is updated, and then trigger body decides which tables are updated and how.
In Apex, you could - additionally - try to write your own processes that handle inserts, updates and deletes. In other words, don't use automatic row processing as it won't work, but create your processes.
As of mapping 1/0 to "yes/no":
in (interactive) report, use CASE (or DECODE)
in form, either create radio button or select list item
The view needs to have a 1:1 mapping to the table and the column that has the "LISTAGG" should have the attribute "Source > Query Only" set to "On".

WebDriver - locate dynamic column

I am using webdriver to test our application that contain table where the user can change the order of columns in a table,and also can remove/add columns (This is beside new column added by developers).
What is the right way to find the column I need?
One way is to go over the table header to find the column I am looking for so I have the column index and than I can access the right cell.
Is there other way ?
What about put unique id/class name for every element in table ?
Thanks
You can do two things for this situation:
Get handle to table element, and then navigate accordingly to get the columns or rows. Once you have this, then you can do all operations on them like click() etc.
Other way is, see the pattern of their ids/css because, most of the table that I have deal with will be having ids like this:
grid_name_1
grid_name_2
grid_name_3
Then you can have do this way:
String baseLocator = "grid_name_" + clickedRowIndex;
driver.findElement(By.id(baseLocator)).click(); //for click operation
Lets say user wants to click on the 3rd row, then clickedRowIndex will be 3 which selects the 3rd table row.

MS Access Delete query based on combobox

I have a table with a bunch of different fields. One is named period.
The period is not part of the raw data but I run a query when I import new data to the database that gives each record a period.
Now I need a delete query that will delete all the records that have the same period as what is selected in a combobox.
The values in the combobox come from a calendar table that contain all the possible values that could be in that period column at any time.
This is the basic query i thought would solve this issue but it tells me it is going to delete 0 rows every time I run it:
DELETE *
FROM PlanTemp
WHERE PlanTemp.period = Forms![Plan Form]!Combo163;
If you don't need the key field, just remove it.
Look at the "PROPERTIES" section and look at the column names.
Ether remove it there, or from your QUERY source.
You can also look at the Data section of the properties, and change your BOUND column, to Column 2... or whatever holds the data you want to use.