简体   繁体   中英

Getting Pl/sql ora-00909 error, where same code doesn't give any errors on mysql

I have a page which works great with mysql and php, so I'm trying to use oracle with php in the same page. I'm very new to pl/sql and I have a problem. (code works on mysql by the way)

I get an error (ORA-00909)in the following code sample, what seems to be the problem can anyone tell me?

concat(isnull(concat(sihe.V_1_INT, '~'), ''),
        isnull(concat(sihe.V_1_DOUBLE, '~'), ''),
        isnull(concat(sihe.V_1_DATE_1, '~'), ''),
        isnull(sihe.V_1_DATE_2, '')
       ) AS V_OBIS_CODE_VALUE_1,

EDIT: mysql version

concat(ifnull(concat(`sihe`.`fld_1_int`, '~'), ''),
            ifnull(concat(`sihe`.`fld_1_double`, '~'), ''),
            ifnull(concat(`sihe`.`fld_1_date_time_1`, '~'),
                    ''),
            ifnull(`sihe`.`fld_1_date_time_2`, '')) AS `fld_obis_code_value_1`,

You can pass only two Arguments in Oracle CONCAT function hence you are getting this error and isnull is also not supported in oracle

Try the simple example below in oracle,Since oracle internally changes empty string to Nulls you can ignore the null check

sihe.v_1_int||'~'||v_1_double||'~'||v_1_date_1||'~'||v_1_date_2 
AS V_OBIS_CODE_VALUE_1

EDIT1:-

By using COALESCE instead of IFNULL and using CONCAT with only two arguments we can use the below code in MYSQL and ORACLE link for testing

select concat(concat(concat(concat(concat(concat('string1','~'),
       COALESCE(null,'string2')),'~'),'string3'),'~'),
       'string4') from dual; 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM