Re: DatabaseAddAction and unique or primary keys

2003-02-07 Thread Antonio Gallardo
Hi,

Today morning I told you about the MODULAR Database Actions, also I
pointed you to:

http://wiki.cocoondev.org/Wiki.jsp?page=ModularDatabaseActions

There you can find ALL the info about how to do what you mean. Also I can
work with sequence (you told before you use PostgreSQL 7.2).

Sheraz Sharif dijo:
> Hello all,
>
> I have been working on a website for a while.  Here is my problem - I
> can easily verify user input through forms and return any error messages
> through the xsp-formval tags.  After validation, the input is passed to
> the database.  However, I get an SQL exception :
>
> ProcessingException: Could not add record: java.sql.SQLException: ERROR:
> Cannot insert a duplicate key into unique index category_name_key
>
> This is happening because I am attempting to insert a value into a key
> column where that value already exists.  I am looking for a solution
> where cocoon will connect to the database and attempt to retreive the
> key value before the insert.  If it does not exist, it will insert it,
> otherwise it will fail and I can notify the user of the error.

I think you can do a select before and check for the result of the select.
Sorry, I use XSP, but maybe the example will work:


 
SELECT the_key
FROM the_table
WHERE the_key=
  
  


  
INSERT INTO the_table(the_key, the_data1, the_data2) ..
  
  

  
  

  


Best Regards,

Antonio Gallardo



-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




RE: DatabaseAddAction and unique or primary keys

2003-02-07 Thread Antonio Gallardo
Hi!

The problem is solved using Modular Database Actions. More info at:

http://wiki.cocoondev.org/Wiki.jsp?page=ModularDatabaseActions

Antonio Gallardo

Sheraz Sharif dijo:
> I am using postgresql 7.2..
>
> I am not sure what you mean.  Are you talking about making the database
> run a trigger before the insert happens?  If so, I do not think that
> will solve my problem.  I want cocoon to realize that there already
> exists that specific value in the table, and notify the user to try
> again. I think what I am trying to say is this.
>
> 1. User sends form to cocoon.
> 2. Cocoon processes form values.
> 3. Form values are ok, check the database to make sure primary keys and
> unique keys do not already exist
> 4. on success, insert values into database
> 5. on failure, return failure
>
> I am thinking that I need make some additions to the DatabaseAddAction
> class to make this happen.
>
> Sheraz
>
> On Fri, 2003-02-07 at 05:43, Kazmir, Jaroslav wrote:
>> Which type of database you use? Isn't it easily to use before insert
>> trigger?
>>
>> JayKay
>>
>> -Original Message-
>> From: Sheraz Sharif [mailto:[EMAIL PROTECTED]]
>> Sent: Freitag, 07. Februar 2003 12:19
>> To: [EMAIL PROTECTED]
>> Subject: DatabaseAddAction and unique or primary keys
>>
>> Hello all,
>>
>> Sorry if this gets double-posted...
>>
>> I have been working on a website for a while.  Here is my problem - I
>> can easily verify user input through forms and return any error
>> messages through the xsp-formval tags.  After validation, the input is
>> passed to the database.  However, I get an SQL exception :
>>
>> ProcessingException: Could not add record: java.sql.SQLException:
>> ERROR: Cannot insert a duplicate key into unique index
>> category_name_key
>>
>> This is happening because I am attempting to insert a value into a key
>> column where that value already exists.  I am looking for a solution
>> where cocoon will connect to the database and attempt to retreive the
>> key value before the insert.  If it does not exist, it will insert it,
>> otherwise it will fail and I can notify the user of the error.  Have I
>> been verbose enough?  If no solution exists, I am thinking I can
>> either extend or rewrite the DatabaseAddAction class to do this.  Or
>> should I abandon logicsheets all together and move to xforms?  Thanks.
>>
>
>
>
>
> -
> Please check that your question  has not already been answered in the
> FAQ before posting. 
>
> To unsubscribe, e-mail: <[EMAIL PROTECTED]>
> For additional commands, e-mail:   <[EMAIL PROTECTED]>




-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




RE: DatabaseAddAction and unique or primary keys

2003-02-07 Thread Kazmir, Jaroslav
I think, that it will help you to create a new class for checking. 
I made the same ... check and then make registration save into DB ...

  
  




... if the data are invalid, show XSP page

  



  ...  ... 



  

  

  

JayKay

-Original Message-
From: Sheraz Sharif [mailto:[EMAIL PROTECTED]] 
Sent: Freitag, 07. Februar 2003 13:07
To: [EMAIL PROTECTED]
Subject: RE: DatabaseAddAction and unique or primary keys

I am using postgresql 7.2..

I am not sure what you mean.  Are you talking about making the database
run a trigger before the insert happens?  If so, I do not think that
will solve my problem.  I want cocoon to realize that there already
exists that specific value in the table, and notify the user to try
again. I think what I am trying to say is this.

1. User sends form to cocoon.
2. Cocoon processes form values.
3. Form values are ok, check the database to make sure primary keys and
unique keys do not already exist
4. on success, insert values into database
5. on failure, return failure

