CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> CodeChargeStudio.Discussion

 verify "unique" for two database fields

Print topic Send  topic

Author Message
Alexey Rodionov
Posted: 07/31/2003, 11:11 PM

Good day!

How to organize "unique" verification for more than one field? I can
set easily for one, but if I want to verify two fields at the same
time? I have an index in database for those fields, but I get an sql
error while inserting data when unique rule doesn`t match.
I added the following in "On validation":
if (CCDlookUp("count(*)","pmnl_email","email=" .
$pmnl_email->ds->ToSQL($pmnl_email->email->GetValue(),ccsText) . " AND
list_id=" .
$pmnl_email->ds->ToSQL($pmnl_email->list_id->GetValue(),ccsInteger),
$pmnl_email->ds))
{
$pmnl_email->Errors->addError("ERROR description");
return false;
}

...but this event check all values in EDITABLE GRID : first row of the
grid makes a mistake and I receive an error. I need to check while
inserting new records + update. How to do that?

How to allow database operations on the rows that are OK, and deny
them on the rows that fail?

Oleksiy.
DonB
Posted: 08/01/2003, 5:04 AM

A thought: The BeforeInsert will trigger for each row of the grid. You
could utilize a session variable or to hold an array or other collection (at
your preference) of values, appending each one as it is inserted. This will
establish a list of values that cannot be reinserted (for all those awaiting
insertion).

So, in the BeforeInsert event, if the value is in this list, you can
terminate the INSERT by setting the AllowInsert variable to False and exit
the event routine.

If you have an issue with values already in the database being duplicated,
then you will need to examine the status returned by the INSERT in the
AfterInsert event, handle it (that is, clear it) so that the error does
trickle back to the user. There is an Error property on your datasource and
this is where the need to clear it. How you do this is language-specific.

Everything I said about "insert" also applies to "update" (if that is
relevant to your application) so you may have to deal with update in the
same manner you do with an insert.

DonB


"Alexey Rodionov" <radik@alfacom.net> wrote in message
news:9u0kivsodkbe0o5fa745gjmtjjijka094s@4ax.com...
> Good day!
>
> How to organize "unique" verification for more than one field? I can
> set easily for one, but if I want to verify two fields at the same
> time? I have an index in database for those fields, but I get an sql
> error while inserting data when unique rule doesn`t match.
> I added the following in "On validation":
> if (CCDlookUp("count(*)","pmnl_email","email=" .
> $pmnl_email->ds->ToSQL($pmnl_email->email->GetValue(),ccsText) . " AND
> list_id=" .
> $pmnl_email->ds->ToSQL($pmnl_email->list_id->GetValue(),ccsInteger),
> $pmnl_email->ds))
> {
> $pmnl_email->Errors->addError("ERROR description");
> return false;
> }
>
> ..but this event check all values in EDITABLE GRID : first row of the
> grid makes a mistake and I receive an error. I need to check while
> inserting new records + update. How to do that?
>
> How to allow database operations on the rows that are OK, and deny
> them on the rows that fail?
>
> Oleksiy.


   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.