我有一个使用Oracle的Django项目有一段时间我无法解决的问题。这是我在oracle数据库上的第一个工作,但我会尽力解释。我在工作中开发了一个工具,用户可以大规模更新记录(Just Update)。使用ajax显示和过滤数据。 还有一个由其他人创建的oracle过程,而不是向表中插入一些记录。 但通常该工具会停止工作,抛出以下内容:
DatabaseError: ORA--0001: Message -1 not found; product=RDBMS; facility=ORA
我尝试了一切,我在各处搜索了几个月,但没有运气。 首先,我看到序列nextval通过使用触发器和序列落后于最大ID,并且当过程插入确保唯一id的记录时更改了id以获取nextval但是在此之后最大ID和nextval都没问题但是错误仍然存在。我们看了关于插入过程中的约束违规,但我不认为这种情况导致主键 - 唯一ID正确递增,我们不会从oracle日志中获得错误。
我知道ora - 0001是一种独特的关键违规行为,我已经搜索并尝试了好几个月但我不知道哪个约束被违反了,因为我得到了#34;消息-1未找到& #34 ;.
错误记录来自应用程序日志记录系统我们还在oracle中创建了一个日志记录,但是没有任何内容出现在那里,并且在与DBA交谈之后说没有出现错误记录并且不知道发生了什么&# 39;它喜欢它不存在,但我仍然得到ORA - 0001。
唯一存在的约束是主键(ID),ID不是NULL:
SITES_HALTED_REASONS_PK Primary_Key ENABLED NOT DEFERRABLE VALIDATED USER NAME 12/06/17 DAS SITES_HALTED_REASONS_PK
SYS_C0011733 Check "ID" IS NOT NULL ENABLED NOT DEFERRABLE VALIDATED GENERATED NAME 24/05/17
我在这里已经死了几个月,我读到了关于唯一索引并使connstrains可以确定但我不太确定这是方法,我将解决问题。问题是我只搜索ajax和更新哪个是不合逻辑的获取唯一密钥违规。另外从日志记录系统我得到的错误是在ajax帖子上或在更新或类似的东西上发布空查询。以下是第一个错误日志的几个示例:
1. return Database.connect(conn_string, **conn_params)
DatabaseError: ORA--0001: Message -1 not found; product=RDBMS; facility=ORA
Request repr():
<WSGIRequest
path:/mass_update/reasons/sites/halted/,
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'__session:0.66375524560864:': 'http:',
'csrftoken': 'ThbibARdilkyc3g6izASpAHBen1mm4Yr'},
2.
Internal Server Error: /mass_update/reasons/sites/halted/
Traceback (most recent call last):
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/root/mass_update/mass_update/views.py", line 96, in sites_halted
return render(request, 'sites_halted.html', {'form': form} )
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/shortcuts.py", line 67, in render
template_name, context, request=request, using=using)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/loader.py", line 99, in render_to_string
return template.render(context, request)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/backends/django.py", line 74, in render
return self.template.render(context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/base.py", line 210, in render
return self._render(context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
return self.nodelist.render(context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/base.py", line 905, in render
bit = self.render_node(node, context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/loader_tags.py", line 135, in render
return compiled_parent._render(context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/test/utils.py", line 96, in instrumented_test_render
return self.nodelist.render(context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/base.py", line 905, in render
bit = self.render_node(node, context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/loader_tags.py", line 65, in render
result = block.nodelist.render(context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/base.py", line 905, in render
bit = self.render_node(node, context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/debug.py", line 79, in render_node
return node.render(context)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/defaulttags.py", line 217, in render
nodelist.append(node.render(context))
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/template/debug.py", line 92, in render
output = force_text(output)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/utils/encoding.py", line 92, in force_text
s = six.text_type(s)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/utils/html.py", line 390, in <lambda>
klass.__unicode__ = lambda self: mark_safe(klass_unicode(self))
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/forms/forms.py", line 537, in __str__
return self.as_widget()
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/widget_tweaks/templatetags/widget_tweaks.py", line 28, in as_widget
html = old_as_widget(widget, attrs, only_initial)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/forms/forms.py", line 593, in as_widget
return force_text(widget.render(name, self.value(), attrs=attrs))
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/forms/widgets.py", line 513, in render
options = self.render_options(choices, [value])
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/forms/widgets.py", line 539, in render_options
for option_value, option_label in chain(self.choices, choices):
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/forms/models.py", line 1107, in __iter__
for obj in queryset:
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/db/models/query.py", line 238, in iterator
results = compiler.execute_sql()
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 838, in execute_sql
cursor = self.connection.cursor()
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/db/backends/base/base.py", line 162, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/db/backends/base/base.py", line 135, in _cursor
self.ensure_connection()
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
self.connect()
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/db/backends/base/base.py", line 119, in connect
self.connection = self.get_new_connection(conn_params)
File "/root/.virtualenvs/dashboard/lib/python2.7/site-packages/django/db/backends/oracle/base.py", line 214, in get_new_connection
return Database.connect(conn_string, **conn_params)
DatabaseError: ORA--0001: Message -1 not found; product=RDBMS; facility=ORA
Request repr():
<WSGIRequest
path:/mass_update/reasons/sites/halted/,
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'__session:0.66375524560864:': 'http:',
'csrftoken': 'ThbibARdilkyc3g6izASpAHBen1mm4Yr'},
META:{'CONTEXT_DOCUMENT_ROOT': '/var/www/idash',
'CONTEXT_PREFIX': '',
u'CSRF_COOKIE': u'ThbibARdilkyc3g6izASpAHBen1mm4Yr',
u'CSRF_COOKIE_USED': True,
'DOCUMENT_ROOT': '/var/www/idash',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'HTTP_ACCEPT_ENCODING': 'gzip, deflate',
'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',
'HTTP_CACHE_CONTROL': 'max-age=0',
'HTTP_CONNECTION': 'keep-alive',
'HTTP_COOKIE': 'csrftoken=ThbibARdilkyc3g6izASpAHBen1mm4Yr; __session:0.66375524560864:=http:',
'HTTP_HOST': 'idash.victus.gr',
'HTTP_REFERER': 'http://idash.victus.gr/mass_update/reasons/sites/halted/',
'HTTP_UPGRADE_INSECURE_REQUESTS': '1',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36',
'PATH_INFO': u'/reasons/sites/halted/',
'PATH_TRANSLATED': 'redirect:/index.php/sites/halted/',
'QUERY_STRING': '',
'REMOTE_ADDR': '172.27.66.138',
'REMOTE_PORT': '61077',
'REQUEST_METHOD': 'GET',
'REQUEST_SCHEME': 'http',
'REQUEST_URI': '/mass_update/reasons/sites/halted/',
'SCRIPT_FILENAME': '/root/mass_update/dashboard/wsgi.py',
'SCRIPT_NAME': u'/mass_update',
'SERVER_ADDR': '172.31.128.20',
'SERVER_ADMIN': 'root@localhost',
'SERVER_NAME': 'idash.victus.gr',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '',
'SERVER_SOFTWARE': 'Apache/2.4.6 (CentOS) PHP/5.4.16 mod_wsgi/3.4 Python/2.7.5',
'UNIQUE_ID': 'WX@X3lek1z3wHZH8gb8pAAAAABA',
'mod_wsgi.application_group': 'idash.victus.gr|/mass_update',
'mod_wsgi.callable_object': 'application',
'mod_wsgi.enable_sendfile': '0',
'mod_wsgi.handler_script': '',
'mod_wsgi.input_chunked': '0',
'mod_wsgi.listener_host': '',
'mod_wsgi.listener_port': '80',
'mod_wsgi.process_group': 'mass_update',
'mod_wsgi.queue_start': '1501534174566045',
'mod_wsgi.request_handler': 'wsgi-script',
'mod_wsgi.script_reloading': '1',
'mod_wsgi.version': (3, 4),
'wsgi.errors': <mod_wsgi.Log object at 0x7fc3e830fdf0>,
'wsgi.file_wrapper': <built-in method file_wrapper of mod_wsgi.Adapter object at 0x7fc3e83187b0>,
'wsgi.input': <mod_wsgi.Input object at 0x7fc3e830fdb0>,
'wsgi.multiprocess': False,
'wsgi.multithread': True,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)}>
views.py
@login_required
def sites_halted(request):
#view for halted sites
if request.method == 'POST':
form = ReasonAndCategoryForm(request.POST)
id_list = request.POST.getlist('checkbox')
d = {}
print id_list
info = request.POST['info']
username = request.POST['username']
tt = request.POST['tt']
actions = request.POST['actions']
comments = request.POST['comments']
#idd = request.POST.get('checkbox')
#print idd
if form.is_valid():
if form.cleaned_data['reason']:
reason = str(form.cleaned_data['reason'])
d['reason'] = reason
if form.cleaned_data['category']:
category = str(form.cleaned_data['category'])
d['category'] = category
if info:
d['info'] = info
if username:
d['username'] = username
if tt:
d['tt'] = tt
if actions:
d['actions'] = actions
if comments:
d['comments'] = comments
try:
SitesHaltedReasons.objects.filter(id__in=id_list).update(**d)
except Exception as e:
#print "Unexpected error:", sys.exc_info()[1]
# print str(e)
logger.error(e.message)
# raise
else:
form = ReasonAndCategoryForm()
#sites = SitesHaltedReasons.objects.all()[:30]
return render(request, 'sites_halted.html', {'form': form, 'name': request.user.username} )
def sites_down_ajax(request):
sites = SitesDownReasons.objects.all()[:40]
isnull_sitename=True
isnull_sitenumber=True
isnull_info=True
isnull_reason=True
isnull_category=True
isnull_tt=True
isnull_username=True
isnull_spares=True
isnull_pending=True
isnull_actions=True
isnull_comments=True
isnull_lastupdate=True
isnull_opco=True
isnull_gsm=True
isnull_umts=True
isnull_lte=True
isnull_region=True
isnull_county=True
isnull_totalaffected = True
isnull_oosend = False
if request.method == 'POST':
sitename = request.POST['sitename']
sitenumber = request.POST['sitenumber']
page = request.POST['page_number']
region = request.POST['region']
info = request.POST['info']
oostart = request.POST['oostart']
oosend = request.POST['oosend']
reason = request.POST['reason']
category = request.POST['category']
tt = request.POST['tt']
username = request.POST['username']
spares = request.POST['spares']
pending = request.POST['pending']
actions = request.POST['actions']
comments = request.POST['comments']
lastupdate = request.POST['lastupdate']
opco = request.POST['opco']
gsm = request.POST['gsm']
umts = request.POST['umts']
lte = request.POST['lte']
region = request.POST['region']
county = request.POST['county']
totalaffected = request.POST['totalaffected']
null_reasons = request.POST['chk_reason']
null_oosend = request.POST['chk_oosend']
isnull_sitename = True if sitename == '' else False
isnull_sitenumber = True if sitenumber == '' else False
isnull_reason = True if reason == '' else False
isnull_category = True if category == '' else False
isnull_info = True if info == '' else False
isnull_tt = True if tt == '' else False
isnull_username = True if username == '' else False
isnull_spares = True if spares == '' else False
isnull_pending = True if pending == '' else False
isnull_actions = True if actions == '' else False
isnull_comments = True if comments == '' else False
isnull_lastupdate = True if lastupdate == '' else False
isnull_opco = True if opco == '' else False
isnull_gsm = True if gsm == '' else False
isnull_umts = True if umts == '' else False
isnull_lte = True if lte == '' else False
isnull_region = True if region == '' else False
isnull_county = True if county == '' else False
isnull_totalaffected = True if totalaffected == '' else False
else:
sitenumber = ''
if sitename == '' and sitenumber == '' and region == '' and reason == '' and category == '' and info == '' and username == '' and \
tt == '' and spares == '' and pending == '' and actions == '' and comments == '' and opco == '' and gsm == '' and umts == '' and \
lte == '' and region == '' and county == '' and totalaffected == '' and oostart == '' and oosend == '' and not null_reasons and not null_oosend:
sites = SitesDownReasons.objects.all().order_by('-oostart')
else:
print null_reasons
if null_reasons:
isnull_reason = True
reason = "##"
if null_oosend:
isnull_oosend = True
try:
sites = SitesDownReasons.objects.filter( ((Q(info__isnull=True) | Q(info__icontains=info))) & (Q(info__isnull=isnull_info) | Q(info__icontains=info)), \
((Q(reason__isnull=True) | Q(reason__icontains=reason))) & (Q(reason__isnull=isnull_reason) | Q(reason__icontains=reason)),
((Q(category__isnull=True) | Q(category__icontains=category))) & (Q(category__isnull=isnull_category) | Q(reason__icontains=category)),
((Q(username__isnull=True) | Q(username__icontains=username))) & (Q(username__isnull=isnull_username) | Q(username__icontains=username)),
((Q(tt__isnull=True) | Q(tt__icontains=tt))) & (Q(tt__isnull=isnull_tt) | Q(tt__icontains=tt)),
((Q(spares__isnull=True) | Q(spares__icontains=spares))) & (Q(spares__isnull=isnull_spares) | Q(spares__icontains=spares)),
((Q(pending__isnull=True) | Q(pending__icontains=pending))) & (Q(pending__isnull=isnull_pending) | Q(pending__icontains=pending)),
((Q(actions__isnull=True) | Q(actions__icontains=actions))) & (Q(actions__isnull=isnull_actions) | Q(actions__icontains=actions)),
((Q(comments__isnull=True) | Q(comments__icontains=comments))) & (Q(comments__isnull=isnull_comments) | Q(comments__icontains=comments)),
((Q(lastupdate__isnull=True) | Q(lastupdate__icontains=lastupdate))) & (Q(lastupdate__isnull=isnull_lastupdate) | Q(lastupdate__icontains=lastupdate)),
((Q(opco__isnull=True) | Q(opco__icontains=opco))) & (Q(opco__isnull=isnull_opco) | Q(opco__icontains=opco)),
((Q(gsm__isnull=True) | Q(gsm__istartswith=gsm))) & (Q(gsm__isnull=isnull_gsm) | Q(gsm__istartswith=gsm)),
((Q(umts__isnull=True) | Q(umts__istartswith=umts))) & (Q(umts__isnull=isnull_umts) | Q(umts__istartswith=umts)),
((Q(lte__isnull=True) | Q(lte__istartswith=lte))) & (Q(lte__isnull=isnull_lte) | Q(lte__istartswith=lte)),
((Q(county__isnull=True) | Q(county__icontains=county))) & (Q(county__isnull=isnull_county) | Q(county__icontains=county)),
((Q(totalaffected__isnull=True) | Q(totalaffected__icontains=totalaffected))) & (Q(totalaffected__isnull=isnull_totalaffected) | Q(totalaffected__icontains=totalaffected)),
#Q(reason__icontains=reason), \
sitename__icontains=sitename, sitenumber__icontains=sitenumber, region__icontains=region, oosend__isnull=isnull_oosend ).order_by('-oostart')
except Exception as e:
logger.error(e.message)
if oostart:
oostart_date = oostart.split()[0].split('-')
year = oostart_date[0]
month = oostart_date[1]
day = oostart_date[2]
try:
sites = sites.filter(oostart__year=year, oostart__month=month, oostart__day=day).order_by('-oostart')
except Exception as e:
logger.error(e.message)
list(sites)
if oosend:
oosend_date = oosend.split()[0].split('-')
year = oosend_date[0]
month = oosend_date[1]
day = oosend_date[2]
try:
sites = sites.filter(oosend__year=year, oosend__month=month, oosend__day=day).order_by('-oostart')
except Exception as e:
logger.error(e.message)
list(sites)
########## Pagination ###############
paginator = Paginator(sites, 20)
#page = request.GET.get('page')
#print page
p = Page(sites, 20)
if page != None:
pages = p.pages_to_show(int(page))
else:
pages = p.pages_to_show(1)
try:
sites = paginator.page(page)
except PageNotAnInteger:
sites = paginator.page(1)
except EmptyPage:
sites = paginator.page(paginator.num_pages)
context = {'sites':sites, 'pages': pages}
return render(request, 'sites_down_ajax.html', context)
这是代码的一部分,但它对所有表格类似
任何使用过oracle的人都可以给我一些帮助或提示或任何可能导致此错误的建议或如何找到它,因为它非常混乱,我甚至很难识别。
谢谢