[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 564
  • Last Modified:

"You tried to assign the null value to a variable that is not a variant data type" - AS400

I'm trying to add records in a table in AS400. I do an insert query and I get the error message : "You tried to assign the null value to a variable that is not a variant data type".

Here is my query :


INSERT INTO PRDORBIDTA_ORAALG ( BEDRAA, ARNRAA, AAKTAA, KAMCAA, AKTGAA, ALVNAA, VARTAA, OARTAA, ARVLAA, EVVBAA, BSEHAA, GWEHAA, EENHAA, VPEHAA, VERPAA, LKNRAA, ARGRAA, ARFMAA, BWRKAA, FCTRAA, USLWAA, EWLWAA, DTLWAA, TDLWAA )
SELECT 1 AS BEDRAA, qry_artikels_toadd_VERPAA.[Ref roy], "0" AS AAKTAA, 0 AS KAMCAA, "" AS AKTGAA, "" AS ALVNAA, "" AS VARTAA, "" AS OARTAA, qry_artikels_toadd_VERPAA.Description, "" AS EVVBAA, qry_artikels_toadd_VERPAA.Unité AS BSEHAA, 0 AS GWEHAA, qry_artikels_toadd_VERPAA.EENHAA, qry_artikels_toadd_VERPAA.Unité, Int([qry_artikels_toadd_VERPAA].[Quantité]) AS VERPAA, "" AS LKNRAA, qry_artikels_toadd_VERPAA.ARGRAA, qry_artikels_toadd_VERPAA.Famille, "*" AS BWRKAA, 1 AS FCTRAA, "FT" AS USLWAA, 1 AS EWLWAA, 110331 AS Expr1, 0 AS Expr2
FROM qry_artikels_toadd_VERPAA;


It seems this is not an AS400 message, but I don't know where it is coming from. I even tried casting the text value in integer before sending those to the number fields in the AS400. But nothing seems to make this error message go away.

I tried using this query in view, and it works fine. It only gives an error when trying to add into AS400.
0
vanroybel
Asked:
vanroybel
  • 2
1 Solution
 
Gustav BrockCIOCommented:
> .. and it works fine.

Yes, a select query won't fail. But study the output of this to spot the field and rows with Null values (= empty fields).
Then correct the query to output useful data or simply exclude these rows.

/gustav
0
 
vanroybelAuthor Commented:
Well It seems so easy now that you say it. For once the error message was in fact explicit. I did as you said, and now that I got no null values, it works.
0
 
Gustav BrockCIOCommented:
Great!
Thanks for the feedback.

/gustav
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now