Oracle Apex email validation - oracle-apex

I have an item to enter the email ids item_email
I need to give validation for email id item item_email that the email id should not exists already in table.
So I have to create email validation please help me to proceed on this.

You need to create a Validation (Processing tab) with type No Rows Returned, and put the following to the validation query:
select 1
from table_with_emails
where email_column = :P_EMAIL_ITEM
UPD
To check email: create a new validation (it is easier than add two checks in one) with type PL/SQL Expression, and add the following:
regexp_like (:P_EMAIL_ITEM, '^[A-Za-z]+[A-Za-z0-9.]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$')
Creating a new validation also allows you to define two different error messages: when email is already exists and when it has wrong format.

Additionally, consider creating UNIQUE INDEX on e-mail column. Apex validation would do the job, but won't prevent another ways of inserting data.

Related

Editing of django form with primary key fields

I have a django model form for which I allowed partial form save since its a long form. Now I want the user to come back and complete the form later.
There is one hindrance however that my database cannot accept duplicate entries with same primary key. So should I remove primary key in my database to solve this or is there another way to make it possible? Suggestions please.
Why not keep only one row per user for that form? Just add one boolean field to check whether the form is submitted or is a draft. Something like is_submitted=models.Boolean(default=False). Keep updating the row with the new values on each partial save (a separate button for Save or an AJAX call for auto save).
When the form is submitted, just mark the field is_submitted = True and perform whatever actions you want after that.

Email Validation to avoid duplicate entry within two items Apex

I am having two items:
P1_email
p2_emails
Here I want to validate the email ids, the same email ids should not enter with these items.
If I enter same email id in both items, it should raise an error:
its not possible to enter the same email id in both place.
The simplest option is to create validation on P2_EMAILS item. Choose PL/SQL Function (returning error text). Code to be used:
if :P1_EMAIL = :P2_EMAILS then
return ('It is not possible to enter the same email ID in both places');
end if;
Note that this won't handle invalid e-mail addresses (such as "little#foot#gmail#com"), NULLs etc. - as I said, it is the simplest way to do what you asked.

how to match a field name with another field name

I have two fields that run throughout a website that I would like to match so that when a user inputs a value either of the fields, it will match the other field. I'm using Sitecore Rocks and am trying to use a query to do this.
select ##h1#, ##Title#
from /sitecore/Content/Home//*[##h1# !="##Title#"];
update set ##h1# = ##Title# from /sitecore/Content/Home//*[##Title# = "<id>"];
What am I missing here?
This article talks about tapping in to the item:saving event which allows you to compare the fields values of the item before and after the changes:
http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2010/11/Intercepting-Item-Updates-with-Sitecore.aspx
Using this, you can determine which field has been amended, then change the other to match.
I've had to do something similar to this when a new field was added, and we wanted to set the initial value equal to an existing field. It may be a bug in Sitecore Rocks, but I found it would only update a field when a static value was part of the query.
When I ran ##h1# = ##Title#, the query analyzer would return the correct number of items updated, but no values were actually updated. However, ##h1# = '<id>' worked perfectly. After trying a number of things, I found this did what I wanted.
update set ##h1# = '' + ##Title# from /sitecore/Content/Home//*[##Title# = "<id>"];
I hope that helps.

How to remove the meta data field from multi id queries

I am using the open_graph Explorer tool to test this out and I need to be able to get the first_name, last_name and installed from 1000 users. At the moment I group up the users in grouped of 50 for a single query and batch them into up to 20 queries in a batch request.
A single query looks as follows
?ids=100003825998801,100003825998802,547884299,100003825998803,100003825998804,100003825998805,100003825998806&fields=first_name,last_name,installed
Now, the question is, when you use multiple ids in a single query like I did, facebook seems to "force" certain fields on you, large fields, such as "metadata" and "fields". Is it possible to remove these fields from the result set of the query?
Also, any advice on how to make this more efficient would also be great.
Thank.
Have you considered using FQL instead …?
SELECT first_name, last_name, is_app_user FROM user
WHERE uid IN (100003825998801,100003825998802,547884299,100003825998803,
100003825998804,100003825998805,100003825998806)
– that gives you just the info you want, you only have to watch out for the fact that the installed field is named is_app_user in FQL.

Oracle APEX - Validation against a List of Values

In Oracle APEX, is it possible to create a validation so that field B cannot be null if a "Modem" is selected in field A? (field A is a Select List that contains a List of Values that uses a query to receive it's list of values)
Thanks Tony,
Your solution makes sense but it didn't work in my case.
Here is my validation:
The result is not what I expected. I would like an error only to show up for "Unit Ip Address" when Modem is the selected Device Type when the field is null.
Additional Info that describes the "Device Type":
Yes - see this example, where field Commission cannot be null if "Salesman" is selected in field Job.
It is simply a "Not Null" validation on item P15_COMMISSION, with a condition to perform the validation only when P15_JOB has the value "Salesman"
This is the validation definition I used:
Note that the condition on the validation is based on the return value of the LOV, not the display value. In my case they happen to be the same, but in yours they are not and your condition should be based on the ID of the device type rather than the description.