Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

oracle jet ajax problem

User_XU6OZMay 1 2022

Hey all I am new to Oracle JET and I have a problem
we try to upgrade our app to version 12 and some of the code that works now does not function well
I try to do login into the app with ajax like before the upgrade and for some reason, I can't understand it not working and I don't get an output\error code that I can try to understand the problem.
this is the code the problem happen :
await $.ajax({
url: self.rootModel.usersLoginRestURL(),
data: {
username: self.username(),
password: self.password()
},
type: 'POST',
xhrFields: {
withCredentials: true
},
error: function (request, status, error) {
console.log(`Login Failed.`)
},
statusCode: {
403: function(response) {
console.log(`Access Error: (Forbidden) Attempted access to forbidden resource.`);
alert(`Incorrect username or password when attempting login.`)
},
401: function(response) {
console.log(`Access Error: (Unauthorized) Incorrect username or password when attempting login.`)
alert(`Incorrect username or password when attempting login.`)
},
},
success: (function (results){
const delay = Math.max(100, parseInt(results.accessTokenExpiryMillis) - 5000);
setTimeout(self.rootModel.refreshTokens, delay);
self.rootModel.accessToken(results.accessToken);
self.loginResponse(results)
console.log(results);
}),
});

hope you can help.

Comments

Frank Kulash
Hi,

Assuming the columns bb, cl and la are never NULL:
SELECT	customer_key
,	GREATEST ( bb
		 , cl
		 , la
		 )	AS spend
FROM	TABLE_X
;
Assuming the numbers can be NULL, is there a lower bound to their possible values (such as 0)?
If so, use NVL to map NULLs to an impossibly low value, e.g. NVL (bb, -1). You may want to use NULLIF to map that back to NULL in the event that all 3 columns are NULL.
If not, unpivot the 3 columns in to one column and use the aggregate MAX function.
Kodiak_Seattle
Cooool, let me try that out, thanks!
Kodiak_Seattle
Ok, this worked, I guess I need one more thing, I need an additional field that will tell me which column the Greatest Spend Came from, like BB, or CL, or LA ?

How would something like that be done ?
Frank Kulash
Answer
Hi,

Use a CASE expression.
Assuming the numbers are distinct and not NULL:
SELECT	customer_key
,	GREATEST ( bb
		 , cl
		 , la
		 )	AS spend
,	CASE
		WHEN  bb >= GREATEST (cl, la)	THEN  'BB'
		WHEN  cl >= la	     	  	THEN  'CL'
		      	    			ELSE  'LA'
	END		AS column_name
FROM	table_x
;
Marked as Answer by Kodiak_Seattle · Sep 27 2020
Kodiak_Seattle
Thank you for your time!
Aketi Jyuuzou
I like simple case expression :D
SELECT customer_key,GREATEST(bb,cl,la) AS spend
CASE GREATEST(bb,cl,la)
when bb then 'BB'
when cl then 'CL'
when la then 'LA' END AS column_name
FROM    table_x;
1 - 6

Post Details

Added on May 1 2022
1 comment
230 views