Note that there are some explanatory texts on larger screens.

plurals
  1. POSSIS Equality Operator not working as expected
    primarykey
    data
    text
    <p>I have an SSIS package that is hooked into a MySQL database that has a <code>tinyint(1)</code> field which is set to the value <code>4</code> and I'm checking to see if that value is <code>4</code> in the database because it should not change based on the incoming flat file if it is already set to <code>4</code>, but it doesn't seem to be working.</p> <p>It should not be updating the status because the field is set to <code>4</code> but I guess I just don't understand why the expression isn't working. I have tried all the different <code>int</code> types for SSIS and it doesn't matter because it always sets the status to <code>1</code>. Based on a quick google search a <code>tinyint</code> should be an <code>unsigned 1 byte int</code> which is why I am casting it to <code>DT_UI1</code></p> <p>Incoming values from flat file the first being the product and the last being the status</p> <pre><code>"039414","*****","*****","*****","*****","*****","*****","*****"," " </code></pre> <p>Existing value from the database the first being the product and the second being the status</p> <pre><code>039414 4 </code></pre> <p>I handle the status by the following derived column expression, basically if there is no value it should be <code>1</code> otherwise it should be <code>4</code></p> <pre><code>LEN(TRIM(Status)) &gt; 0 ? (DT_UI1)4 : (DT_UI1)1 </code></pre> <p>Here is the derived column expression that I'm using to set the product_status (products_status being the actual field from the database and prod_status the status from the incoming flat file):</p> <pre><code>((DT_UI1)products_status == (DT_UI1)4) || ISNULL(prod_status) ? (DT_UI1)4 : (DT_UI1)prod_status </code></pre> <p>What I'm expecting to happen is a few products should keep their status of <code>4</code> but are being updated to <code>1</code>, does anyone have an idea why?</p> <p><strong>Edit:</strong></p> <p>I tried changing the expression to the following with no success.</p> <pre><code>(DT_UI1)products_status == (DT_UI1)4 || ISNULL(prod_status) ? (DT_UI1)4 : (DT_UI1)prod_status </code></pre> <p>and</p> <pre><code>((DT_UI1)products_status == (DT_UI1)4 || ISNULL(prod_status)) ? (DT_UI1)4 : (DT_UI1)prod_status </code></pre> <p>and just the base test</p> <pre><code>(DT_UI1)products_status == (DT_UI1)4 ? (DT_UI1)4 : (DT_UI1)prod_status </code></pre> <p><strong>Solution:</strong></p> <p>I ended up casting the field in the query to an integer because it was being pulled in as a <code>boolean</code> instead of an <code>int</code></p> <pre><code>CAST(products_status AS SIGNED) </code></pre> <p>Then changed my expression to the following and it worked as expected</p> <pre><code>(products_status == 4 || ISNULL(prod_status)) ? (DT_I4)4 : prod_status </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload