Wednesday, February 11, 2015

Oracle - Type Initialization Exception




For all the non-geniuses like me, I don’t have much experience working with Oracle, and had a challenging issue using the correct Oracle Library in my C# project.
There are 2 main types of libraries to connect to Oracle Database, one is provided by Microsoft(System.Data.OracleClient) and other by Oracle(Oracle.DataAccess.Client). To keep this conversation to a simplistic level I’ll not deep dive into the other library choices that we have. But in order to work with any of these you need to have the oracle client installed on your machine.


After brushing it under desk, I decided to revisit and address this issue. One of the most compelling reasons was that Microsoft Drivers have been deprecated in favor of Oracle supplied drivers, so it was important to understand the issue and solve it.
After a lot of research and trial-error, I identified that it was due to the difference in file bit versions.



So, go to Platform and switch to “Any CPU” and close. Rebuild your solution and it should work like a charm.


Hopefully, this resolves your issue.

Thursday, November 7, 2013

SQL–Basic Select

 

SQL –> Structured Query Language.

In this tutorial series, we’ll restrict ourselves to more examples which makes the concepts self explanatory.

Select * from TABLE_NAME;

select * from Person;

Explanation: Selects all the column from a table, like person table in the above example.

Select Id, FirstName, LastName from Person



Explanation: This query selects the Id, FirstName and LastName columns from Person Table.


Note: Always specify columns instead of using wildcardsStar as far as possible to improve performance.


Technorati Tags: ,,,,,,,,,,,,,,,,,,,,,,,,,,,,

Windows Live Tags: SQL,Basic,Select,Query,Language,tutorial,series,examples,concepts,self,TABLE_NAME,Person,Explanation,Selects,column,example,FirstName,LastName,size,Consolas,Courier,Monospace,margin,width,columns,Table,Note,performance,csharpcode


WordPress Tags: SQL,Basic,Select,Query,Language,tutorial,series,examples,concepts,self,TABLE_NAME,Person,Explanation,Selects,column,example,FirstName,LastName,size,Consolas,Courier,Monospace,margin,width,columns,Table,Note,performance,csharpcode


Blogger Labels: SQL,Basic,Select,Query,Language,tutorial,series,examples,concepts,self,TABLE_NAME,Person,Explanation,Selects,column,example,FirstName,LastName,size,Consolas,Courier,Monospace,margin,width,columns,Table,Note,performance,csharpcode


Tuesday, November 29, 2011

SQL to Get All the Stored Procedures in a SQL Server

We often come across Scenarios, when we need to find a particular object in SQL Server.
Generally the Objects will be either a Stored Procedure or a Table, so while working on one of this Issue I created a SQL query to address this.

/* SQL to Get All the Stored Procedures in a SQL Server */
/* Author : Sharadendu K Singh */
/* "ip.type = 'p'" -- This statement can be altered to 'u'
instead of 'p' to get the list of User defined Tables */
/* Additionally filters can also be applied at "ip.name like '%Query%' */

--Table Variable to Hold all the DB names in a SQL Server

Declare @DBlist table
(
 pk int identity(1,1),
 name nvarchar(100)
)

--Table Variable to Hold all the Stored Procedure in a SQL Server/DB

Declare @SPNametbl table
(
 name nvarchar(110),
 dbname nvarchar(100)
)

--Get the bnames of all the SQL DB in SQL Server

insert into @DBlist(name)
(
Select name
from sys.databases
)

Declare @pkcur int
Declare @pkmax int
Declare @dbname nvarchar(100)
Declare @Usevariable nvarchar(100)

select @pkmax = max(pk) from @DBlist
set @pkcur = 1

/* Loop through all the Databases and get the List of Stored Procedure */

while @pkcur <= @pkmax
begin
Set @dbname = (Select DO.name from @DBlist DO where DO.pk = @pkcur)
Set @Usevariable = 'USE' + @dbname;
EXEC(@Usevariable)
insert into @SPNametbl(name, dbname)
(
select ip.name, @dbname
from sys.objects ip
where
ip.type = 'p'
)
Select @pkcur = @pkcur +1
end

/* Returns the List of all the Stored Procedure to User */

Select * from @SPNametbl


Hope this Helps!!
For any queries/suggestions mail me @ sksfreedom@gmail.com