473,774 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Database import fails and prints "insert table failed for eventLog" - what issue?

365 Contributor
database file gets created using below sql file, then lua script calls "db.import config_ascc", then I get errors says "insert table failed for eventLog", below are my sql file entry, config file, also import and saveTable function, any idea what is wrong, why I get error?. thanks in advance.




system.sql file
==========
CREATE TABLE eventLog
(
component text NOT NULL,
facilityId integer NOT NULL,
logLevel integer NOT NULL,
textMessage text NOT NULL,
binMessage blob,
FOREIGN KEY (component,faci lityId) REFERENCES compFacilityMap (component,faci lityId)
)
;

insert into saveTables (tableName) values("eventLo g");


config_ascci file
===========
eventLog = {}
eventLog[1] = {}
eventLog[1]["component"] = "UMI_COMP_N TP"
eventLog[1]["textMessag e"] = "Sun Dec 30 11:08:00 2007 [Netgard_MFD][System][NTP] ntpTblHandler:1 67:ntpTblHandle r\
eventLog[1]["logLevel"] = "128"
eventLog[1]["binMessage "] = ""
eventLog[1]["_ROWID_"] = "1"
eventLog[1]["facilityId "] = "3"
eventLog[2] = {}
eventLog[2]["component"] = "UMI_COMP_N TP"
eventLog[2]["textMessag e"] = "Sun Dec 30 11:08:00 2007 [Netgard_MFD][System][NTP] ntpTblHandler:1 81:tz: 0 \
eventLog[2]["logLevel"] = "128"
eventLog[2]["binMessage "] = ""
eventLog[2]["_ROWID_"] = "2"
eventLog[2]["facilityId "] = "3"
eventLog[3] = {}
eventLog[3]["component"] = "UMI_COMP_N TP"
eventLog[3]["textMessag e"] = "Sun Dec 30 11:08:00 2007 [Netgard_MFD][System][NTP] ntpTblHandler:1 91:DayLightsavi ng: 0 \
eventLog[3]["logLevel"] = "128"
eventLog[3]["binMessage "] = ""
eventLog[3]["_ROWID_"] = "3"
eventLog[3]["facilityId "] = "3"
eventLog[4] = {}
eventLog[4]["component"] = "UMI_COMP_N TP"
eventLog[4]["textMessag e"] = "Sun Dec 30 11:08:00 2007 [Netgard_MFD][System][NTP] ntpTblHandler:2 04:status: 1 \
eventLog[4]["logLevel"] = "128"
eventLog[4]["binMessage "] = ""
eventLog[4]["_ROWID_"] = "4"
eventLog[4]["facilityId "] = "3"
eventLog[5] = {}
eventLog[5]["component"] = "UMI_COMP_N TP"
eventLog[5]["textMessag e"] = "Sun Dec 30 11:08:03 2007 [Netgard_MFD][System][NTP] ntpTblHandler:2 36:pNtpControl->ServerNames[PRIMARY_SERVER]: 0.us.pool.ntp.o rg \
eventLog[5]["logLevel"] = "128"
eventLog[5]["binMessage "] = ""
eventLog[5]["_ROWID_"] = "5"
eventLog[5]["facilityId "] = "3"
eventLog[6] = {}
eventLog[6]["component"] = "UMI_COMP_N TP"
eventLog[6]["textMessag e"] = "Sun Dec 30 11:08:03 2007 [Netgard_MFD][System][NTP] ntpTblHandler:2 42:pNtpControl->ServerNames[SECONDARY_SERVE R]: 1.us.pool.ntp.o rg \
eventLog[6]["logLevel"] = "128"
eventLog[6]["binMessage "] = ""
eventLog[6]["_ROWID_"] = "6"
eventLog[6]["facilityId "] = "3"
eventLog[7] = {}
eventLog[7]["component"] = "UMI_COMP_N TP"
eventLog[7]["textMessag e"] = "Sun Dec 30 11:08:03 2007 [Netgard_MFD][System][NTP] ntpTblHandler:2 81:DS: 1 \
eventLog[7]["logLevel"] = "128"
eventLog[7]["binMessage "] = ""
eventLog[7]["_ROWID_"] = "7"
eventLog[7]["facilityId "] = "3"
eventLog[8] = {}
eventLog[8]["component"] = "UMI_COMP_N TP"
eventLog[8]["textMessag e"] = "Sun Dec 30 11:08:03 2007 [Netgard_MFD][System][NTP] ntpdGetDefaultS ervers:509:pPri Serv 0.us.pool.ntp.o rg\
eventLog[8]["logLevel"] = "128"
eventLog[8]["binMessage "] = ""
eventLog[8]["_ROWID_"] = "8"
eventLog[8]["facilityId "] = "3"
eventLog[9] = {}
eventLog[9]["component"] = "UMI_COMP_N TP"
eventLog[9]["textMessag e"] = "Sun Dec 30 11:08:03 2007 [Netgard_MFD][System][NTP] ntpdGetDefaultS ervers:510:pSec Serv 1.us.pool.ntp.o rg\
eventLog[9]["logLevel"] = "128"
eventLog[9]["binMessage "] = ""
eventLog[9]["_ROWID_"] = "9"
eventLog[9]["facilityId "] = "3"
eventLog[10] = {}
eventLog[10]["component"] = "UMI_COMP_PLATF ORM"
eventLog[10]["textMessag e"] = "Sun Dec 30 11:08:03 2007 [Netgard_MFD][System][PLATFORM] platformHandleD BUpdate:248:DAT ABASE UPDATE, Table Name:vlan operation:INSER T row=2\
eventLog[10]["logLevel"] = "128"
eventLog[10]["binMessage "] = ""
eventLog[10]["_ROWID_"] = "10"
eventLog[10]["facilityId "] = "3"

