oracle.jdbc.OracleDatabaseException: ORA-01722: invalid number - oracle19c

Getting the above error but the offending column is not a number. Somehow it is related to the cycle_code column which is a string. My query is hacky since I dont have full control over building it so I have to append another condition at the end ( "!= 'ABC'"). If I remove that condition the query works. I dont understand why im getting an invalid number error though?
select * from my_view WHERE ... CYCLE_CODE IN ( 'XYZ' ) AND CYCLE_CODE != 'ABC';

Related

Pine Script V5 getting syntax error when checking boolean value with 'If' statement

Trying to detect 3 specific EMA crosses, assign them to boolean variable, plot them and set alerts when their conditions are true.
No problem detecting and plotting the 3 crosses when they occur but when I try to set alerts using 'If' statement to check boolean value = true, I get a syntax error at the if statement.
Error is :
Syntax error at input 'end of line without line continuation'
I've tried a thousand different ways to get rid of the syntax error. How am I so stumped on a simple syntax error? Lol I need a fresh set of eyes to look at this for me. Maybe its obvious?
Code:
Continuationema = ta.crossover(ema2_, ema8_)
plotshape(Continuationema, style=shape.triangleup, color=color.new(color.blue, 0), location=location.abovebar)
Bearema = ta.crossunder(ema1_, ema2_)
plotshape(Bearema, style=shape.triangledown, color=color.new(color.red, 0), location=location.abovebar)
Bullema = ta.crossover(ema2_, ema3_)
plotshape(Bullema, style=shape.triangleup, color=color.new(color.green, 0), location=location.belowbar)
// Set Alerts
If Continuationema
strategy.entry("Continuation",strategy.long,alert_message="Uptrend Detected")
alert("Uptrend Continuation Detected. EMA2 Crossing Over EMA8")
*** Syntax error at input 'end of line without line continuation'*** appears at the above 'If' statement
It is you IF statement wich is not well written, you should not use Capital ( If ) but :
if Continuationema == true

Regex validation on Account Address field

We sync our Salesforce accounts and opportunities to QuickBooks (QB), but QB has character limits on its fields. Street lines have a 41 character limit per line and I'm trying to have regex control and limit this, but it isn't working on the Address field type. I am using the very simple conditional formula:
REGEX(BillingStreet, '.{42,}')
which matches any non-linebreak character and if it's 42 characters or more, trigger the validation. The problem is that it ignores this rule. I know this formula works because if I apply it to another text field, it works how it's supposed to. Here's an example of how it should work: https://www.regexpal.com/99217. If there's a match anywhere, it should throw the validation error.
Any ideas?
I ended up not using Regex because it doesn't seem to work well. Instead I used formulas to make sure it follows the validation. Since we have a limit of two lines, it wasn't too bad to do this the long way.
AND(
IF(
//Look for a line break. If there is one, split and compare lengths separately.
FIND(MID( $Setup.Global__c.CLRF__c ,3,1), BillingStreet ) > 0
,
IF(
//If the first line is over the limit, return true to trigger validation.
LEN(LEFT(BillingStreet, FIND(MID( $Setup.Global__c.CLRF__c ,3,1), BillingStreet )-2))>41
,
TRUE
,
//If first line is fine, check second line and since this is a condition, it will return true/false automatically.
LEN(MID(BillingStreet, FIND(MID( $Setup.Global__c.CLRF__c ,3,1), BillingStreet )+1,LEN(BillingStreet))) > 41
)
,
//If there is no line break (one line) check the total length.
LEN(BillingStreet) > 41
)
,
//There is a validation for having more than 2 lines. Without this, it will combine lines 2 and above and check that length and will be confusing to users when it's > 41.
NOT(REGEX( BillingStreet , '(.*\r?\n.*){2,}'))
,
//Ignore this rule if the user has this flag active. Useful for bulk updating and don't have to worry about import errors.
$User.Bypass_Validation__c = False
)
This piece MID( $Setup.Global__c.CLRF__c ,3,1) represents a line break in Salesforce. Found out how it works from find line break in formula field. I would have liked to use Regex, but it just doesn't work if you ask me. Except for checking 2+ lines like in the above code.

IF Formula returning error or not doing a section of the formula

