<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Check constraint in appian MYSQL database</title><link>https://community.appian.com/discussions/f/new-to-appian/21684/check-constraint-in-appian-mysql-database</link><description>Hello, 
 
 I wonder if it is possible to apply check constraint in appian database? 
 
 Secondly, can it be possible to update the values in a table column based on the values in second column in the same table?</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Check constraint in appian MYSQL database</title><link>https://community.appian.com/thread/87062?ContentTypeID=1</link><pubDate>Tue, 19 Oct 2021 11:51:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:565531f4-ab3e-499f-9bba-dacacb547d38</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;We typically implement this kind of checks in the application or UI layer. Not in DB.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Check constraint in appian MYSQL database</title><link>https://community.appian.com/thread/87059?ContentTypeID=1</link><pubDate>Tue, 19 Oct 2021 08:47:38 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:4ff098fd-10f2-4e33-b48e-9f53fcfdfbe2</guid><dc:creator>xug0001</dc:creator><description>&lt;p&gt;Thank you for your reply. However I still can not add check constraint even I make sure all data is fit to my check condition. Like this.&lt;/p&gt;
&lt;p&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/62/pastedimage1634632745529v2.png" alt=" " /&gt;&lt;img src="/resized-image/__size/320x240/__key/communityserver-discussions-components-files/62/pastedimage1634632705370v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;It looks like the key &amp;#39;check&amp;#39; is illegal on APPIAN cloud database. Because it remind me I need a delimiter in appian rule. It means the key word &amp;#39;CHECK&amp;#39; can only be used at the first word in a sql.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;your script is exactly right. I can easily run the constraint SQL in other tools .&lt;/p&gt;
&lt;p&gt;I had solved this question in another way. By creating a trigger to validation before insert.&lt;/p&gt;
&lt;p&gt;Thank you so much.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Check constraint in appian MYSQL database</title><link>https://community.appian.com/thread/85615?ContentTypeID=1</link><pubDate>Thu, 09 Sep 2021 01:43:58 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:23b9c3ae-7fb4-4438-8d7d-8b38b70cf1d7</guid><dc:creator>vimalkumars</dc:creator><description>&lt;p&gt;&lt;a class="internal-link view-user-profile" href="/members/xug0001"&gt;xug0001&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You will get this error, when the table already has some data and fails to qualify the check constraint requirements. Try to fix the data first and then create the check constraint.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I was able to re-produce the issue by following the scripts below&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;CREATE TABLE Persons (
    ID int NOT NULL,
    LastName varchar(255) NOT NULL,
    FirstName varchar(255),
    Age int,
    City varchar(255),
    PRIMARY Key (ID)
);

INSERT INTO `Persons` (`ID`, `LastName`, `FirstName`, `Age`, `City`) VALUES (&amp;#39;10&amp;#39;, &amp;#39;Test&amp;#39;, &amp;#39;Test&amp;#39;, &amp;#39;17&amp;#39;, &amp;#39;Test&amp;#39;);

ALTER TABLE Persons ADD CONSTRAINT CHK_PersonAge CHECK (Age&amp;gt;=18); 
-- This will throw the error message as you mentioned


-- Fix the data by using the blow query and create check constraint
UPDATE `Persons` SET `Age` = &amp;#39;18&amp;#39; WHERE `Persons`.`ID` = 10;
ALTER TABLE Persons ADD CONSTRAINT CHK_PersonAge CHECK (Age&amp;gt;=18); &lt;/pre&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Check constraint in appian MYSQL database</title><link>https://community.appian.com/thread/85488?ContentTypeID=1</link><pubDate>Mon, 06 Sep 2021 07:24:56 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:351402ab-b08a-41ae-8618-461d23e81544</guid><dc:creator>xug0001</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I just find appian cloud - database&amp;nbsp; cannot&amp;nbsp; add check constraint by sql. It always remind me&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;quot;&amp;nbsp;&amp;nbsp;&lt;span&gt;A new statement was found, but no delimiter between it and the previous one. (near &amp;quot;check&amp;quot; at position 84 )&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;img src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/62/pastedimage1630913031723v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So I want to know Whether can I use the check order to complete my constraint.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Check constraint in appian MYSQL database</title><link>https://community.appian.com/thread/84815?ContentTypeID=1</link><pubDate>Fri, 20 Aug 2021 15:01:30 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:1fb2611a-51f0-47f9-81f1-48ccc1298c6c</guid><dc:creator>Chris</dc:creator><description>&lt;p&gt;CHECK constraint - if you have access to the database directly I don&amp;#39;t see why you could not apply CHECK constraints where you would like, but note I am not a MySQL expert.&lt;/p&gt;
&lt;p&gt;Additionally, you can certainly update values in a table column based on another.&amp;nbsp; Utilize a!queryEntity() to retrieve data into your CDT, manipulate the CDT as needed, then Write to Datastore back to the DB.&amp;nbsp; More details on your use case might be helpful here however.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>