Expand|Select|Wrap|Line Numbers
  1.  
  2. database.lua script
  3. =============
  4. -- Import settings from given file.
  5. function db.import (filename)
  6.     local valid = true
  7.     util.appendDebugOut("Imported DB!<br>")
  8.     dofile(filename)
  9.     local saveTables = db.getTable("saveTables", false)
  10.     db.beginTransaction()
  11.  
  12.     -- for each dbTable
  13.     for k,v in pairs(saveTables) do
  14.         if (not valid) then break end
  15.         local tableName = v["tableName"]
  16.         local table = util.getLuaVariable(tableName)
  17.  
  18.         if (table == nil) then
  19.             print ("no LUA variable:" .. tableName)
  20.             break
  21.         end
  22.  
  23.         if (#table >= 1) then
  24.             -- for each row
  25.             for kk,vv in pairs(table) do
  26.                 valid = db.insert(tableName, table[kk], true, true)
  27.                 if (not valid) then 
  28.                     print ("******** table insert failed for " .. tableName)
  29.                     break 
  30.                 end
  31.             end
  32.         end
  33.     end
  34.  
  35.     -- return
  36.     if (valid) then
  37.         db.commitTransaction()
  38.         return "imported successfully!!!!!!!!!!!!!!!!!!"
  39.     else
  40.         db.rollback()
  41.         return "import failed!"
  42.     end
  43. end
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. -- Save table to file in ascii format.
  52. function db.saveTable (f, name, value, saved)
  53.     local one, two = "", ""
  54.     saved = saved or {}       -- initial value
  55.     if type(value) == "number" or type(value) == "string" then
  56.         one = name .. " = "
  57.         two = basicSerialize(value) .. "\n"
  58.         f:write(one, two)
  59.     elseif type(value) == "table" then
  60.         one = name .. " = "
  61.         if saved[value] then    -- value already saved?
  62.             f:write(one)
  63.             f:write(saved[value], "\n")  -- use its previous name
  64.         else
  65.             f:write(one)
  66.             f:write("{}\n")
  67.             saved[value] = name   -- save name for next time
  68.             for k,v in pairs(value) do      -- save its fields
  69.                 local fieldname = string.format("%s[%s]", name,
  70.                 basicSerialize(k))
  71.                 db.saveTable(f, fieldname, v, saved)
  72.             end
  73.         end
  74.     else
  75.     -- function
  76.     end
  77.     f:flush()
  78. end
  79.  
  80.  
Feb 1 '10 #1
0 1488

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1708
by: Thomas Reat | last post by:
The postgresql documentation claims that "on insert" rules are executed after the insert. This is not happening for me. I have a rule that is being executed even though the insert should have failed due to a foreign key check. The rule does an insert that is failing, and the whole insert fails. So in this case it's not a huge problem. But I get a completely useless error message, and as far as I can tell there is no way to determine...
2
8687
by: Robin Tucker | last post by:
I have some code that dynamically creates a database (name is @FullName) and then creates a table within that database. Is it possible to wrap these things into a transaction such that if any one of the following fails, the database "creation" is rolledback. Otherwise, I would try deleting on error detection, but it could get messy. IF @Error = 0 BEGIN SET @ExecString = 'CREATE DATABASE ' + @FullName EXEC sp_executesql @ExecString
1
4561
by: technocraze | last post by:
Hi guys, I am having trouble resolving this error. Below mentioned is my code and implmentation. MS Acess is my front end and sql server is my backend. What i want to achieve is to be able to insert StudentId in the table matching the values chosen in the combo boxes and listboxes. This sound more like searching the table to insert StudentId matching the criterias. I have set the necessary configuration for ODBC connection (File...
3
1705
by: 01423481d | last post by:
Hi All I am facing a very strange "problem" on the captioned issue, I hope I can explain it clearly. Actually I am developing an interface (using VB.net) which read records from a file and then import them to the database. The performance of the interface was about 20000 records/0.5 hrs. However, if I query the table using "SELECT COUNT(*) FROM TABLE" from the SQL Data Manager of Pervasive Control Center during the importation
3
1701
by: Twanne | last post by:
Hi, I've got a table called Aerosol and a table called LinkTabel. Now I do an update to a table from an excell sheet, this table is called ExportAerosol. So far so good, the import works perfect. Now when I want to transfer the data from the ExportAerosol table to the Aerosol table I have to make a unique key. I do this by adding a string to another key. Now there is no problem when I update the Aerosol table. It adds the values I...
5
3442
by: =?Utf-8?B?Y2RiaWdncw==?= | last post by:
Hi, I've been tasked to write a windows app that allows people to enter transactions. For each transaction, there can be an unknown number of items, and as a person enters an item, the program asks if there are more items. If yes, a new set of input boxes are created dynamically. What I was wondering is this - not knowing how many items are going to be entered, is there a way that I can change the layout of a database table depending...
5
1987
by: doc1355 | last post by:
Hi, I have a script that I need to use a variable to select the database table that I want to update or to get the results from. But for some reason when I use the variable I get error. If I replace the variable with the table name, it works fine. Here is the part of the code related to this issue: <?php $memberID = $_GET; if ($memberID < 50001) $data_table = 'new_members' && $auth_token = "first_token"; else
1
2258
srj115
by: srj115 | last post by:
This is just something that had me tearing out my nose hairs in frustration... hypothetically. I must have spent 7 or 8 hours trying to get this to work before I smelled the coffee (so to speak). Now, all I'm missing is my pride. The issue: Debugging my form to get the bound datagridview to update the backend database table. After running the app in the debugger, none of the changes I made to the table in the datagridview were being saved...
3
6016
by: Larry Leonard | last post by:
Running MSDE 2000 SP2 on Windows XP SP3. I have a T-SQL script that is relatively simple (adding constraints, inserting rows, etc.) and short (maybe 300 lines, heavily commented). It's an upgrade script I wrote weeks ago, and has worked fine everywhere. After the patch from last Wednesday. "Security Update for SQL Server 2000 Service Pack 4 (KB948110)", I have gotten the following error on two different machines, using a copy of the...
7
2299
by: tarunkhatri | last post by:
Hi, I want to insert multiple rows in a database table, from an submit form. But not able to trouble shoot the problem in my code. Following is the code. <form action=test_insert.php method="post"> <table> <?php for($i=0; $i<10; $i++) { ?> <tr>
0
9621
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10040
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7463
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4012
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.