To remove duplicate's using a loop in Oracle:
BEGIN
FOR Lcntr IN 1..560
LOOP
DELETE TABLE WHERE ROWID IN
(
SELECT min(ROWID)
FROM TABLE
GROUP BY COLUMN1, COLUMN2, COLUMN3, ...
HAVING count(1) > 1
);
END LOOP;
END;
And then, COMMIT; or ROLLBACK;
donderdag 25 april 2013
Oracle: Regular Expressions in Like
When you want to use regular expressions in the like part of the query in Oracle, use:
SELECT count(*) FROM TABLE WHERE REGEXP_LIKE(COLUMN, '^[0123456789].*$')
Notice that you cannot use '%' any more.
SELECT count(*) FROM TABLE WHERE REGEXP_LIKE(COLUMN, '^[0123456789].*$')
Notice that you cannot use '%' any more.
woensdag 24 april 2013
.NET: Easy way to make ANY_CPU compiled DLL 32-bit
The default configuration in Microsoft .NET is compiling the DLL's as ANY_CPU. This means that in a 64-bit environment the code will look for 64-bit drivers and in a 32-bit environment for 32-bit drivers.
In a professional environment, you typically notice this when moving to Windows 2008 R2. When you do not install 64-bit drivers, your software will not function anymore.
There is a solution, however: Use the Visual Studio tool CorFlags. The CorFlags Conversion tool allows you to configure the CorFlags section of the header of a portable executable image.
The following statement will set the DLL as 32-bit:
CorFlags.exe assembly.dll /32BIT+
Ofcourse, you can also recompile your software as X86, but in some cases which contain modifications in the build-scripts that may not be possible.
Notice that IIS 7.5 (Windows 2008 R2) does contain an advanced property in the Application Pool, which must be set to run 32-bit DLL's in IIS webapplications.
In a professional environment, you typically notice this when moving to Windows 2008 R2. When you do not install 64-bit drivers, your software will not function anymore.
There is a solution, however: Use the Visual Studio tool CorFlags. The CorFlags Conversion tool allows you to configure the CorFlags section of the header of a portable executable image.
The following statement will set the DLL as 32-bit:
CorFlags.exe assembly.dll /32BIT+
Ofcourse, you can also recompile your software as X86, but in some cases which contain modifications in the build-scripts that may not be possible.
Notice that IIS 7.5 (Windows 2008 R2) does contain an advanced property in the Application Pool, which must be set to run 32-bit DLL's in IIS webapplications.
vrijdag 12 april 2013
Oracle: all rows in a tree node
In Oracle 10, if you want to select all rows in een tree node do:
SELECT t.* FROM <table> t
START WITH t.ID = 'startvalue'
CONNECT BY PRIOR t.ID = t.PARENT_ID
SELECT t.* FROM <table> t
START WITH t.ID = 'startvalue'
CONNECT BY PRIOR t.ID = t.PARENT_ID
donderdag 11 april 2013
Oracle: Remove duplicate rows
In Oracle, when there are duplicate rows in a table, use the following piece to remove them:
DELETE <TABLE> WHERE ROWID IN
(
SELECT min(ROWID)
FROM <TABLE>
GROUP BY COLUMN1, COLUMN2, ...
HAVING count(1) > 1
)
Use all the columns in the table in the "group by" clause to ensure that the rows are identical.
DELETE <TABLE> WHERE ROWID IN
(
SELECT min(ROWID)
FROM <TABLE>
GROUP BY COLUMN1, COLUMN2, ...
HAVING count(1) > 1
)
Use all the columns in the table in the "group by" clause to ensure that the rows are identical.
maandag 8 april 2013
Found conflicts between different versions of the same dependent assembly. (MSB3247)
In SharpDevelop 4, you can come accross this warning: Found conflicts between different versions of the same dependent assembly. (MSB3247)
I've seen it the first time when using the .NET 4.0 framework. The error means that you should redirect all references of a DLL to the newest version of that DLL.
Do the following:
Create an app.config that looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="mscorlib" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 2.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 2.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 3.5.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
The last entry is the conflicting System.Web DLL that we have found by investigating the output. All versions of the System.Web DLL are now redirected to the 4.0.0.0 version of that DLL.
Now, the warning is gone when rebuilding.
Don't forget to turn off the diagnostic Building! It is much slower!
The mscorlib, System, System.Web assembly redirects are just samples. Redirect as many DLL's as needed.
I've seen it the first time when using the .NET 4.0 framework. The error means that you should redirect all references of a DLL to the newest version of that DLL.
Do the following:
- In SharpDevelop -> Tools/Options/Projects and Solutions/Build Verbosity: Diagnostic
- Now you can see the conflict in detail. Activate the output by -> View/Output.
- Rebuild the project.
- Search for "conflict" in the output.
- The DLL that's resolved before the conflict is the conflicting DLL. For example it prints: Dependency "System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Create an app.config that looks like:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="mscorlib" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 2.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System" publicKeyToken="b77a5c561934e089" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 2.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="1.0.3300.0 - 3.5.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
The last entry is the conflicting System.Web DLL that we have found by investigating the output. All versions of the System.Web DLL are now redirected to the 4.0.0.0 version of that DLL.
Now, the warning is gone when rebuilding.
Don't forget to turn off the diagnostic Building! It is much slower!
The mscorlib, System, System.Web assembly redirects are just samples. Redirect as many DLL's as needed.
Abonneren op:
Posts (Atom)