Error trying to do insert on table

Experts,

I am new to the SQL DBF platform.  I am trying to update a table with a rate.  I created a column

, 0 as rate

When trying to update rate using query below

UPDATE #1 D
      SET RATE = (SELECT IPRS_RATE FROM #DISTINCT_PRICE       P                    
                  WHERE TRIM(D.IPCD_ID) = TRIM(P.IPCD_ID)
                  AND P.IPRS_RATE IS NOT NULL)

I get this error

Error(21) ASA Error - 1002005: Tried to insert a null value into a non-null field RATE on row 98595

Can someone tell me how to rectify this issue by field definition or modification to update query?
moriniaAdvanced Analytics AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CamilliaCommented:
That error means your data has a null value in the result column and RATE column doesn't allow null.

Run the query by itself and see the values. Is there a null column?

SELECT IPRS_RATE FROM #DISTINCT_PRICE       P                    
                  WHERE TRIM(D.IPCD_ID) = TRIM(P.IPCD_ID)
                  AND P.IPRS_RATE IS NOT NULL
Julian HansenCommented:
Try this
UPDATE #1 D
      SET RATE = (SELECT P.IPRS_RATE FROM #DISTINCT_PRICE P
                  WHERE TRIM(D.IPCD_ID) = TRIM(P.IPCD_ID)
                  AND P.IPRS_RATE IS NOT NULL AND P.IPRS_RATE <> '')

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
moriniaAdvanced Analytics AnalystAuthor Commented:
julianH

I tried the update above and I get Invalid data type comparison in predicate

Camilla,

The file does not appear to have nulls when I do the select.  When I try to select iprs_rate  is null I get nothing.
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

Julian HansenCommented:
What database are you using?
CamilliaCommented:
Sql  server
CamilliaCommented:
Sorry.  Mistook this for my own ticket. On my phone and can't delete my previous comment for some reason.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.