Background
I have a NodeJS server powered by ExpressJS that fetches data from Oracle database. I manage the database with Oracle SQL Developer tool. There is a database called MCF01 created using Database Configuration Assistant with pluggable database also named MCF01.
I connect to it using SYSTEM and the admin password both inside Oracle SQL Developer tool and from my server:
Now I created a table named CM_ITM_ALL:
CREATE TABLE "SYS"."CM_ITM_ALL" ...
I can without a problem query inside CM_ITM_ALL from Oracle SQL Developer tool like so:
Problem
I cannot execute the same query SELECT ITM_NM FROM CM_ITM_ALL WHERE ITM_NUM='a800004' using my nodejs server. What is the problem here?
Here is the error message from the Oracle via my server:
[Error: ORA-00942: table or view does not exist] {
errorNum: 942,
offset: 19
}
Table does exist. Connection is not a problem as it is giving out the table does not exist error. Otherwise it would give out wrong credentials error.
What I tried
Appending SYS into the query: SELECT ITM_NM FROM SYS.CM_ITM_ALL WHERE ITM_NUM='a800004'
Quoting the table name inside the query to SELECT ITM_NM FROM 'SYS'.'CM_ITM_ALL' WHERE ITM_NUM='a800004'
Dev environment
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0
NodeJS v16.13.0
ExpressJs 4.17.2
node-oracledb 5.3.0
Oracle SQL Developer 21.4.2
Update I revised my approach to use 1 sync scope per database schema. This eliminated the problem for all schemas except dbo. Then I split dbo into several sync scopes, which seems to have eliminated the problem in dbo. It is not clear to me why having a large number of tables in a single sync scope would lead to this particular error message.
I am using Microsoft Sync Framework 2.1 to set up synchronization between two databases. I am provisioning the Azure database using the following code:
// Set up destination server for sync
var destinationScopeProvisioning = new SqlSyncScopeProvisioning(DestinationConnection, scope);
if (!destinationScopeProvisioning.ScopeExists(ScopeName))
{
destinationScopeProvisioning.Apply();
}
This code throws an exception after running for several minutes:
An unhandled exception of type 'Microsoft.Synchronization.Data.DbPartiallyProvisionedException' occurred in Microsoft.Synchronization.Data.SqlServer.dll
Additional information: Cannot update identity column 'scope_local_id'.
Ordinarily, this kind of error is caused by a scope that already exists, so I've tried the following three methods (several times) to clean up the scopes and start again:
Deprovisioning the scope by invoking deprovisioning.DeprovisionScope(ScopeName)
Deprovisioning the store by invokeing deprovisioning.DeprovisionStore()
Dropping and recreating the database.
Unfortunately, none of those worked.
When I Create the azure database with Entity Framework model first pattern, then the creation works. But when I want to save the database I get the following error:
"Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again."
I updated entity Framework to Version 6.1.2. But still get the same eroor. Do you have any idea?
I've been scratching my head on this for hours, but can't seem to figure out what's wrong.
Here's our project basic setup:
MVC 3.0 Project with ASP.NET Membership
Entity Framework 4.3, Code First approach
Local environment: local SQL Server with 2 MDF database files attached (aspnet.mdf + entities.mdf)
Server environment: Windows Azure + 2 SQL Azure databases (aspnet and entities)
Here's what we did:
Created local and remote databases, modified web.config to use SQLEXPRESS connection strings in debug mode and SQL Azure connection strings in release mode
Created a SampleData class extending DropCreateDatabaseAlways<Entities> with a Seed method to seed data.
Used System.Data.Entity.Database.SetInitializer(new Models.SampleData()); in Application_Start to seed data to our databases.
Ran app locally - tables were created and seeded, all OK.
Deployed, ran remote app - tables were created and seeded, all OK.
Added pre-processor directives to stop destroying the Entity database at each application start on our remote Azure environment:
#if DEBUG
System.Data.Entity.Database.SetInitializer(new Models.SampleData());
#else
System.Data.Entity.Database.SetInitializer<Entities>(null);
#endif
Here's where it got ugly
We enabled Migrations using NuGet, with AutomaticMigrationsEnabled = true;
Everything was running smooth and nice. We left it cooking for a couple days
Today, we noticed an unknown bug on the Azure environment:
we have several classes deriving from a superclass SuperClass
the corresponding Entity table stores all of these objects in the same SuperClass table, using a discriminator to know which column to feed from when loading the various classes
While the loading went just fine before today, it doesn't anymore. We get the following error message:
The 'Foo' property on 'SubClass1' could not be set to a 'null' value. You must set this property to a non-null value of type 'Int32'.
After a quick check, our SuperClass table has columns Foo and Foo1. Logical enough, since SuperClass has 2 subclasses SubClass1 and SubClass2, each with a Foo property. In our case, Foo is NULL but Foo1 has an int32 value. So the problem is not with the database - rather, it would seem that the link between our Model and Database has been lost. The discriminator logic was corrupted.
Trying to find indications on what could've gone wrong, we noticed several things:
Even though we never performed any migration on the SQL Azure Entity database, the database now has a _MigrationHistory table
The _MigrationHistory table has one record:
MigrationID: 201204102350574_InitialCreate
CreatedOn: 4/10/2012 11:50:57 PM
Model: <Binary data>
ProductVersion: 4.3.1
Looking at other tables, most of them were emptied when this migration happened. Only the tables that were initially seeded with SampleData remained untouched.
Checking in with the SQL Azure Management portal, our Entity database shows the following creation date: 4/10/2012 23:50:55.
Here is our understanding
For some reason, SQL Azure deleted and recreated our database
The _MigrationHistory table was created in the process, registering a starting point to test the model against for future migrations
Here are our Questions
Who / What triggered the database deletion / recreation?
How could EF re-seed our sample data since Application_Start has System.Data.Entity.Database.SetInitializer<Entities>(null);?
EDIT: Looking at what could've gone wrong, we noticed one thing we didn't respect in this SQL Azure tutorial: we didn't remove PersistSecurityInfo from our SQL Azure Entity database connection string after the database was created. Can't see why on Earth it could have caused the problem, but still worth mentioning...
Nevermind, found the cause of our problem. In case anybody wonders: we hadn't made any Azure deployment since the addition of the pre-processor directives. MS must have restarted the machine our VM resided on, and the new VM recreated the database using see data.
Lesson learned: always do frequent Azure deployments.
I was trying to export SQL Server 2008 R2 database to Excel 2007. I used the export wizard in SQL Server Management Studio. I used a query to export some columns of a table. I checked the query (saw the result of parsing it) and it was good. But on the REVIEW DATA TYPE MAPPING it showed error notifications. It was converting varchar to LongText. But when I executed the package it failed to run showing fail status for steps like prepare for execute,pre-execute,execute . the error message is like this
Error 0xc002f210: Preparation SQL Task 1: Executing the query "CREATE TABLE Query (
id Long, sku LongText..." failed with the following error: "Unexpected error from external database driver (1309).". Possible failure
reasons: Problems with the query, "ResultSet" property not set
correctly, parameters not set correctly, or connection not established
correctly.
(SQL Server Import and Export Wizard)
Someone has a clue whats wrong?
Not an ideal answer (I have no idea what the cause of this problem is) but I was able to bypass this error by saving the excel sheet to 97-03 format and extracting to that.