<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Database table and Unique key in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673959#M297530</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As saxena said, you cannot do it directly from DB level.  Either you have to achieve it thru' programming or keep both fields as key field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 06 Nov 2006 11:51:17 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2006-11-06T11:51:17Z</dc:date>
    <item>
      <title>Database table and Unique key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673954#M297525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a database (customizing) table with two columns; one of them is a primary key and the other column should have the following behavior: Entering data for this column is optional. However, if some data is entered, it should be unique when compared to the existing values in that column. I tried unique index on this column but the problem is that multiple rows cannot have this column left unfilled. So, can anybody tell me how I can achieve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santhosh N&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Nov 2006 09:01:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673954#M297525</guid>
      <dc:creator>former_member24570</dc:creator>
      <dc:date>2006-11-06T09:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Database table and Unique key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673955#M297526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Santhosh,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the code level of the pgm u can do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the database for the exixting values befor u insert a new value to that field in DB from the pgm.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it exists dont allow to enter, other wise allow.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rgds&lt;/P&gt;&lt;P&gt;Anver&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if hlpd pls mark points&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Nov 2006 09:04:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673955#M297526</guid>
      <dc:creator>anversha_s</dc:creator>
      <dc:date>2006-11-06T09:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Database table and Unique key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673956#M297527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi santhosh,&lt;/P&gt;&lt;P&gt;U can give a check table to that particular field. so that the field becomes unique by assigning the cardinality 1:1. and maintain the required unique values in the check table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;santhosh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Nov 2006 09:08:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673956#M297527</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-06T09:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Database table and Unique key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673957#M297528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am more interested in have a check done by the database itself rather than a program. Generally speaking, a unique key defined on this should solve the problem. But I do not know whether this can be done in ABAP. Secondly, the content of this field is unknown.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Santhosh N&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Nov 2006 09:14:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673957#M297528</guid>
      <dc:creator>former_member24570</dc:creator>
      <dc:date>2006-11-06T09:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Database table and Unique key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673958#M297529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Santhosh,&lt;/P&gt;&lt;P&gt;    As you mentined you have 2 fields in your table, one is primary key and other is a simple field. &lt;/P&gt;&lt;P&gt;this check can not be done by the database as this second field is not a primary key and as you said the content of this field can be anything and there can't be a check table for the same, even if you have a check table then you can not avoid the repetation of the same content for this field.&lt;/P&gt;&lt;P&gt;Now the only solution left is to do it programatically. &lt;/P&gt;&lt;P&gt;For eg: when ever user inserts a new entry into the database you can put a check &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  select * from &amp;lt;table&amp;gt; 
     into table itab.
  read table itab into wa
      with key &amp;lt;field2&amp;gt; = user_input.
   if sy-subrc = 0.
      error message "this entry already exist".
   else.
     insert user_input into &amp;lt;table&amp;gt;.
   endif.
 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;hope this helps.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;kinshuk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Nov 2006 10:26:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673958#M297529</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-06T10:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: Database table and Unique key</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673959#M297530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As saxena said, you cannot do it directly from DB level.  Either you have to achieve it thru' programming or keep both fields as key field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Nov 2006 11:51:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/database-table-and-unique-key/m-p/1673959#M297530</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2006-11-06T11:51:17Z</dc:date>
    </item>
  </channel>
</rss>

