在HADR待机状态下无法执行子选择或联合操作

时间:2013-04-13 13:29:39

标签: db2 union subquery standby

尝试使用带有union运算符或子选择的RoS(只读待机)在HADR数据库中执行某些查询,我收到错误SQL1773N原因码5。

是什么原因?它们是不产生写入的操作。

联盟

with hist(start_time, operationtype) as (
 select start_time, operationtype
 from sysibmadm.db_history
 where operation = 'B' )
select 'delta', timestampdiff(8, current timestamp - char(timestamp(max(start_time))))
from hist
where operationtype = 'D' or operationtype = 'E'
union all
select 'delta', timestampdiff(8, current timestamp - char(timestamp(max(start_time))))
from hist
where operationtype = 'I' or operationtype = 'O'

子选择

with hist(start_time, operationtype) as (
 select start_time, operationtype
 from sysibmadm.db_history
 where operation = 'B' )
select 'delta', operationtype, start_time, timestampdiff(8, current timestamp - char(timestamp(start_time)))
from hist
where start_time = (
 select max(start_time)
 from hist
 where operationtype = 'D' or operationtype = 'E')

1 个答案:

答案 0 :(得分:2)

这似乎是newBalance特有的问题 在启用了ROS的待机状态下尝试了以下//calculates balance public float calculateBalance() { balance = previousBalance + currentPurchases - payments - creditsReturns + lateFees+ 5; return balance; } //sets finance charge public void setFinanceCharge(float financeCharge) { double periodicRate; periodicRate = .12/12; float d = (float)periodicRate; financeCharge = balance * d; } //gets finance charge public float getFinanceCharge() { return financeCharge; } //Method to calculate new balance public float calculateNewBalance() { //calculate the new balance newBalance = balance+financeCharge+5; return newBalance; } //setes new payment due public void setpaymentDue(double newPayment) { newPayment = newBalance * .10; this.paymentDue = (float)newPayment; } //gets new payment due public float getpaymentDue() { return paymentDue; } //method to display results public void displayOutput() { if (overCreditLimit == 0) { JOptionPane.showMessageDialog(null, "The Customer number is: " + customerNumber + "\n" + "The Customer name is: " + customerName + "\n" + "The Credit Limit is: " + creditLimit + "\n" + "The Previous Balance is: " + previousBalance + "\n" + "The Current Purchases is: " + currentPurchases + "\n" + "The Payments is: " + payments + "\n" + "The Credits/Returns is: " + creditsReturns + "\n" + "The Late Fees is: " + lateFees + "\n" + "The Finance Charge is: " + financeCharge + "\n" + "The New Balance is: " + newBalance + "\n" + "The New Payment Due is: " + paymentDue + "\n"); } else { overCreditAmount = newBalance - creditLimit - 25; JOptionPane.showMessageDialog(null, "You are " + overCreditAmount + " dollars over your credit limit," + " a $25 fee has been charged to your new balance"); JOptionPane.showMessageDialog(null, "The Customer number is: " + customerNumber + "\n" + "The Customer name is: " + customerName + "\n" + "The Credit Limit is: " + creditLimit + "\n" + "The Previous Balance is: " + previousBalance + "\n" + "The Current Purchases is: " + currentPurchases + "\n" + "The Payments is: " + payments + "\n" + "The Credits/Returns is: " + creditsReturns + "\n" + "The Late Fees is: " + lateFees + "\n" + "The Finance Charge is: " + financeCharge + "\n" + "The Amount over Credit Limit is: " + overCreditAmount + "\n" + "The New Balance is: " + newBalance + "\n" + "The New Payment Due is: " + paymentDue + "\n"); } } sysibmadm.db_history,两者都运行良好

union all