This is my query & I'm getting error divisor is equal to zero, I know i need to build this as a case statement just tried a few things and cant get it to work, thanks in advance.
NVL(ROUND(((SELECT PC.BUCKET_ACCUM_COST
FROM PART_CB PC WHERE
PART_CB_NO = '201'
AND PC.PART_NO = I.PART_NO
AND
PC.CONTRACT = P.CONTRACT
AND
PC.TOP_LEVEL_PART_NO || '' =
Z_BEL_FINANCE_API.GET_PART_COST_TOP_PART_NO(P.CONTRACT, P.PART_NO,
P.COST_SET, P.ALTERNATIVE_NO,
P.ROUTING_ALTERNATIVE_NO)
AND
PC.COST_SET = P.COST_SET
AND
PC.COST_BUCKET_ID != 'SYS'
AND
PC.TOP_ALTERNATIVE_NO =
Z_BEL_FINANCE_API.GET_PART_COST_TOP_ALT_NO(P.CONTRACT, P.PART_NO,
P.COST_SET, P.ALTERNATIVE_NO,
P.ROUTING_ALTERNATIVE_NO)
AND
PC.TOP_ROUTING_NO =
Z_BEL_FINANCE_API.GET_PART_COST_TOP_ROUTING_NO(P.CONTRACT, P.PART_NO,
P.COST_SET, P.ALTERNATIVE_NO,
P.ROUTING_ALTERNATIVE_NO)
AND
PC.BUCKET_SEQ = Z_BEL_FINANCE_API.GET_PART_COST_BUCKET_SEQ(P.CONTRACT,
P.PART_NO, P.COST_SET, P.ALTERNATIVE_NO,
P.ROUTING_ALTERNATIVE_NO)) /
(SELECT WC_RATE
FROM WCT
WHERE WORK_CENTER_NO = 'COST1'
AND COST_SET = '1'
AND CONTRACT = P.CONTRACT)), 4), 0) MACHINE_SETUP_TIME,
The only dividing in this mess is here:
/ (SELECT WC_RATE FROM WCT ...)
If you don't want to divide with zero, you'll have to handle it.
For example, use DECODE (or CASE) and - if you want to get 0 as the result, divide with a very large number (e.g. 1E99)
Related
Can some help me the best way convert the below Oracle code to Postgres
MERGE INTO INCLUSION_EXCLUSION_ALL A
USING (SELECT DISTINCT IEALL.rowid rid, IE.BLACKOUT_DURATION, ie.BLACKOUT_CATEGORY
FROM INCLUSION_EXCLUSION_ALL IEALL, INCLUSION_EXCLUSION_RULES IE
WHERE IE.PRI_PROMOTION_ID = IEALL.PRI_PROMOTION_ID
AND IE.PRI_OFFER_ID = IEALL.PRI_OFFER_ID
AND IE.SEC_PROMOTION_ID = IEALL.SEC_PROMOTION_ID
AND IE.SEC_OFFER_ID = IEALL.SEC_OFFER_ID
AND IE.BLACKOUT_DURATION > 0
AND (IEALL.BLACKOUT_DURATION <> IE.BLACKOUT_DURATION OR IEALL.BLACKOUT_CATEGORY <> IE.BLACKOUT_CATEGORY)
--AND IE.INCL_EXCL_IND <> 'I'
AND IE.SECONDARY_TYPE = 'B') B
ON (A.rowid = B.rid)
WHEN MATCHED THEN UPDATE SET A.BLACKOUT_DURATION = B.BLACKOUT_DURATION, A.BLACKOUT_CATEGORY = B.BLACKOUT_CATEGORY;
Thank You,
I want to know different ways on how we can do it as the rowid's are involved in here and are not compatible with Postgres esp in Joining using Alias even by using CTID,
Please advise
For the main.py of the px2graph project, the part of training and validation is shown as below:
splits = [s for s in ['train', 'valid'] if opt.iters[s] > 0]
start_round = opt.last_round - opt.num_rounds
# Main training loop
for round_idx in range(start_round, opt.last_round):
for split in splits:
print("Round %d: %s" % (round_idx, split))
loader.start_epoch(sess, split, train_flag, opt.iters[split] * opt.batchsize)
flag_val = split == 'train'
for step in tqdm(range(opt.iters[split]), ascii=True):
global_step = step + round_idx * opt.iters[split]
to_run = [sample_idx, summaries[split], loss, accuracy]
if split == 'train': to_run += [optim]
# Do image summaries at the end of each round
do_image_summary = step == opt.iters[split] - 1
if do_image_summary: to_run[1] = image_summaries[split]
# Start with lower learning rate to prevent early divergence
t = 1/(1+np.exp(-(global_step-5000)/1000))
lr_start = opt.learning_rate / 15
lr_end = opt.learning_rate
tmp_lr = (1-t) * lr_start + t * lr_end
# Run computation graph
result = sess.run(to_run, feed_dict={train_flag:flag_val, lr:tmp_lr})
out_loss = result[2]
out_accuracy = result[3]
if sum(out_loss) > 1e5:
print("Loss diverging...exiting before code freezes due to NaN values.")
print("If this continues you may need to try a lower learning rate, a")
print("different optimizer, or a larger batch size.")
return
time_str = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print("{}: step {}, loss {:g}, acc {:g}".format(time_str, global_step, out_loss, out_accuracy))
# Log data
if split == 'valid' or (split == 'train' and step % 20 == 0) or do_image_summary:
writer.add_summary(result[1], global_step)
writer.flush()
# Save training snapshot
saver.save(sess, 'exp/' + opt.exp_id + '/snapshot')
with open('exp/' + opt.exp_id + '/last_round', 'w') as f:
f.write('%d\n' % round_idx)
It seems that the author only get the result of each batch of the validation set. I am wondering, if I want to observe whether the model is improving or reaching the best performance, should I use the result on the whole validation set?
If the validation set is small enough, we could calculate the loss, accuracy on the whole validation set during training to observe the performance. However, if the validation set is too large, it is better to calculate batch-wise validation results and for multiple steps.
I'm using Informatica with Oracle RDBMS. Lately I've been struggling a bit.
I got an assignment to query the dependencies between each Model/Workflow , so the desired result will look something like this:
GRAND_MODEL | GRAND_WORKFLOW | WAIT_4_MODEL | WAIT_4_WORKFLOW
DWH_Model1 WF_workflow1 DWH_Model3 WF_Workflow3_1
DWH_Model1 WF_workflow1 DWH_Model4 WF_Workflow4_1
DWH_Model2 WF_workflow2_1 DWH_Model1 WF_Workflow1
Which means, WF_workflow1 in model DWH_Model1 waits for workflow WF_Workflow3_1 in model DWH_Model3 ETC....
We have 3 types of workflows , DELTA (will contains the word DELTA) DWH (same here) and CALC(same here). A workflow that waits uses an EVENT that will contain both of the models names, and a workflow that flags contain a CMD that contain the grand_model name.
So far We've come up with this:
SELECT DISTINCT OA.SUBJ_NAME AS GRAND_MODEL,
OL.SUBJ_NAME AS WAIT_4_MODEL_NAME,
REP.WORKFLOW_NAME AS WAIT_4_WORKFLOW_NAME,
A.FLAG_NAME,
CASE
WHEN INSTR(UPPER(A.FLAG_NAME), 'DWH') > 0 THEN
'DWH'
WHEN INSTR(UPPER(REP.WORKFLOW_NAME), 'DELTA') > 0 THEN
'DELTA'
ELSE
'CALC'
END CONNECTION_NAME
FROM OPB_SUBJECT#TO_INFORMATICA_ADMIN OL,
OPB_SUBJECT#TO_INFORMATICA_ADMIN OA,
OPB_TASK#TO_INFORMATICA_ADMIN T,
OPB_TASK#TO_INFORMATICA_ADMIN TL,
OPB_TASK_INST#TO_INFORMATICA_ADMIN TI,
REP_SESSION_INSTANCES#TO_INFORMATICA_ADMIN REP,
(SELECT T.TASK_ID,
SUBSTR(T.ATTR_VALUE,
LENGTH(T.ATTR_VALUE) + 2 -
INSTR(REVERSE(T.ATTR_VALUE), '/')) FLAG_NAME
FROM OPB_TASK_ATTR#TO_INFORMATICA_ADMIN T
WHERE T.TASK_TYPE = 60
AND INSTR(REVERSE(T.ATTR_VALUE), '/') > 0) A,
(SELECT T.TASK_ID,
T.SUBJECT_ID,
SUBSTR(T.PM_VALUE,
LENGTH(T.PM_VALUE) + 2 -
INSTR(REVERSE(T.PM_VALUE), '/')) FLAG_NAME
FROM OPB_TASK_VAL_LIST#TO_INFORMATICA_ADMIN T
WHERE INSTR(REVERSE(T.PM_VALUE), '/') > 0) L
WHERE OL.SUBJ_ID = L.SUBJECT_ID
AND A.TASK_ID = T.TASK_ID
AND T.SUBJECT_ID = OA.SUBJ_ID
AND A.FLAG_NAME = L.FLAG_NAME
AND OL.SUBJ_NAME <> OA.SUBJ_NAME
AND L.TASK_ID = TL.TASK_ID
AND TL.TASK_ID = TI.TASK_ID
AND TI.WORKFLOW_ID = REP.WORKFLOW_ID
This query works! The problem is, I'm getting worklets as workflows as well, so some of the times the last joins fails. I don't know how to avoid it..
if volt.isalpha() or res.isalpha() or amp.isalpha():
What did I do wrong here? I get an INVALID SYNTAX, I am using this for a calculator program I am making. It calculates voltage, resistance, and amperage. But thats the easy part, I am just trying to make it fool proof. I have 3 variables in the code (volt, amp, res) that are inputted by the user. I just wanna make sure that they don't type in anything stupid. Like letters for e.g. ...
try:
float(volt) >= 0 and float(res) >= 0 and float(amp) >= 0
print("")
print("You put a value for everything. You don't need the calculator.")
allowed = 0
if volt.isalpha() or res.isalpha() or amp.isalpha():
print("You typed in characters for one of the values, this calculator doesn't use letters.")
allowed = 0
def find_voltage(a,b): # V = I * R
voltage = a * b
return(voltage)`
You don't have an except block after try - it is required. Do something like:
try:
float(volt) >= 0 and float(res) >= 0 and float(amp) >= 0
print("")
print("You put a value for everything. You don't need the calculator.")
allowed = 0
except ValueError:
print("Oops, you messed up.")
Additionally, the line
float(volt) >= 0 and float(res) >= 0 and float(amp) >= 0
doesn't do anything. You'll need to assign it to a variable, then check the results of the variable - if True, do one thing, if False, do something else.
so I am very new to coding in general and I am trying to make a vertically-scrolling endless runner which basically involves jumping onto platforms to stay alive.I want to generate the same platform in three different locations endlessly. I basically copied some code from an article on the internet and then changed it around to try to make it suit my needs. However, when I run my code in the simulator, one platform is generated in the same location and no others appear. Also, when I look at the console, random numbers do appear. here is the code I am using
local blocks = display.newGroup ()
local groundMin = 200
local groundMax = 100
local groundLevel = groundMin
local function blockgenerate( event )
for a = 1, 1, -1 do
isDone = false
numGen = math.random(3)
local newBlock
print (numGen)
if (numGen == 1 and isDone == false) then
newBlock = display.newImage ("platform.jpg")
end
if (numGen == 2 and isDone == false) then
newBlock = display.newImage ("platform.jpg")
end
if (numGen == 3 and isDone == false) then
newBlock = display.newImage ("platform.jpg")
end
newBlock.name = ("block" .. a)
newBlock.id = a
newBlock.x = (a * 100) - 100
newBlock.y = groundLevel
blocks : insert(newBlock)
end
end
timer.performWithDelay (1000, blockgenerate, -1)
thank you very much in advance and sorry my description was so long
Your "a" variable is always going to be 1. Perhaps you meant to use:
a = a + 1