31 March 2008

How to return recordset from SELECT statement in Oracle?

In Oracle, returning a recordset from a stored procedure is not as straight forward as simply write a SELECT statement in MSSQL stored procedure. We will need to make use of a reference cursor to do that.

-- First, declare the reference cursor.
Type YourCursorType Is Ref Cursor;

-- Then, write the SELECT statement as usual by assign the cursor.
Open YourCursorType For
Select Field_Names From Table_Name
Where Related_Conditions
-- Group By Field_Names
-- Order By Field_Names

-- Note that the Group By and Order By are optional statements.

For more information, please refer to: http://decipherinfosys.wordpress.com/2007/08/06/oracle-returning-a-recordset-from-a-stored-procedure/

The request could not be submitted for background processing.

After install the Crystal Report Version 9.0, please remember to install the Crystal Report 9.0 Service Pack 5.

For more information, please refer to: http://technicalsupport.businessobjects.com/KanisaSupportSite/search.do;jsessionid=02A38E28C4F8A1D3D2D9382F64778A5A?cmd=displayKC&docType=kc&externalId=c2012318&sliceId=&dialogID=360384&stateId=1%200%20356275

ORA-06502: PL/SQL: numeric or value error: character string buffer too small

Make sure that the size of the target variable is same as the size of the assign value.

Examples:

-- Correct Way.
fstrVar1 VarChar2 (5);
fstrVar2 VarChar2 (5);

fstrVar2 := ‘12345’;
fstrVar1 := fstrVar2;

-- Incorrect Way.
fstrVar1 VarChar2 (4);
fstrVar2 VarChar2 (5);

fstrVar2 := ‘123456’; -- Error prompted here because fstrVar2 only accept 5 characters.

-- If fstrVar2 is changed to accept 6 characters.
fstrVar1 := fstrVar2; -- Error prompted here because fstrVar1 only accept 4 characters.

The breakpoint will not currently be hit. No symbols have been loaded for this document.

This error occurred when the file date is not match for the *.dll and *.pdb files, normally what I will do is: delete all of the *.pdb files and then debug again.

20 March 2008

How to read a text file by using stored procedure in Microsoft SQL Server?

SET NOCOUNT ON

/* Create a temporary table to store the data in the text file. Maximum character is 8000. */
CREATE TABLE #tempfile (line varchar(8000))

/* Insert data from the text file to the temporary table */
EXEC ('bulk INSERT #tempfile FROM "' + 'C:\Sample.txt' + '"')

/* Return the data in the text file. */
SELECT * FROM #tempfile

/* Drop the temporary table. */
DROP TABLE #tempfile

19 March 2008

Safety Windows Live Messenger

To make sure that your Windows Live Messenger (a.k.a. MSN) is safe enough, normally we will apply the followings:

1). Go to Tools -> Options



2). Go to 'Security', make sure the checkboxes are checked and un-checked accordingly.




3). NEVER open any internet link within the instant messenger or email.

The following are the common words that will be used by those instant messenger spammers or email spammers:

a). Click here to see my pictures.

b). Click here to see who delete you from their msn.

c). I just update my profile, please come and see.

d). I just uploaded some of my recent photos, please come and see.

Prevent is always better than cure.