BLOB数据是一个XML片段,目前在数据库中看起来像这样
import numpy as np
import types
from timeit import repeat
prom={np.dtype(np.int32): np.dtype(np.int64), np.dtype(float): np.dtype(float)}
def RI(k, N, dt, top=100):
return np.random.randint(0, top if top else N, (k, N)).astype(dt)
def RA(k, N, dt, top=None):
return np.add.outer(np.zeros((k,), int), np.arange(N)%(top if top else N)).astype(dt)
def RU(k, N, dt, top=100):
return (np.random.random((k, N))*(top if top else N)).astype(dt)
def data(k, N_b, N_e, dt_b, dt_e, b_fun=RI, e_fun=RA):
b = list(b_fun(k, N_b, dt_b))
e = list(e_fun(k, N_e, dt_e))
return b, e
def f_vander(b, e):
return np.vander(b, len(e), increasing=True)
def f_bc_b(b, e):
return b[:, None]**e
def f_bc_e(b, e):
return np.ascontiguousarray((b**e[:, None]).T)
def f_ma(b, e):
out = np.empty((len(b), len(e)), prom[b.dtype])
out[:, 0] = 1
np.multiply.accumulate(np.broadcast_to(b, (len(e)-1, len(b))), axis=0, out=out[:, 1:].T)
return out
def f_nnc(b, e):
out = np.empty((len(b), len(e)), prom[b.dtype])
out[:, 0] = 1
out[:, 1:] = b[:, None]
np.multiply.accumulate(out[:, 1:], out=out[:, 1:], axis=1)
return out
def f_out_e_1(b, e):
out = np.empty((len(b), len(e)), b.dtype)
out[:, 0] = 1
out[:, 1] = b
out[:, 2] = c = b*b
for i in range(3, len(e)):
c*=b
out[:, i] = c
return out
def f_out_e_2(b, e):
out = np.empty((len(b), len(e)), b.dtype)
out[:, 0] = 1
out[:, 1] = b
out[:, 2] = b*b
for i in range(3, len(e)):
out[:, i] = out[:, i-1] * b
return out
def f_safe_e_1(b, e):
out = np.empty((len(b), len(e)), prom[b.dtype])
out[:, 0] = 1
out[:, 1] = b
out[:, 2] = c = (b*b).astype(prom[b.dtype])
for i in range(3, len(e)):
c*=b
out[:, i] = c
return out
def f_safe_e_2(b, e):
out = np.empty((len(b), len(e)), prom[b.dtype])
out[:, 0] = 1
out[:, 1] = b
out[:, 2] = b*b
for i in range(3, len(e)):
out[:, i] = out[:, i-1] * b
return out
def f_bc_e_cheat(b, e):
return (b**e[:, None]).T
for params in [(100, 5000, 4, np.int32, np.int32),
(100, 5000, 8, np.int32, np.int32),
(100, 5000, 4, float, np.int32),
(100, 5000, 8, float, np.int32)]:
k = params[0]
dat = data(*params)
ref = f_vander(dat[0][0], dat[1][0])
print('rep={} n_b={} n_e={} b_tp={} e_tp={}'.format(*params))
for name, func in list(globals().items()):
if not name.startswith('f_') or not isinstance(func, types.FunctionType):
continue
try:
assert np.allclose(ref, func(dat[0][0], dat[1][0]))
if not func(dat[0][0], dat[1][0]).flags.c_contiguous:
print('cheat', end=' ')
print("{:16s}{:16.8f} ms".format(name[2:], np.min(repeat(
'f(b.pop(), e.pop())', setup='b, e = data(*p)', globals={'f':func, 'data':data, 'p':params}, number=k)) * 1000 / k))
except:
print("{:16s} apparently failed".format(name[2:]))
我需要通过删除年份来更新如下所示。
<lrs-conv end-page="34" runhead="LMI v BAULDERSTONE" series="NSWLR" start-page="31" version="1" volume="(2001) 53">
我有大约1000条BLOB数据记录需要同样更新。所以我认为UPDATE SQL脚本可能会有所帮助。
答案 0 :(得分:0)
我尝试了下面的脚本,但它只是让我只更新数据库中的一条记录,因为substr的参数不断更改数据库中的其他记录。我想更改SQL,以便它可以为所有记录更新BLOB XML中的卷。
Update FRAGMENT F
set F.FRAGMENT_DATA = REPLACE ((select DBMS_LOB.SUBSTR(FRAGMENT_DATA)
from
FRAGMENT where OBJECT_ID = '5037087'
and fragment_type_id = 77 and doctype_id = 29),
(select Dbms_lob.substr(FRAGMENT_DATA,7,106) from Fragment where
OBJECT_ID = '5037087'
and fragment_type_id = 77 and doctype_id = 29),
'')
where OBJECT_ID = '5037087'
and fragment_type_id = 77 and doctype_id = 29