I have a formula in my report to select a field based on requirements:
if not isnull({EXT_TBL.EXT_KEY_TYPE}) then
(if {EXT_TBL.EXT_KEY_TYPE} = "SO" and {EXT_TBL.EXT_ACTION_FLAG_9} = "Y"
then {EXT_TBL.EXT_TEXT})
else '0'
When I run the report it works ok until I try to load a specific page. When I try to load the page I get an error of 'The string is non numeric'. The formula is called in another formula:
{COR_TBL.COR_EXPECTED_DATE} + 2 + ToNumber({#FRM_NOTES})
I have ran the query on the server of:
SELECT * FROM EXT_TBL WHERE EXT_KEY_TYPE = "SO" AND EXT_ACTION_FLAG_9 = "Y";
This returned me two rows of data. I have narrowed it down to a specific entry that is causing the issue, but in the database the row has N in the field action flag 9 instead of Y so it shouldn't be throwing me the error in my report.
The action field 9 is flagged on only two records both of which contain a 7 in the EXT_TEXT feild so I have no idea why I am getting the error.
I also tried a nested if statement of:
if not isnull({EXT_TBL.EXT_KEY_TYPE}) then
(if {EXT_TBL.EXT_KEY_TYPE} = "SO" then (if {EXT_TBL.EXT_ACTION_FLAG_9} = "Y"
then {EXT_TBL.EXT_TEXT}))
else '0'
But it still gave me the same error.
Thanks
I was able to fix the issue by removing the nested if statement and just putting all the conditions in the original statement:
if not isnull({EXT_TBL.EXT_KEY_TYPE}) AND {EXT_TBL.EXT_KEY_TYPE} = "SO"
AND {EXT_TBL.EXT_ACTION_FLAG_9} = "Y"
THEN {EXT_TBL.EXT_TXT} ELSE '0'
This seems to have fixed the issue.

TypeError during executemany() INSERT statement using a list of strings

I am trying to just do a basic INSERT operation to a PostgreSQL database through Python via the Psycopg2 module. I have read a great many of the questions already posted regarding this subject as well as the documentation but I seem to have done something uniquely wrong and none of the fixes seem to work for my code.
#API CALL + JSON decoding here
x = 0
for item in ulist:
idValue = list['members'][x]['name']
activeUsers.append(str(idValue))
x += 1
dbShell.executemany("""INSERT INTO slickusers (username) VALUES (%s)""", activeUsers
)
The loop creates a list of strings that looks like this when printed:
['b2ong', 'dune', 'drble', 'drars', 'feman', 'got', 'urbo']
I am just trying to have the code INSERT these strings as 1 row each into the table.
The error specified when running is:
TypeError: not all arguments converted during string formatting
I tried changing the INSERT to:
dbShell.executemany("INSERT INTO slackusers (username) VALUES (%s)", (activeUsers,) )
But that seems like it's merely treating the entire list as a single string as it yields:
psycopg2.DataError: value too long for type character varying(30)
What am I missing?
First in the code you pasted:
x = 0
for item in ulist:
idValue = list['members'][x]['name']
activeUsers.append(str(idValue))
x += 1
Is not the right way to accomplish what you are trying to do.
first list is a reserved word in python and you shouldn't use it as a variable name. I am assuming you meant ulist.
if you really need access to the index of an item in python you can use enumerate:
for x, item in enumerate(ulist):
but, the best way to do what you are trying to do is something like
for item in ulist: # or list['members'] Your example is kinda broken here
activeUsers.append(str(item['name']))
Your first try was:
['b2ong', 'dune', 'drble', 'drars', 'feman', 'got', 'urbo']
Your second attempt was:
(['b2ong', 'dune', 'drble', 'drars', 'feman', 'got', 'urbo'], )
What I think you want is:
[['b2ong'], ['dune'], ['drble'], ['drars'], ['feman'], ['got'], ['urbo']]
You could get this many ways:
dbShell.executemany("INSERT INTO slackusers (username) VALUES (%s)", [ [a] for a in activeUsers] )
or event better:
for item in ulist: # or list['members'] Your example is kinda broken here
activeUsers.append([str(item['name'])])
dbShell.executemany("""INSERT INTO slickusers (username) VALUES (%s)""", activeUsers)

Print value from a lua table if pattern matches

Okay, so I just recently got into lua and find myself stuck with the following:
I have the function peripheral.getNames() (which is a custom function)
it will return a table with the structure key,value, whereas key is always a number and starts from 1 and value will be what the function finds (it searches for devices connected to it)
In my example it creates a table which looks like this
1 herp
2 derp
3 monitor_1
4 morederp
I can print the values with the following
local pgn = peripherals.getNames()
for key,value in pairs(pgn) do
setCursorPos(1,key)
write(value)
end
end
this will output the corresponding value of the table at key on my display like this
herp
derp
monitor_1
morederp
now, I try to filter my results so it only prints something if value contains 'monitor'
I tried to achive this with
for key,value in pairs(pgn) do
if string.match(value, monitor) then
#dostuff
end
end
but it always returns 'bad argument: string expected, got nil'
so obviously string.match either does not accept 'value' or, value is not a string
so i tried converting value first
for key,value in pairs(pgn) do
value = tostring(value)
if ....
#dostuff
end
end
but it still throws the same error
Do any of you have an idea how i might either get string.match to accept 'value' or if there is another method to check the contents of 'value' for a pattern while in this for loop?
The error message is talking about the variable monitor, which is not defined and so has a nil value.
Try string.match(value, "monitor").