check duplicate values in oracle forms multi record block - oracle11g

What I wanted is to display an alert when I move to the next row if the record that I inserted is already one of the records in the multi record block.
and in what trigger must I put it?

There are several options you can use.
One is to POST values entered (in WHEN-NEW-RECORD-INSTANCE) trigger. It will, well, post everything you entered so far. Then, you can write a WHEN-VALIDATE-ITEM trigger which SELECTs from that table and checks whether such a value already exists. Alternatively, if there's the UNIQUE CONSTRAINT on that (those) column(s), database will do its job itself, i.e. raise an exception.
Another option is to literally loop through all rows in a block and compare the first row's value with all the others, then the second row's values with all of them, etc.
Or, you can use a Record Group (usually used for Lists of Values). Basically, you'd check whether value you entered exists in a record group. More info, along with a FMB file, on Craig's blog.
Or, you can use calculated items, as described enter link description here (FMB attached as well).
As you can see, quite a few ways to do that; explore each of them and pick the one you find the most useful / attractive / easy to implement.

Related

Adding a user-filled value as well as a pick value for google appmaker

I would like to define a field, where there is a list of allowed values as well as give user the option to type it in. For example, I list a bunch of previous jobs that the applicant can have, plus have them pick other and fill it in as well.
Is it possible to do this with one field or do I need two fields where the user has to type it in? Is there a doc. or sample or tutorial I can look up? Thanks.
Here is a super simple Tags sample:
https://drive.google.com/open?id=0BxtQI4fTAVQqcUx4OUJfQ1JYV2c
To cover your exact use case you just need to:
Add logic to check if record already exists
1.1 If record doesn't exist, then create one
Create relation between records
If you don't care about duplicates in your database, then you can skip step 1 and always do 1.1 and 2.

Choosing from multiple query results to display in a single form

I have a form that submits parameters to a query, then opens the resulting record in another form. The problem is, whenever there is more than one record it automatically puts the first one into the from without any kind of option to choose the record I want. I have a macro set up on the search button on the first form that submits the parameters to the query and then displays it in the second form, I've tried to set up another macro in between the two, but I don't know if it's possible to set up the expression creator to check the number of rows resulting from a query. Is it possible to modify the query to create a prompt to choose which record I want? Or should I change something else?
This is the query:(automatically created by access)
SELECT CHILD.CHILD_L_NAME, CHILD.CHILD_F_NAME, CHILD.DOB, CHILD.GENDER, CHILD.DAYS_IN_CARE,
CHILD.HOURS_PER_DAY, CHILD.ENROLLMENT_DATE, CHILD.CHILD_ADDRESS, CHILD.CHILD_CITY,
CHILD.CHILD_ZIP, CHILD.CHILD_STATE, CHILD.CLASSROOM, CHILD.SNACK, CHILD.LAST_UPDATED, CHILD.CIN
FROM CHILD
WHERE (((CHILD.CHILD_L_NAME)=[Forms]![Search]![L_NAME]) AND
((CHILD.CHILD_F_NAME)=[Forms]![Search]![F_NAME])) OR
(((CHILD.CHILD_L_NAME)=[Forms]![Search]![L_NAME]) AND
((CHILD.DOB)=[Forms]![Search]![DOB])) OR
(((CHILD.DOB)=[Forms]![Search]![DOB])) OR
(((CHILD.CHILD_L_NAME)=[Forms]![Search]![L_NAME]));
If I understood well your problem and you use VBA it's quite easy to do.
You can create a reduced query based on the query you're creating with the button. This new query should include all and only the fields that allows you to discriminate beetwen the records to show in the 2nd form.
For instance it could include LastName, FirstName and classroom to select between children with same full name.
You can count the number of records of this 2nd query and if greater than 1 it means that you have more than one children to show.
So you can use this 2nd query to populate a combo-box or a listbox for selecting the record you really want to show.
When number of records is 1 you can simply skip the listbox population using an if statement on recordcount.
Next step is opening the form with the selected (or unique) record.
Bye

"COLUMNS_UPDATED" in SQLite triggers

I need a trigger to log updates on a table. As I want to log it I need to know the name of the updated column(s) in the trigger body. We have NEW and OLD but it doesn't tell me which column were updated.
If nothing else, I still have the choice between these two ugly solutions:
use one IF NEW.val <> OLD.val per column
use one trigger per column
PS: I saw this "COLUMNS_UPDATED" in SQL which represents what I am looking for.

InfoPath Repeating Tables: Force all rows to have same value for one column

Does anyone know a way to have all the rows of one column of a repeating table to always have the same value?
Say the user changes the value in the first row for that column, then all the other cells in that column change to have the new value. (Preferably this will happen if a user changes any cell in the column, not just the one in the first row, but just the first row would be fine if that's all that's possible).
I have access to both InfoPath 2007 and InfoPath 2010 so can use either. The form submits data to and receives data from an SQL Server database. Code is fine if this requires it.
You basically want to change the field from a repeating field to just multiple copies of the same field (since you want it to always be the same there is no point in storing multiple versions).
On the data source tab, all the fields that you put in the repeating section are in a group folder with the little repeating icon on it. Right click on the field you want to be non repeating and choose move. Put it anywhere outside the repeating group folder (the encompassing folder is usually a good choice but it can be anywhere). The field on the design surface will now show a little info box that says "this item can't be repeated" (or similar).
Now you just have multiple copies of the same field - so if you change any one of them they will all update to reflect the value.

Handling SortOrder fields in SQL Server

In a specific table I have a SortOrder integer field that tells my page in which order to display the data. There are sets of data in the this field (based on a CategoryID field), and each set will have its own ordering. Users can add/remove/update records in this table.
My question is what is the best way to manage this SortOrder field? I would like to "reseed" it everytime a record is deleted or updated. Is this something I should be using a trigger for? Or should my code handle it and manage the reseeding?
What I used to do is use only odd numbers in the SortOrder field so upon changing the order, I would add or subtract 3 from the current value of the modified item and then do a reseed (order the items again using odd number indexes). Also I used to reseed after every insert or delete.
All you really have to worry about is swapping any two fields. All new entries go to the end and i'm sure you've got a mechanism by which the user can change the order. The order change, move up or down, really is a swap with a neighboring field. All you really care about is that all the fields are sorted properly. Don't let a mathematical sense of aesthetic drive you into creating something overly complex. (You'll end up with holes in your sequence after deletes are made but that's OK. It's an internal sequence marker used for ORDER BY. the numbers don't need to be made contiguous.)

Resources