25
Views
10
Comments
Solved
Error in Sql query
Question

Hi All, 

I have created a sql query but if I run it , I get this following error 

"Id  is an unknown attribute of AssetLocationStatus at GetClaimStatusChangeRequestList"

Please assist with the below query. Thanking you in advance

SELECT Distinct 
'InstructionCode' = {Instruction}.[Code],
'Status' ,
'AssetLocationStatus' = {AssetLocationStatus}.[Label],
'FromClaimStatus' = {InstructionClaimStatus}.[Id],
'ToClaimStatus' = {InstructionClaimStatus}.[Id],
'RequestedBy' = {User}.[Id],
'RequestedOn' = {ClaimStatusChangeRequest}.[RequestedOn]
'UpdatedBy' = {User}.[Id],
'UpdatedOn' = {ClaimStatusChangeRequest}.[ModifiedOn]

from Instruction
inner join {SalvageAsset} ON {Instruction}.[SalvageAssetId] = {SalvageAsset}.[Id]
inner join {InstructionClaimStatus} ON {Instruction}.[InstructionClaimStatusId] = {InstructionClaimStatus}.[Id]
inner join {ClaimStatusChangeRequest} ON {InstructionClaimStatus}.[Id] = {ClaimStatusChangeRequest}.[InstructionClaimStatusToId]
inner join {User} ON {ClaimStatusChangeRequest}.[RequestedBy] = {User}.[Id]
inner join {User} ON {ClaimStatusChangeRequest}.[ApprovedBy] = {User}.[Id]
inner join {InstructionBusinessUnit} ON {Instruction}.[FMSBusinessUnitId] = {InstructionBusinessUnit}.[Id]
inner join {AssetLocationStatus} ON {SalvageAsset}.[AssetLocationStatusId] = {AssetLocationStatus}.[Id]

where {ClaimStatusChangeRequest}.[InstructionClaimStatusToId] IN (7,11)
and {Instruction}.[Code]  like '%' + @Search_Keyword + '%' or
{Instruction}.[ClaimNumber]  like '%' + @Search_Keyword + '%' or
{Instruction}.[PolicyNumber] like '%' + @Search_Keyword + '%'
and
{ClaimStatusChangeRequest}.[RequestedBy] = @Search_RequestedBy or @Search_RequestedBy = 0
and
{ClaimStatusChangeRequest}.[ApprovedBy] = @Search_ApprovedBy or @Search_ApprovedBy = 0
and
{AssetLocationStatus}.[Id ]= @Search_AssetLocationStatusId or @Search_AssetLocationStatusId = 0
and
{Instruction}.[FMSBusinessUnitId] = @Search_BusinessUnit or @Search_BusinessUnit = 0


UserImage.jpg
Thandeka Zungu
Solution

It was complaining about the following: 

{Instruction}.[Code]  like '%' + @Search_Keyword + '%' or
{Instruction}.[ClaimNumber]  like '%' + @Search_Keyword + '%' or
{Instruction}.[PolicyNumber] like '%' + @Search_Keyword + '%'

So I did it like this:

{Instruction}.[Code]  like @Search_Keyword 

{Instruction}.[ClaimNumber] like @Search_Keyword
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Maybe remove this space:

UserImage.jpg
Thandeka Zungu

thank you Daniel I got where the error is coming from , but it's giving me another error now  saying "input string was not in a correct format "  Please see below

{ClaimStatusChangeRequest}.[RequestedBy] = @Search_RequestedBy or @Search_RequestedBy= 0
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

If @Search_RequestedBy is of data type text then a string literal needs to be provided, the fact that you have condition set to  =0 makes me assume you are providing numeric data

UserImage.jpg
Thandeka Zungu
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

That error message is then related to something else

2025-01-09 14-56-57
IQ78

Hi Zungu,

I tried a simpel case and it is okay:

Why not try first and see the executed sql?

regards

2024-06-13 07-53-34
Paulo Moreira
 
MVP

Hi Thandeka,

Can you please share the data types of your input parameters, and also the structure you are using as the output (attributes and data types)?

Thank you.

Best regards,

Paulo

UserImage.jpg
Thandeka Zungu

Hi Paulo


Thank you so much I managed to resolve the error. Thank you.

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Could you also share what fix you made to the SQL to resolve the problem?

UserImage.jpg
Thandeka Zungu
Solution

It was complaining about the following: 

{Instruction}.[Code]  like '%' + @Search_Keyword + '%' or
{Instruction}.[ClaimNumber]  like '%' + @Search_Keyword + '%' or
{Instruction}.[PolicyNumber] like '%' + @Search_Keyword + '%'

So I did it like this:

{Instruction}.[Code]  like @Search_Keyword 

{Instruction}.[ClaimNumber] like @Search_Keyword
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.