I am thinking that I need make some additions to the DatabaseAddAction
class to make this happen.

Sheraz

On Fri, 2003-02-07 at 05:43, Kazmir, Jaroslav wrote:
> Which type of database you use? Isn't it easily to use before insert
> trigger? 
> 
> JayKay
> 
> -Original Message-
> From: Sheraz Sharif [mailto:[EMAIL PROTECTED]] 
> Sent: Freitag, 07. Februar 2003 12:19
> To: [EMAIL PROTECTED]
> Subject: DatabaseAddAction and unique or primary keys
> 
> Hello all,
> 
> Sorry if this gets double-posted...
> 
> I have been working on a website for a while.  Here is my problem - I
> can easily verify user input through forms and return any error messages
> through the xsp-formval tags.  After validation, the input is passed to
> the database.  However, I get an SQL exception :
> 
> ProcessingException: Could not add record: java.sql.SQLException: ERROR:
> Cannot insert a duplicate key into unique index category_name_key
> 
> This is happening because I am attempting to insert a value into a key
> column where that value already exists.  I am looking for a solution
> where cocoon will connect to the database and attempt to retreive the
> key value before the insert.  If it does not exist, it will insert it,
> otherwise it will fail and I can notify the user of the error.  Have I
> been verbose enough?  If no solution exists, I am thinking I can either
> extend or rewrite the DatabaseAddAction class to do this.  Or should I
> abandon logicsheets all together and move to xforms?  Thanks.
> 




-
Please check that your question  has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

-
Please check that your question  has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




RE: DatabaseAddAction and unique or primary keys

2003-02-07 Thread Sheraz Sharif
I am using postgresql 7.2..

I am not sure what you mean.  Are you talking about making the database
run a trigger before the insert happens?  If so, I do not think that
will solve my problem.  I want cocoon to realize that there already
exists that specific value in the table, and notify the user to try
again. I think what I am trying to say is this.

1. User sends form to cocoon.
2. Cocoon processes form values.
3. Form values are ok, check the database to make sure primary keys and
unique keys do not already exist
4. on success, insert values into database
5. on failure, return failure

I am thinking that I need make some additions to the DatabaseAddAction
class to make this happen.

Sheraz

On Fri, 2003-02-07 at 05:43, Kazmir, Jaroslav wrote:
> Which type of database you use? Isn't it easily to use before insert
> trigger? 
> 
> JayKay
> 
> -Original Message-
> From: Sheraz Sharif [mailto:[EMAIL PROTECTED]] 
> Sent: Freitag, 07. Februar 2003 12:19
> To: [EMAIL PROTECTED]
> Subject: DatabaseAddAction and unique or primary keys
> 
> Hello all,
> 
> Sorry if this gets double-posted...
> 
> I have been working on a website for a while.  Here is my problem - I
> can easily verify user input through forms and return any error messages
> through the xsp-formval tags.  After validation, the input is passed to
> the database.  However, I get an SQL exception :
> 
> ProcessingException: Could not add record: java.sql.SQLException: ERROR:
> Cannot insert a duplicate key into unique index category_name_key
> 
> This is happening because I am attempting to insert a value into a key
> column where that value already exists.  I am looking for a solution
> where cocoon will connect to the database and attempt to retreive the
> key value before the insert.  If it does not exist, it will insert it,
> otherwise it will fail and I can notify the user of the error.  Have I
> been verbose enough?  If no solution exists, I am thinking I can either
> extend or rewrite the DatabaseAddAction class to do this.  Or should I
> abandon logicsheets all together and move to xforms?  Thanks.
> 




-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>




RE: DatabaseAddAction and unique or primary keys

2003-02-07 Thread Kazmir, Jaroslav
Which type of database you use? Isn't it easily to use before insert
trigger? 

JayKay

-Original Message-
From: Sheraz Sharif [mailto:[EMAIL PROTECTED]] 
Sent: Freitag, 07. Februar 2003 12:19
To: [EMAIL PROTECTED]
Subject: DatabaseAddAction and unique or primary keys

Hello all,

Sorry if this gets double-posted...

I have been working on a website for a while.  Here is my problem - I
can easily verify user input through forms and return any error messages
through the xsp-formval tags.  After validation, the input is passed to
the database.  However, I get an SQL exception :

ProcessingException: Could not add record: java.sql.SQLException: ERROR:
Cannot insert a duplicate key into unique index category_name_key

This is happening because I am attempting to insert a value into a key
column where that value already exists.  I am looking for a solution
where cocoon will connect to the database and attempt to retreive the
key value before the insert.  If it does not exist, it will insert it,
otherwise it will fail and I can notify the user of the error.  Have I
been verbose enough?  If no solution exists, I am thinking I can either
extend or rewrite the DatabaseAddAction class to do this.  Or should I
abandon logicsheets all together and move to xforms?  Thanks.

Sheraz
-- 
[EMAIL PROTECTED]
m3b Consulting
www.m3b.net
832.573.0937




-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

-
Please check that your question  has not already been answered in the
FAQ before posting. 

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>