0

I'm trying to execute the below statement on PostgreSQL 12.4. This statement was converted from Oracle 10g to PostgreSQL 12.4 using the online SQL Lines tool.

select
        hid,
        pname,
        starting_from,
        ename
    from schema1.pet
    where hid=COALESCE(TO_NUMBER(sys_context('temp1','hid')),0);

I'm getting the below error:

ERROR:  function sys_context(unknown, unknown) does not exist
LINE 7:  where hid=COALESCE(TO_NUMBER(sys_context('temp1','hid...

I'm not sure what's the equivalent of sys_context in PostgreSQL.

How can I fix this statement to PostgreSQL?

1
  • 3
    You should add a description of what sys_context does, then you could also reach those people who are not familiar with Oracle. Commented Nov 2, 2021 at 4:56

1 Answer 1

1

The PostgreSQL current_setting() function comes closest to the Oracle sys_context() function. PostgreSQL does not use the namespace parameter, however.

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

Comments

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.