Question

Custom Attribute with select statement

  • 19 April 2023
  • 5 replies
  • 232 views

Badge +3

Hello everyone.

I am a newbie to IFS hence this is my first question in this forum.

I just want to retrieve the last 3 digits from a column called “Part_No”, I created the flowing inquiry and validated it at the Database layer  

SELECT SUBSTR(Part_No, LENGTH(Part_No)-2) AS Truncated_Part_No
FROM Reserved_Lot_Batch

Unfortunately, I got an error from IFS when I try to save the read only Custom Attribute with select statement. Screenshot below.

 

what is wrong here?

Regards,


5 replies

Badge +3

here is a screenshot from IFS

 

Userlevel 4
Badge +9

@akrageb  

 

You are incorrectly assigning the variable part_no,

you should use :part_no (so do not forget the : sign)

 

Here is another example:

 

 

you can find more info here

 

Set Implementation Type (ifs.com)

Badge +3

@kvbe  many thanks for you reply.

 

You are right, I fixed this. The error is gone. Still however not getting my desired result.

The first issue is that instead getting the last 3 digits of part_no, I got the last 6 numbers (see the image below). I need to show only last 3 numbers whether they are digits or letters.

Please notice that the query was validated on the DB.

 

Furthermore, when the “Part_No” is a string or has letter IFS generates an error even though the cast is done using cast(). The error is below

 

{"error":{"code":"DATABASE_ERROR","message":"Database error occurred. Contact administrator.","details":[{"code":6502,"message":"ORA-06502: PL/SQL: numeric or value error: character to number conversion error"}]}}
Userlevel 4
Badge +9

@akrageb  make sure after you created your query that you delete the field and recreate it on the field. 

Als I would not do any casting in your query and make sure your custom field is a string. 

Badge +3

Hankx agian @kvbe 

In fact I could understand why I need to recreate the field again and why not casting?

 

Reply