-----------------------------
Create procedure in Oracle:
-----------------------------
create or replace PROCEDURE SP_GET_UserCOUNT (returnval out number) AS
BEGIN
select count(*) into returnval from (select * from usertable);
END SP_GET_UserCOUNT;
-----------------------------
Call form you vb function
-----------------------------
#Region "getUserCount"
Public Shared Function getUserCount() As Integer
Dim returncount As Integer
Try
'Using conn As OracleConnection = New OracleConnection(connecitonstring)
Using conn As OracleConnection = New OracleConnection(My.Settings.sConnectionString)
conn.Open()
Dim cmdTyProcessTbl As OracleCommand = New OracleCommand("", conn)
cmdTyProcessTbl.CommandText = "SP_GET_UserCOUNT"
cmdTyProcessTbl.CommandType = Data.CommandType.StoredProcedure
Dim prm As OracleParameter = New OracleParameter("a", OracleDbType.Int32)
prm.Direction = Data.ParameterDirection.Output
cmdTyProcessTbl.Parameters.Add(prm)
cmdTyProcessTbl.ExecuteNonQuery()
cmdTyProcessTbl.Dispose()
returncount = prm.Value.ToString
conn.Close()
conn.Dispose()
GC.Collect()
End Using
Return Convert.ToInt32(returncount)
Catch ex As Exception
Throw ex
End Try
End Function
#End Region
Wednesday, July 1, 2009
Tuesday, June 23, 2009
Learn how to scale your application cache on multiple servers (really cool)
Developer now can scale there .NET application objects in cache from string to binary objects using "Velocity"
Overview: Microsoft project code named “Velocity” provides a highly scalable in-memory application cache for all kinds of data. By using cache, you can significantly improve application performance by avoiding unnecessary calls to the data source. Distributed cache enables your application to match increasing demand with increasing throughput by using a cache cluster that automatically manages the complexities of load balancing. When you use “Velocity,” you can retrieve data by using keys or other identifiers, named “tags.” “Velocity” supports optimistic and pessimistic concurrency models, high availability, and a variety of cache configurations. “Velocity” includes an ASP.NET session provider object that enables you to store ASP.NET session objects in the distributed cache without having to write to databases, which increases the performance and scalability of ASP.NET applications.
You can checkout this webcast for complete understanding:
http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032413050&EventCategory=5&culture=en-US&CountryCode=US
Overview: Microsoft project code named “Velocity” provides a highly scalable in-memory application cache for all kinds of data. By using cache, you can significantly improve application performance by avoiding unnecessary calls to the data source. Distributed cache enables your application to match increasing demand with increasing throughput by using a cache cluster that automatically manages the complexities of load balancing. When you use “Velocity,” you can retrieve data by using keys or other identifiers, named “tags.” “Velocity” supports optimistic and pessimistic concurrency models, high availability, and a variety of cache configurations. “Velocity” includes an ASP.NET session provider object that enables you to store ASP.NET session objects in the distributed cache without having to write to databases, which increases the performance and scalability of ASP.NET applications.
You can checkout this webcast for complete understanding:
http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032413050&EventCategory=5&culture=en-US&CountryCode=US
Saturday, June 6, 2009
Retrieve Images that are saved in your Oracle tables as Blog
Ok. If you have images that are saved in your blob field. You can download then into your code as shown below.
Please don't forget visit my website at: www.lendmyspace.com and www.lookfordeal.com
Public Function saveBlobImages() As Single
Dim sqlStr1 As String
Dim cmd As New OracleClient.OracleCommand
Dim oraDa As OracleDataAdapter
Dim conn As OracleConnection = Nothing
Dim ms As MemoryStream = Nothing
Dim dsImage As Data.DataSet = Nothing
Dim myBytes() As Byte = Nothing
Dim imgJPG As System.Drawing.Image = Nothing
Dim msOut As MemoryStream = Nothing
Try
sqlStr1 = "select Image_Name, image_ID, blob_image from image_table where rownum < 100"
' Initialize connection
oraDa = New OracleDataAdapter(sqlStr1, My.Settings.sConnectionString)
conn = oraDa.SelectCommand.Connection
dsImage = New Data.DataSet()
oraDa.Fill(dsImage, "ImageTifImages")
If dsImage.Tables(0).Rows.Count = 0 Then
Throw New Exception("No results returned for rows")
Else
For i As Integer = 0 To dsImage.Tables(0).Rows.Count - 1
myBytes = dsImage.Tables(0).Rows(i)("blob_image")
ms = New MemoryStream
ms.Write(myBytes, 0, myBytes.Length)
imgJPG = Image.FromStream(ms)
'Export to TIF Stream
msOut = New MemoryStream
imgJPG.Save(msOut, System.Drawing.Imaging.ImageFormat.Jpeg)
imgJPG.Dispose()
imgJPG = Nothing
ms.Write(myBytes, 0, myBytes.Length)
imgJPG = System.Drawing.Image.FromStream(ms)
Dim filename As String = dsImage.Tables(0).Rows(i)("Image_Name").ToString + "_" + dsImage.Tables(0).Rows(i)("Image_id").ToString
filename = filename.Replace(".txt", "")
imgJPG.Save(filename + ".Tif")
ms.Close()
Next
End If
Catch ex As Exception
Throw
End Try
End Function
Please don't forget visit my website at: www.lendmyspace.com and www.lookfordeal.com
Public Function saveBlobImages() As Single
Dim sqlStr1 As String
Dim cmd As New OracleClient.OracleCommand
Dim oraDa As OracleDataAdapter
Dim conn As OracleConnection = Nothing
Dim ms As MemoryStream = Nothing
Dim dsImage As Data.DataSet = Nothing
Dim myBytes() As Byte = Nothing
Dim imgJPG As System.Drawing.Image = Nothing
Dim msOut As MemoryStream = Nothing
Try
sqlStr1 = "select Image_Name, image_ID, blob_image from image_table where rownum < 100"
' Initialize connection
oraDa = New OracleDataAdapter(sqlStr1, My.Settings.sConnectionString)
conn = oraDa.SelectCommand.Connection
dsImage = New Data.DataSet()
oraDa.Fill(dsImage, "ImageTifImages")
If dsImage.Tables(0).Rows.Count = 0 Then
Throw New Exception("No results returned for rows")
Else
For i As Integer = 0 To dsImage.Tables(0).Rows.Count - 1
myBytes = dsImage.Tables(0).Rows(i)("blob_image")
ms = New MemoryStream
ms.Write(myBytes, 0, myBytes.Length)
imgJPG = Image.FromStream(ms)
'Export to TIF Stream
msOut = New MemoryStream
imgJPG.Save(msOut, System.Drawing.Imaging.ImageFormat.Jpeg)
imgJPG.Dispose()
imgJPG = Nothing
ms.Write(myBytes, 0, myBytes.Length)
imgJPG = System.Drawing.Image.FromStream(ms)
Dim filename As String = dsImage.Tables(0).Rows(i)("Image_Name").ToString + "_" + dsImage.Tables(0).Rows(i)("Image_id").ToString
filename = filename.Replace(".txt", "")
imgJPG.Save(filename + ".Tif")
ms.Close()
Next
End If
Catch ex As Exception
Throw
End Try
End Function
Thursday, May 21, 2009
Azure - Simple Applicaiton - Security Exception Error
I have recently deploy Azure Application to see how Microsoft Cloud Application will work. In this process I come across Security Exception Error which took me while to figure out. So, if you have same issue make sure you do the following:
Here is the error message:
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.
1. In your "could" project make sure you open ".csdef" file and edit the following
WebRole name="WebRole" enableNativeCodeExecution="true">
Make sure you have enableNativeCodeExecution="true"
2. You should also make your "web_role" project open web.config file and make sure you have the following:
3. If you page still gives error message then you set all your <@Page Debug = "true"
4. Make sure you have customErrors mode="Off" in web.config file
This should make your application work on Azure Cloud Please don't forget to visit my website at: http://www.lookfordeal.com
Here is the error message:
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: That assembly does not allow partially trusted callers.
1. In your "could" project make sure you open ".csdef" file and edit the following
WebRole name="WebRole" enableNativeCodeExecution="true">
Make sure you have enableNativeCodeExecution="true"
2. You should also make your "web_role" project open web.config file and make sure you have the following:
3. If you page still gives error message then you set all your <@Page Debug = "true"
4. Make sure you have customErrors mode="Off" in web.config file
This should make your application work on Azure Cloud Please don't forget to visit my website at: http://www.lookfordeal.com
Tuesday, May 12, 2009
Oracle Package - Basics
Here is a sample of oracle package in which I will send startIndex as integer and endIndex as integer. In returns it will return me customer list
create or replace PACKAGE BODY PKG_GET_THANKYOU_customer_LIST AS
procedure getThankyouNames(startIndex IN number, endIndex in number,myMethodCode in varchar2, out_cursor OUT Thank_Cur) AS
localThank_Cursor Thank_cur;
BEGIN
/* TODO implementation required */
/* delete from temp_ty; */
insert into temp_thankyou_cust_list
select t3.customer_sid, ws1.order_sid, t2.order_code,max(ws1.order_date) order_date, rnum,t3.cust_company_name,
t3.cust_name,t3.cust_title, t3.cust_Phone, t3.cust_phone_ext, t3.cust_fax, t3.cust_STREET_ADDR_LINE1,
t3.cust_STREET_ADDR_LINE2,t3.cust_CITY,t3.cust_ZIP_CODE,t3.cust_ZIP_PLUS4,t3.cust_STATE_CODE,
t3.MY_METHOD_CODE
from work_table_order t2, work_spec_table ws1,
(select * from
(select t1.*, rownum rnum from
(select distinct c1.customer_sid, c1.cust_company_name, c1.cust_name,
c1.cust_title, c1.cust_Phone, c1.cust_phone_ext, c1.cust_fax,
c1.cust_STREET_ADDR_LINE1, c1.cust_STREET_ADDR_LINE2, c1.cust_CITY,
c1.cust_ZIP_CODE,c1.cust_ZIP_PLUS4,c1.cust_STATE_CODE,c1.RPC_METHOD_CODE
from customer c1, work_productive_order wp1
where c1.MY_METHOD_CODE = myMethodCode and c1.customer_sid = wp1.customer_sid
and wp1.customer_sid not in (select customer_sid from thankyou_customers)
order by c1.customer_sid
) t1
where rownum <= endIndex
)
where rnum >= startIndex
) t3
where t2.customer_sid = t3.customer_sid and ws1.order_sid = t2.order_sid
group by ws1.order_sid,t2.order_code, t3.customer_sid, rnum, t3.cust_company_name, t3.cust_name,
t3.cust_title, t3.cust_Phone, t3.cust_phone_ext, t3.cust_fax, t3.cust_STREET_ADDR_LINE1,
t3.cust_STREET_ADDR_LINE2,t3.cust_CITY,t3.cust_ZIP_CODE,t3.cust_ZIP_PLUS4,t3.cust_STATE_CODE,t3.MY_METHOD_CODE;
open localThank_Cursor for
select ty1.*, substr(ws1.text_description,1,50)
from temp_thankyou_cust_list ty1, work_spec_table ws1
where ty1.order_sid = ws1.order_sid and ty1.order_date = ws1.order_date
order by ty1.customer_sid, ty1.order_code;
out_cursor := localThank_Cursor;
END getThankyouNames;
END PKG_GET_THANKYOU_cust_LIST;
create or replace PACKAGE BODY PKG_GET_THANKYOU_customer_LIST AS
procedure getThankyouNames(startIndex IN number, endIndex in number,myMethodCode in varchar2, out_cursor OUT Thank_Cur) AS
localThank_Cursor Thank_cur;
BEGIN
/* TODO implementation required */
/* delete from temp_ty; */
insert into temp_thankyou_cust_list
select t3.customer_sid, ws1.order_sid, t2.order_code,max(ws1.order_date) order_date, rnum,t3.cust_company_name,
t3.cust_name,t3.cust_title, t3.cust_Phone, t3.cust_phone_ext, t3.cust_fax, t3.cust_STREET_ADDR_LINE1,
t3.cust_STREET_ADDR_LINE2,t3.cust_CITY,t3.cust_ZIP_CODE,t3.cust_ZIP_PLUS4,t3.cust_STATE_CODE,
t3.MY_METHOD_CODE
from work_table_order t2, work_spec_table ws1,
(select * from
(select t1.*, rownum rnum from
(select distinct c1.customer_sid, c1.cust_company_name, c1.cust_name,
c1.cust_title, c1.cust_Phone, c1.cust_phone_ext, c1.cust_fax,
c1.cust_STREET_ADDR_LINE1, c1.cust_STREET_ADDR_LINE2, c1.cust_CITY,
c1.cust_ZIP_CODE,c1.cust_ZIP_PLUS4,c1.cust_STATE_CODE,c1.RPC_METHOD_CODE
from customer c1, work_productive_order wp1
where c1.MY_METHOD_CODE = myMethodCode and c1.customer_sid = wp1.customer_sid
and wp1.customer_sid not in (select customer_sid from thankyou_customers)
order by c1.customer_sid
) t1
where rownum <= endIndex
)
where rnum >= startIndex
) t3
where t2.customer_sid = t3.customer_sid and ws1.order_sid = t2.order_sid
group by ws1.order_sid,t2.order_code, t3.customer_sid, rnum, t3.cust_company_name, t3.cust_name,
t3.cust_title, t3.cust_Phone, t3.cust_phone_ext, t3.cust_fax, t3.cust_STREET_ADDR_LINE1,
t3.cust_STREET_ADDR_LINE2,t3.cust_CITY,t3.cust_ZIP_CODE,t3.cust_ZIP_PLUS4,t3.cust_STATE_CODE,t3.MY_METHOD_CODE;
open localThank_Cursor for
select ty1.*, substr(ws1.text_description,1,50)
from temp_thankyou_cust_list ty1, work_spec_table ws1
where ty1.order_sid = ws1.order_sid and ty1.order_date = ws1.order_date
order by ty1.customer_sid, ty1.order_code;
out_cursor := localThank_Cursor;
END getThankyouNames;
END PKG_GET_THANKYOU_cust_LIST;
Tuesday, May 5, 2009
Wednesday, April 8, 2009
How to bring data from One Schema to Second Schema in Oracle
This is specify to Oracle 11
If you need to bring (transfer) data from older database schema (UDBTEST) to new schema (UDBBETA) in oracle database then you will follow there procedures:
1- Create a Link between both schema(s)
2- Run insert query
Step: 1 For this step you must have admin permission on database
ORACLE LINKS
HERE SOURCE IS UDBTEST and target is UDBBETA. Link is created in target and accessed in target.
Run it from UDBBETA:
select count(*) from team1_user@UDBTEST2BETA;
Link created in udbbeta connected to udbtest.:
CREATE PUBLIC DATABASE LINK UDBTEST2BETA
CONNECT TO 'yourusername' IDENTIFIED BY 'yourpassword'
USING 'udbtest'
/
Step 2: Run this command
Insert into
Select * from@UDBTEST2UDBBETA;
commit;
If you need to bring (transfer) data from older database schema (UDBTEST) to new schema (UDBBETA) in oracle database then you will follow there procedures:
1- Create a Link between both schema(s)
2- Run insert query
Step: 1 For this step you must have admin permission on database
ORACLE LINKS
HERE SOURCE IS UDBTEST and target is UDBBETA. Link is created in target and accessed in target.
Run it from UDBBETA:
select count(*) from team1_user@UDBTEST2BETA;
Link created in udbbeta connected to udbtest.
CREATE PUBLIC DATABASE LINK UDBTEST2BETA
CONNECT TO 'yourusername' IDENTIFIED BY 'yourpassword'
USING 'udbtest'
/
Step 2: Run this command
Insert into
Select * from
commit;
Subscribe to:
Posts (Atom)