简体   繁体   中英

SQL IF ELSE Statement?

In Oracle apex I am using a custom authentication system. Whereby it gets the username and passwords from a users table, Currently when logged in as a normal user you can only view your own records and edit them for security reasons. with this as example of the SQL,

select 
"RECORD_NUMBER",
"STUDENT_FIRST_NAME",
"STUDENT_SURNAME",
"USERNAME"
"PASSWORD"
from   "USERS"
where upper(USERNAME) = upper(v('APP_USER'))

However one of the Users is called admin in the table, how can I make it if I'm logged in with the user admin I can view everyone's records in the table, never really delved this deep before so could do with some help.

I've never used apex, so I hope your sql is somehow using bind variables, but here is the general idea:

select 
"RECORD_NUMBER",
"STUDENT_FIRST_NAME",
"STUDENT_SURNAME",
"USERNAME"
"PASSWORD"
from   "USERS"
where upper(USERNAME) = upper(v('APP_USER'))
or upper(v('APP_USER')) = 'ADMIN'

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