0

I have a query that runs perfectly n SQL server but in Oracle, I get the following error:

ORA-00923: FROM keyword not found where expected

SELECT  
MyApps.AppConfigurationId, 
MyApps.GUID, 
MyApps.AppName, 
MyApps.BinaryData, 
MyApps.Color1, 
MyApps.UserCreatorName, 
MyApps.CreatedAt,  
MyApps.UserUpdaterName, 
MyApps.UpdatedAt, 
MyApps.UserPublisherName, 
MyApps.LastPublishedAt, 
MyApps.AppConfigStateId, 
MyApps.AppConfigStateLabel 
FROM 
(  
    SELECT 
        ROW_NUMBER() OVER ( 
            PARTITION BY  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."ID" 
            ORDER BY LastestPublishInfo."PUBLISHEDAT" DESC 
        ) AS RowNum, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."ID" AS AppConfigurationId, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."GUID", 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."NAME" AS AppName, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPICON1"."BINARYDATA", 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_COLORPA1"."COLOR1", 
        UserCreator."NAME" AS UserCreatorName, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."CREATEDAT",  
        UserUpdater."NAME" AS UserUpdaterName, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."UPDATEDAT", 
        LastestPublishInfo.PublisherName AS UserPublisherName , 
        LastestPublishInfo."PUBLISHEDAT" AS LastPublishedAt, 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."APPCONFIGSTATEID", 
         "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON20"."LABEL" AS AppConfigStateLabel            

    FROM     "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266" JOIN  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON20" 
                ON ( "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."APPCONFIGSTATEID" =  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON20"."ID" AND 
                     "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."PARENTAPPCONFIGID" IS NULL AND 
                     "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."ISACTIVE" = 1 
                   ) 
            JOIN  "OSADMIN_OSDEV1"."OSSYS_USER_T266" UserCreator 
                ON ( "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."CREATEDBY" = UserCreator."ID") 
            LEFT JOIN  "OSADMIN_OSDEV1"."OSSYS_USER_T266" UserUpdater 
                ON ( "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."UPDATEDBY" = UserCreator."ID") 
            LEFT JOIN  "OSADMIN_OSDEV1"."OSUSR_4BQ_COLORPA1" 
                ON( "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."COLORPALETTEID" =  "OSADMIN_OSDEV1"."OSUSR_4BQ_COLORPA1"."ID") 
            LEFT JOIN               
                ( 
                    SELECT   "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16"."APPCONFIGURATIONID", 
                             "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16"."PUBLISHEDAT", 
                            UserPublisher."NAME" AS PublisherName 
                    FROM     "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16" LEFT JOIN  "OSADMIN_OSDEV1"."OSSYS_USER_T266" UserPublisher 
                                ON ( "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16"."PUBLISHEDBY" = UserPublisher."ID") 
                    WHERE    "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16"."PUBLISHEDAT" IS NOT NULL  
                            AND 
                             "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON16"."ISACTIVE" = 0 
                             
                ) LastestPublishInfo 
                ON (LastestPublishInfo.AppConfigurationId =  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."ID") 
            LEFT JOIN  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPICON1" 
                ON(  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPICON1"."APPCONFIGURATIONID" =  "OSADMIN_OSDEV1"."OSUSR_4BQ_APPCON15_T266"."ID" ) 
) MyApps 
WHERE MyApps.RowNum = 1 
ORDER BY  
MyApps.UpdatedAt DESC 

I already tried to check syntax follow some articles but I'm not able to solve it. Added " around de the aliases, tried to replace attribute names in the subquery not to match the parent but nothing worked. Hope you could help me with this since I went to the point I have no clue about what to try next! Cheers

5
  • 3
    I don't think Oracle accepts [, ], {, or } as parts of identifiers or delimiters. You better use double quotes " or improve the table and column names. Commented Jul 18, 2020 at 23:52
  • Yeah that is not valid oracle syntax. Commented Jul 18, 2020 at 23:53
  • Sorry, you can ignore that since I took this from my own platform. I fixed the executed query on the post. Commented Jul 19, 2020 at 10:18
  • Your query looks good. What version of Oracle are you using? In any case your query would benefit from the use of table aliases. It's not easy to read or to debug. Can you provide a SQL Fiddle at dbfiddle.uk ? Commented Jul 19, 2020 at 14:27
  • We're using Oracle 12 12.1.0.2.v17. Any tip about what can be causing issues in here? Commented Jul 19, 2020 at 14:29

1 Answer 1

1

Using the following web: https://rextester.com/l/oracle_online_compiler I tryed your SQL and got the same error as you. I then started simplifing it up to:

SELECT 1 AS RowNum FROM blah

and still getting the same error. I think RowNum is a reserved word in Oracle, you can not use it as a field alias.

Sign up to request clarification or add additional context in comments.

1 Comment

That was exactly the issue..Being the RowNumber a reserved word in Oracle. Thank you very much. Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.