Multiple websites on a single IIS Server using Host Header
http://www.geekshangout.com/?q=node/132
Showing posts with label Technical. Show all posts
Showing posts with label Technical. Show all posts
Friday, May 6, 2011
Tuesday, April 5, 2011
Query Tuning Steps
Most of the DBA’s new to query tuning would wonder where to start in order to tune a query. Step 1: Run the query in Management Studio and view the actual execution plan. To view the execution plan, press Ctrl+M and then execute the query in SSMS. Step 2: In Execition plan next to results ,Check if there are any table scans or Clustered index scan or Index scan involved in the execution plan. If yes, then you should analyze that table’s info thoroughly in the execution. Step 3: Identify the actual rows in the table where there is scan involved. If the table is slightly larger i.e. greater than 2000 rows I would suggest you to check if there are proper indexes in the table. If the table has less than 2000 records table scan wouldn’t be a problem and I would rather prefer a table scan on those tables. Step 4: If there is already an index you have to analyze why the optimizer preferred a Clustered index scan or an Index scan rather than Seeks. The reason may be due to fragmentation or outdated statistics or due to the least selectivity or the query cost. Step 5: The following query will give the exact % of fragmentation in the indexes for a particular table. The below query will display the fragmentation status in the table “Person.Address” in Adventureworks database. SELECT CAST(DB_NAME(database_id) AS varchar(20)) AS [Database Name], CAST(OBJECT_NAME(object_id) AS varchar(20)) AS [TABLE NAME], Index_id, Index_type_desc, Avg_fragmentation_in_percent, Avg_page_space_used_in_percent FROM sys.dm_db_index_physical_stats(DB_ID('AdventureWorks'),OBJECT_ID('person.address'),NULL,NULL,'Detailed') If the avg_fragmentation_in_percent is > 40% rebuild the index (using Alter index rebuild command) to eliminate fragmentation. It’s recommended to have a rebuild index job for all the tables scheduled to run on a weekly basis. Please NOTE that rebuilding an index is an expensive operation and ensure that it’s done only during OFF-Production hours. Step 6: If the indexes are fine, then check the statistics. Sometimes the index will be fine but the query would still continue to be slow since the optimizer wouldn’t be able to use the correct indexes due to outdated statistics. The following query gives the last time when the statistics for an index was last updated. SELECT Name AS Stats_Name, STATS_DATE(object_id, stats_id) AS Statistics_update_date FROM sys.stats WHERE object_id=OBJECT_ID('person.address') The statistics should be updated either weekly or daily or on alternate days depending on the frequency of modifications in the table. The more frequent the table is modified the more frequent the statistics should be updated. Sometimes for high transactional tables you can schedule a job to update the statistics on a regular basis. Please NOTE that rebuilding the index will automatically update the statistics as well. Hence avoid updating the statistics if you are rebuilding the index. Step 7: If you see any key lookups happening in the execution plan, make use of Included columns to create a covering Nonclustered index to avoid expensive lookup operation. This will help in improving the query performance as the logical reads would be reduced to a great extent. Step8: Ensure that each table has a clustered index preferably on primary key columns (by default there is one unless you explicitly mention Nonclustered) or on Identity columns. The clustered index should always be defined on unique valued columns like primary keys or identity. Step9: If you have a composite index, ensure to have the most selective field (the ones which have unique values) as the leading column in the index. Step10: If you couldn’t tune the query further or if you are clueless, try to use Database Tuning Advisor (DTA). Provide the SQL query as input file and run the DTA. It will provide a list of recommendations to reduce the query cost. Please do NOT blindly implement the suggestions doing so would certainly improve the query performance but you would end up creating numerous indexes which will be difficult to maintain during maintenance operations. You have to take the call of creating indexes as suggested by DTA, check whether the index will be used in most cases or if you can rewrite the query to make use of the existing indexes. Step11: While tuning stored procedures you need to ensure that the query plan for stored procedures is cached. The following query will help in providing the caching info for the stored procedures. SELECT usecounts, cacheobjtype, objtype, [text] FROM sys.dm_exec_cached_plans P CROSS APPLY sys.dm_exec_sql_text(plan_handle) S WHERE cacheobjtype = 'Compiled Plan' AND objtype='Proc' AND [text] NOT LIKE '%dm_exec_cached_plans%' AND S.DBID=11 --MENTION THE DATABASE ID FOR THE RESPECTIVE DATABASE (USE SP_HELPDB TO GET THE DBID) The value of usecounts will increase every time you run the same stored procedure.If there is a problem in caching check if there is any SET options as most of them will cause a recompile in query plan. Also the plan will be flushed out every time you run DBCC Freeproccache or DBCC FlushprocinDB. Never use both of them in production environment as it will remove the cache for all the procedures and they (SP) will have to be recompiled the next time they are run. If you suspect there might be some problem in the query plan, you can try to use WITH RECOMPILE option which will recompile the particular stored procedure every time it runs and see how the performance is. CREATE PROC Test WITH RECOMPILE AS Statement 1 Statement 2 Step12: Finally if all the above options are fine and the query couldn’t be tuned, try to rewrite the query. In few cases as soon as you view the query such as the ones below we need to rewrite the query: Creating a view with TOP 100% in order to include the ORDERBY clause in view definition where the view will not be sorted unless we explicitly sort the view by issuing <!--[endif]--> Select * from view order by column1 –Result will be sorted Select * from view – Result will NOT be sorted Thus there is a extra cost involved in sorting by using the ORDER BY clause in view definition even though the result is NOT sorted. Hence we should avoid ORDER BY in view definition and instead use it as Select * from view order by column1 <!--[endif]-->Using correlated sub queries will cause RBAR – Row by agonizing Row and will affect the performance. Avoid using Scalar functions in select statements and instead use Inline or Table valued function. Since Scalar function behaves like a cursor we need to avoid it being referenced in the Select statement Source : http://thedbadelight.blogspot.com/2011/01/normal-0-false-false-false-en-us-x-none.html
Thursday, March 24, 2011
Friday, February 25, 2011
WPF : Restrict Multiple Instance
protected override void OnStartup(StartupEventArgs e){
// Get Reference to the current Process
Process thisProc = Process.GetCurrentProcess();
// Check how many total processes have the same name as the current one
if (Process.GetProcessesByName(thisProc.ProcessName).Length > 1)
{
// If ther is more than one, then it is already running.
MessageBox.Show("Another Instance is already running.");
Application.Current.Shutdown();
return;
}
base.OnStartup(e);
}
Friday, January 21, 2011
Registering ASP.NET on IIS after installing the .NET Framework
If you install the .NET Framework on a system that has IIS already installed, IIS is automatically configured to handle requests to ASP.NET pages, and to redirect the execution to the ASP.NET runtime. However, it may happen that you installed the framework on a Windows 2000 Professional system where IIS was not already present, and just later decided to add IIS. Registering ASP.NET on IIS is not just a matter of associating the various .aspx, .asmx, .axd, .ashx and the other ASP.NET extensions to the aspnet_isapi.dll ISAPI, more has to be done to create the ASP.NET account and to set it for ASP.NET requests, register the ISAPI itself and other stuff. Doing all this manually can be a difficult operation, and requires a good understanding of many details. Fortunately there is an utility, shipped with the .NET Framework but not documented, that can take care of these configuration chores for you. The utility is aspnet_regiis.exe, it is located under
%WindowsDir%\Microsoft.NET\Framework\vx.y.zzzz\ and you should call it with the -i parameter: aspnet_regiis.exe -i
%WindowsDir%\Microsoft.NET\Framework\vx.y.zzzz\ and you should call it with the -i parameter: aspnet_regiis.exe -i
Friday, December 31, 2010
A newbie's guide to Android

Android was initially developed by Android Inc. in California which Google bought in 2005. The name comes from a cute little robot in Star Wars named Android.
Android is Google's mobile firmware platform that powers up many mobile devices and has been taking over iPhone sales these days. Android is basically a fragmented yet sort-of open source mobile platform built on Linux. It is written in 3 languages -- XML, Java and C++.
Android didn't receive a warm welcome at first, but Google finally made it and now Android is one of the successful operating systems mobile industry has ever witnessed.
Android is Google's mobile firmware platform that powers up many mobile devices and has been taking over iPhone sales these days. Android is basically a fragmented yet sort-of open source mobile platform built on Linux. It is written in 3 languages -- XML, Java and C++.
Android didn't receive a warm welcome at first, but Google finally made it and now Android is one of the successful operating systems mobile industry has ever witnessed.

For a variety of reasons.
If everyone is humming about Android, then there has to be something special about the stuff, isn't it? Android is the one comparable to the ruling king iOS (the one that powers iPhones, iPads and iPod Touch). Though we won't call Android a total open source platform but yet it does let you enjoy the openness you demand on a mobile platform unlike iOS which is closed and runs strictly according to Steve Jobs.
If everyone is humming about Android, then there has to be something special about the stuff, isn't it? Android is the one comparable to the ruling king iOS (the one that powers iPhones, iPads and iPod Touch). Though we won't call Android a total open source platform but yet it does let you enjoy the openness you demand on a mobile platform unlike iOS which is closed and runs strictly according to Steve Jobs.
Android, unlike iOS, lets you install third party applications and games if you want to and the Android Market (although just 1,00,000 apps strong right now compared to AppStore's 2,50,000 apps) has some really decent set of applications that are useful.
And if iOS is restricted to just Jobs' masterpiece iPhone, you can pick any phone with Android OS in it! Literally many! To name a few are HTC, Motorola, Samsung, LG, Dell and many more.
Then what's the basic difference in these phones, you may ask! It's simple if they are sharing the same firmware release they all function same with the only difference in hardware!
HTC Legend and Samsung Galaxy i5700 -- both run on Android 2.1, but the former is faster than the latter. Reason? HTC Legend has bigger RAM. So, if your only need is Android and you are ready to pick any Android phone, you better check out the hardware too.
As already said, when on an Android device you get full multitasking. That is, you can listen to music, talk to a friend, message another friend together while your desired website is being loaded in the background.
This is the power of multitasking and Android handles it pretty well.
Check out: The all new Gadgets and Gaming page
This one's to sync all. Google Calendar, Gmail and Picasa albums to your phone.
It's again a background process and you won't be bugged when it's running.
It's again a background process and you won't be bugged when it's running.
Once you get hooked up to UI and features Android Gmail and Mail App provides you, it's the toughest to switch to any other OS.
Gmail is obviously synced up and email app supports other emails based on IMAP, POP3 or Exchange Settings.
Gmail is obviously synced up and email app supports other emails based on IMAP, POP3 or Exchange Settings.
Android packs a notification bar at the top which can be dragged down to see what's new. So, bid goodbye to the days of pop-up notifications!
This is one fantastic feature that Android boasts. You just have to add your Facebook and Twitter account and it will automatically match your existing contacts with your Facebook friends and Tweeps.
You can view their status update from both the services in their contact itself.
This one is really handy. You never lose your contact even if you break your phone or it just gets crashed. The export feature saves all your contact in one VCF file in your SD card and import just extracts contact from VCF to phone.

Every Android phone has a GPS chip inside and A-GPS is always there in case GPS connectivity is absent. It's a pretty strong Online Map Navigation Application.This app works with your GPS and data connection and finds places near your location. You can easily find restaurants, bars, ATMs, hotels etc. easily with this.
Android allows rooting of devices so that people can gain Superuser Access to their devices and unlock features that aren't available by default. It also allows installing any custom ROM to your device
Monday, August 10, 2009
Coding standards - Check list
Check whether the code file (aspx, aspx.cs, ascx, ascx.cs, .svc, .svc.cs etc.) follows the standard naming conventions
Does the code file contain Summary comments at the top, and whether the information filled there is enough to understand about the code file?
Is the code separated into logical regions? Are the region names correct and convey the right message?
Does all methods carry Summary Comments (that start with ///)?
Are the comments descriptive enough to explain the intended purpose of the method?
Are all arguments/parameters and return types included in thee summary description?
Is proper line spacing provided between logical code blocks within a method?
Does the code file inherit the prescribed base classes? For example, all user web pages must inherit SynecticPage, admin pages must inherit SynecticAdminPage and central admin pages must inherit SynecticCentralAdminPage. Same way, all user controls must inherit SynecticControl. All WCF Web Services must inherit AuthorizedService.
Does all controls used in the file/page follow the standard naming conventions?
Does all method names used in the file/page follow the standard naming conventions?
Does all variables used in the file/page follow the standard naming conventions?
Are exceptions properly anticipated, handled and logged wherever necessary?
Is there any hardcoding of values while initializing objects? Particularly OrganisationId, OeId, UserId etc?
Are any connection strings hardcoded?
Are any configuration information hardcoded (which is supposed to be kept in the web.config file)?
Is there any string hardcoded within the file, which forms an output of the UI directly (potential multilingual issue)
Is the code properly intended and formatted? Use Ctrl K + D to format code.
Does any aspx page hard code styles, that are supposed to have been used from the stylesheet??
Are all aspx and html tags properly started and properly ended?
Is there any alert box in the page? (potential multilingual issue)
Are there any SQL queries that are created with concatenating values? (potential sql injection issue). Convert such queries to Stored Procedures
All queries should be done on and beyond the WCF Service Layer. There should not be any queries in other namespaces. Do any of such queries exist in the code files?
Is the page properly displayed in design view without "Error loading control" messages
Does the code contain non-initialized or unused variables (warnings - which are potential errors)
Are there any unwanted try/catch blocks in the application?
Does the code contain service calls / sp calls / query executions in a loop?… Are all service connections closed properly using open within try and close within finally block after checking the connection state?
Is there any business logic chek in stored procedures?
Are common functions properly referenced instead of standard conversion functions like Convert.ToInt32 etc?
Is there any dead code available in the code files?
Is there any inline HTML code available, which could have been implemented as a server control? (potential multilingual issue)
Are arrays handled efficiently? Is there a possibility of "Index was outside the bounds of the Array" error?
Does the code contain unwanted loops, indefinite loops, arrays etc?
Are nested if conditions used? Can they be rewritten using some other structure?
Are "Switch-case" used? If yes, then is "break" placed in all "case" constructs? Is there a "default" in place?
Are validations done for all control values as per table column descriptions?
Is "Rowversion" used propertly to check for concurrency issues in database?
Are error messages properly conveyed to the user?
Is the screen loaded (at runtime) as per performance standards laid out?
Does the code file contain Summary comments at the top, and whether the information filled there is enough to understand about the code file?
Is the code separated into logical regions? Are the region names correct and convey the right message?
Does all methods carry Summary Comments (that start with ///)?
Are the comments descriptive enough to explain the intended purpose of the method?
Are all arguments/parameters and return types included in thee summary description?
Is proper line spacing provided between logical code blocks within a method?
Does the code file inherit the prescribed base classes? For example, all user web pages must inherit SynecticPage, admin pages must inherit SynecticAdminPage and central admin pages must inherit SynecticCentralAdminPage. Same way, all user controls must inherit SynecticControl. All WCF Web Services must inherit AuthorizedService.
Does all controls used in the file/page follow the standard naming conventions?
Does all method names used in the file/page follow the standard naming conventions?
Does all variables used in the file/page follow the standard naming conventions?
Are exceptions properly anticipated, handled and logged wherever necessary?
Is there any hardcoding of values while initializing objects? Particularly OrganisationId, OeId, UserId etc?
Are any connection strings hardcoded?
Are any configuration information hardcoded (which is supposed to be kept in the web.config file)?
Is there any string hardcoded within the file, which forms an output of the UI directly (potential multilingual issue)
Is the code properly intended and formatted? Use Ctrl K + D to format code.
Does any aspx page hard code styles, that are supposed to have been used from the stylesheet??
Are all aspx and html tags properly started and properly ended?
Is there any alert box in the page? (potential multilingual issue)
Are there any SQL queries that are created with concatenating values? (potential sql injection issue). Convert such queries to Stored Procedures
All queries should be done on and beyond the WCF Service Layer. There should not be any queries in other namespaces. Do any of such queries exist in the code files?
Is the page properly displayed in design view without "Error loading control" messages
Does the code contain non-initialized or unused variables (warnings - which are potential errors)
Are there any unwanted try/catch blocks in the application?
Does the code contain service calls / sp calls / query executions in a loop?… Are all service connections closed properly using open within try and close within finally block after checking the connection state?
Is there any business logic chek in stored procedures?
Are common functions properly referenced instead of standard conversion functions like Convert.ToInt32 etc?
Is there any dead code available in the code files?
Is there any inline HTML code available, which could have been implemented as a server control? (potential multilingual issue)
Are arrays handled efficiently? Is there a possibility of "Index was outside the bounds of the Array" error?
Does the code contain unwanted loops, indefinite loops, arrays etc?
Are nested if conditions used? Can they be rewritten using some other structure?
Are "Switch-case" used? If yes, then is "break" placed in all "case" constructs? Is there a "default" in place?
Are validations done for all control values as per table column descriptions?
Is "Rowversion" used propertly to check for concurrency issues in database?
Are error messages properly conveyed to the user?
Is the screen loaded (at runtime) as per performance standards laid out?
Thursday, July 24, 2008
Saturday, May 10, 2008
VS2008 - Changes
1. In Regular Expression validation control's property standard validationExpression templates are missing.
2. Split is introduced in addition with Design and Source (Editor)
2. Split is introduced in addition with Design and Source (Editor)
HTML Tips
//To show the controls in single line
<tr><td nowrap="nowrap"><tr nowrap="nowrap"><td>
<div style="text-align:left" style="overflow:auto; height:155px;">
<tr><td nowrap="nowrap"><tr nowrap="nowrap"><td>
<div style="text-align:left" style="overflow:auto; height:155px;">
Graphics Mill for .NET
http://www.aurigma.com/Products/GraphicsMilldotNET/OnlineDemo.aspx
http://www.aurigma.com/Support/DocViewer/29/LoadingandSavingImagestoDatabase.htm.aspx
System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString);
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand("SELECT Image_Data FROM [Image] WHERE Image_ID=" + imageID, connection);
connection.Open();
Byte[] imageData = (byte[])command.ExecuteScalar();
connection.Close();
System.IO.MemoryStream stream = new System.IO.MemoryStream(imageData);
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(stream);
http://www.aurigma.com/Support/DocViewer/29/LoadingandSavingImagestoDatabase.htm.aspx
System.Data.SqlClient.SqlConnection connection = new System.Data.SqlClient.SqlConnection(connectionString);
System.Data.SqlClient.SqlCommand command = new System.Data.SqlClient.SqlCommand("SELECT Image_Data FROM [Image] WHERE Image_ID=" + imageID, connection);
connection.Open();
Byte[] imageData = (byte[])command.ExecuteScalar();
connection.Close();
System.IO.MemoryStream stream = new System.IO.MemoryStream(imageData);
Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap(stream);
Monday, March 17, 2008
Data Tier Generator - .Net free tools
Data Tier Generator
Microsoft .NET project that generates SQL Server 2000 scripts for stored procedures and C# classes used to access those stored procedures. The stored proecedures generated are as follows: Insert, Update, Delete, Select, SelectByPK, SelectByFK
http://sourceforge.net/project/showfiles.php?group_id=41502
MyGeneration Code Generator
MyGeneration is an extremely flexible template based code generator written in Microsoft.NET. MyGeneration is great at generating code for ORM architectures. The meta-data from your database is made available to the templates through the MyMeta API.
http://sourceforge.net/project/showfiles.php?group_id=198893
Microsoft .NET project that generates SQL Server 2000 scripts for stored procedures and C# classes used to access those stored procedures. The stored proecedures generated are as follows: Insert, Update, Delete, Select, SelectByPK, SelectByFK
http://sourceforge.net/project/showfiles.php?group_id=41502
MyGeneration Code Generator
MyGeneration is an extremely flexible template based code generator written in Microsoft.NET. MyGeneration is great at generating code for ORM architectures. The meta-data from your database is made available to the templates through the MyMeta API.
http://sourceforge.net/project/showfiles.php?group_id=198893
Friday, February 29, 2008
Oracle PL/SQL Leap year & Cheatsheet
A year is considered a leap year if the year is divisible by 4 but not divisible by 100 unless also divisible by 400.
create or replace function IS_LEAP_YEAR (nYr in number) return boolean is
v_day varchar2(2);
begin
select to_char(last_day(to_date( '01-FEB-' to_char(nYr), 'DD-MON-YYYY')), 'DD') into v_day from dual;
if v_day = '29' then -- if v_day = 29 then it must be a leap year, return TRUE
return TRUE;
else
return FALSE; -- otherwise year is not a leap year, return false
end if;
end;
--Or we can use Mod(year,4)
/*
V_REMAINDER1 := MOD(nYear,4);
V_REMAINDER2 := MOD(nYear,100);
V_REMAINDER3 := MOD(nYear,400);
IF ((V_REMAINDER1 = 0 AND V_REMAINDER2 <> 0 ) OR V_REMAINDER3 = 0) THEN
DBMS_OUTPUT.PUT_LINE(nYear ' is a leap year');
return true;
ELSE
DBMS_OUTPUT.PUT_LINE (nYear ' is not a leap year');
return false; */
Cheat sheet
http://www.yagc.ndo.co.uk/cheatsheets/plsql_cheatsheet.html
create or replace function IS_LEAP_YEAR (nYr in number) return boolean is
v_day varchar2(2);
begin
select to_char(last_day(to_date( '01-FEB-' to_char(nYr), 'DD-MON-YYYY')), 'DD') into v_day from dual;
if v_day = '29' then -- if v_day = 29 then it must be a leap year, return TRUE
return TRUE;
else
return FALSE; -- otherwise year is not a leap year, return false
end if;
end;
--Or we can use Mod(year,4)
/*
V_REMAINDER1 := MOD(nYear,4);
V_REMAINDER2 := MOD(nYear,100);
V_REMAINDER3 := MOD(nYear,400);
IF ((V_REMAINDER1 = 0 AND V_REMAINDER2 <> 0 ) OR V_REMAINDER3 = 0) THEN
DBMS_OUTPUT.PUT_LINE(nYear ' is a leap year');
return true;
ELSE
DBMS_OUTPUT.PUT_LINE (nYear ' is not a leap year');
return false; */
Cheat sheet
http://www.yagc.ndo.co.uk/cheatsheets/plsql_cheatsheet.html
Wednesday, February 27, 2008
Oracle - PL/SQL samples
Variables and Constants
Declaring Variables
part_no NUMBER(4);
in_stock BOOLEAN;
Assigning Values to a Variable
tax := price * tax_rate;
valid_id := FALSE;
bonus := current_salary * 0.10;
wages := gross_pay(emp_id, st_hrs, ot_hrs) - deductions;
SELECT salary * 0.10 INTO bonus FROM employees WHERE employee_id = emp_id;
DECLARE
my_sal REAL(7,2);
PROCEDURE adjust_salary (emp_id INT, salary IN OUT REAL) IS ...
BEGIN
SELECT AVG(sal) INTO my_sal FROM emp;
adjust_salary(7788, my_sal); -- assigns a new value to my_sal
Assigning a SQL Query Result to a PL/SQL Variable
DECLARE
emp_id employees.employee_id%TYPE := 100;
emp_name employees.last_name%TYPE;
wages NUMBER(7,2);
BEGIN
SELECT last_name, salary + (salary * nvl(commission_pct,0))
INTO emp_name, wages FROM employees
WHERE employee_id = emp_id;
dbms_output.put_line('Employee ' emp_name ' might make ' wages);
END;
/
Declaring Constants
credit_limit CONSTANT NUMBER := 5000.00;
Processing Queries with PL/SQL
FOR someone IN (SELECT * FROM employees)
LOOP
DBMS_OUTPUT.PUT_LINE('First name = ' someone.first_name);
DBMS_OUTPUT.PUT_LINE('Last name = ' someone.last_name);
END LOOP;
Declaring PL/SQL Variables
%TYPE attribute
my_title books.title%TYPE;
%ROWTYPE
DECLARE
dept_rec dept%ROWTYPE; -- declare record variable
--You use dot notation to reference fields, as the following example shows:
my_deptno := dept_rec.deptno;
--declare a cursor that retrieves the last name, salary, hire date…
DECLARE
CURSOR c1 IS
SELECT ename, sal, hiredate, job FROM emp;
emp_rec c1%ROWTYPE; -- declare record variable that represents
-- a row fetched from the emp table When you execute the statement
FETCH c1 INTO emp_rec;
Control Structures
Conditional Control
DECLARE
acct_balance NUMBER(11,2);
acct CONSTANT NUMBER(4) := 3;
debit_amt CONSTANT NUMBER(5,2) := 500.00;
BEGIN
SELECT bal INTO acct_balance FROM accounts
WHERE account_id = acct
FOR UPDATE OF bal;
IF acct_balance >= debit_amt THEN
UPDATE accounts SET bal = bal - debit_amt WHERE account_id = acct;
ELSE
INSERT INTO temp VALUES (acct, acct_balance, 'Insufficient funds');
END IF;
COMMIT;
END;
-- This CASE statement performs different actions based
-- on a set of conditional tests.
CASE
WHEN shape = 'square' THEN area := side * side;
WHEN shape = 'circle' THEN
BEGIN
area := pi * (radius * radius);
DBMS_OUTPUT.PUT_LINE('Value is not exact because pi is irrational.');
END;
WHEN shape = 'rectangle' THEN area := length * width;
ELSE
BEGIN
DBMS_OUTPUT.PUT_LINE('No formula to calculate area of a' shape);
RAISE PROGRAM_ERROR;
END;
END CASE;
Iterative Control
LOOP
-- sequence of statements
END LOOP;
FOR num IN 1..500 LOOP
INSERT INTO roots VALUES (num, SQRT(num));
END LOOP;
DECLARE
salary emp.sal%TYPE := 0;
mgr_num emp.mgr%TYPE;
last_name emp.ename%TYPE;
starting_empno emp.empno%TYPE := 7499;
BEGIN
SELECT mgr INTO mgr_num FROM emp
WHERE empno = starting_empno;
WHILE salary <= 2500 LOOP SELECT sal, mgr, ename INTO salary, mgr_num, last_name FROM emp WHERE empno = mgr_num; END LOOP; INSERT INTO temp VALUES (NULL, salary, last_name); COMMIT; EXCEPTION WHEN NO_DATA_FOUND THEN INSERT INTO temp VALUES (NULL, NULL, 'Not found'); COMMIT; END; --Loop LOOP ... total := total + salary; EXIT WHEN total > 25000; -- exit loop if condition is true
END LOOP;
-- control resumes here
Sequential Control
--The GOTO statement lets you branch to a label unconditionally.
IF rating > 90 THEN
GOTO calc_raise; -- branch to label
END IF;
...
<>
IF job_title = 'SALESMAN' THEN -- control resumes here
amount := commission * 0.25;
ELSE
amount := salary * 0.10;
END IF;
Writing Reusable PL/SQL Code
Subprograms
PROCEDURE award_bonus (emp_id NUMBER) IS
bonus REAL;
comm_missing EXCEPTION;
BEGIN -- executable part starts here
SELECT comm * 0.15 INTO bonus FROM emp WHERE empno = emp_id;
IF bonus IS NULL THEN
RAISE comm_missing;
ELSE
UPDATE payroll SET pay = pay + bonus WHERE empno = emp_id;
END IF;
EXCEPTION -- exception-handling part starts here
WHEN comm_missing THEN
...
END award_bonus;
Packages
CREATE PACKAGE emp_actions AS -- package specification
PROCEDURE hire_employee (empno NUMBER, ename CHAR, ...);
PROCEDURE fire_employee (emp_id NUMBER);
END emp_actions;
CREATE PACKAGE BODY emp_actions AS -- package body
PROCEDURE hire_employee (empno NUMBER, ename CHAR, ...) IS
BEGIN
INSERT INTO emp VALUES (empno, ename, ...);
END hire_employee;
PROCEDURE fire_employee (emp_id NUMBER) IS
BEGIN
DELETE FROM emp WHERE empno = emp_id;
END fire_employee;
END emp_actions;
Data Abstraction
Collections
PL/SQL collection types let you declare high-level datatypes similar to arrays, sets, and hash tables found in other languages. In PL/SQL, array types are known as varrays (short for variable-size arrays), set types are known as nested tables, and hash table types are known as associative arrays.
DECLARE
TYPE Staff IS TABLE OF Employee;
staffer Employee;
FUNCTION new_hires (hiredate DATE) RETURN Staff IS
BEGIN ... END;
BEGIN
staffer := new_hires('10-NOV-98')(5);
END;
/*Collections can be passed as parameters, so that subprograms can process arbitrary numbers of elements.You can use collections to move data into and out of database tables using high-performance language features known as bulk SQL. */
Records
DECLARE
TYPE TimeRec IS RECORD (hours SMALLINT, minutes SMALLINT);
TYPE MeetingTyp IS RECORD (
date_held DATE,
duration TimeRec, -- nested record
location VARCHAR2(20),
purpose VARCHAR2(50));
Object Types
PL/SQL supports object-oriented programming through object types. An object type encapsulates a data structure along with the functions and procedures needed to manipulate the data. The variables that form the data structure are known as attributes. The functions and procedures that manipulate the attributes are known as methods.
Object types reduce complexity by breaking down a large system into logical entities. This lets you create software components that are modular, maintainable, and reusable.
Object-type definitions, and the code for the methods, are stored in the database. Instances of these object types can be stored in tables or used as variables inside PL/SQL code.
CREATE TYPE Bank_Account AS OBJECT (
acct_number INTEGER(5),
balance REAL,
status VARCHAR2(10),
MEMBER PROCEDURE open (amount IN REAL),
MEMBER PROCEDURE verify_acct (num IN INTEGER),
MEMBER PROCEDURE close (num IN INTEGER, amount OUT REAL),
MEMBER PROCEDURE deposit (num IN INTEGER, amount IN REAL),
MEMBER PROCEDURE withdraw (num IN INTEGER, amount IN REAL),
MEMBER FUNCTION curr_bal (num IN INTEGER) RETURN REAL
);
Error Handling
/*PL/SQL makes it easy to detect and process error conditions known as exceptions. When an error occurs, an exception is raised: normal execution stops and control transfers to special exception-handling code, which comes at the end of any PL/SQL block. Each different exception is processed by a particular exception handler.
Predefined exceptions are raised automatically for certain common error conditions involving variables or database operations. For example, if you try to divide a number by zero, PL/SQL raises the predefined exception ZERO_DIVIDE automatically.
You can declare exceptions of your own, for conditions that you decide are errors, or to correspond to database errors that normally result in ORA- error messages. When you detect a user-defined error condition, you execute a RAISE statement. The following example computes the bonus earned by a salesperson. The bonus is based on salary and commission. If the commission is null, you raise the exception comm_missing. */
DECLARE
comm_missing EXCEPTION; -- declare exception
BEGIN
IF commission IS NULL THEN
RAISE comm_missing; -- raise exception
END IF;
bonus := (salary * 0.10) + (commission * 0.15);
EXCEPTION
WHEN comm_missing THEN ... -- process the exception
Declaring Variables
part_no NUMBER(4);
in_stock BOOLEAN;
Assigning Values to a Variable
tax := price * tax_rate;
valid_id := FALSE;
bonus := current_salary * 0.10;
wages := gross_pay(emp_id, st_hrs, ot_hrs) - deductions;
SELECT salary * 0.10 INTO bonus FROM employees WHERE employee_id = emp_id;
DECLARE
my_sal REAL(7,2);
PROCEDURE adjust_salary (emp_id INT, salary IN OUT REAL) IS ...
BEGIN
SELECT AVG(sal) INTO my_sal FROM emp;
adjust_salary(7788, my_sal); -- assigns a new value to my_sal
Assigning a SQL Query Result to a PL/SQL Variable
DECLARE
emp_id employees.employee_id%TYPE := 100;
emp_name employees.last_name%TYPE;
wages NUMBER(7,2);
BEGIN
SELECT last_name, salary + (salary * nvl(commission_pct,0))
INTO emp_name, wages FROM employees
WHERE employee_id = emp_id;
dbms_output.put_line('Employee ' emp_name ' might make ' wages);
END;
/
Declaring Constants
credit_limit CONSTANT NUMBER := 5000.00;
Processing Queries with PL/SQL
FOR someone IN (SELECT * FROM employees)
LOOP
DBMS_OUTPUT.PUT_LINE('First name = ' someone.first_name);
DBMS_OUTPUT.PUT_LINE('Last name = ' someone.last_name);
END LOOP;
Declaring PL/SQL Variables
%TYPE attribute
my_title books.title%TYPE;
%ROWTYPE
DECLARE
dept_rec dept%ROWTYPE; -- declare record variable
--You use dot notation to reference fields, as the following example shows:
my_deptno := dept_rec.deptno;
--declare a cursor that retrieves the last name, salary, hire date…
DECLARE
CURSOR c1 IS
SELECT ename, sal, hiredate, job FROM emp;
emp_rec c1%ROWTYPE; -- declare record variable that represents
-- a row fetched from the emp table When you execute the statement
FETCH c1 INTO emp_rec;
Control Structures
Conditional Control
DECLARE
acct_balance NUMBER(11,2);
acct CONSTANT NUMBER(4) := 3;
debit_amt CONSTANT NUMBER(5,2) := 500.00;
BEGIN
SELECT bal INTO acct_balance FROM accounts
WHERE account_id = acct
FOR UPDATE OF bal;
IF acct_balance >= debit_amt THEN
UPDATE accounts SET bal = bal - debit_amt WHERE account_id = acct;
ELSE
INSERT INTO temp VALUES (acct, acct_balance, 'Insufficient funds');
END IF;
COMMIT;
END;
-- This CASE statement performs different actions based
-- on a set of conditional tests.
CASE
WHEN shape = 'square' THEN area := side * side;
WHEN shape = 'circle' THEN
BEGIN
area := pi * (radius * radius);
DBMS_OUTPUT.PUT_LINE('Value is not exact because pi is irrational.');
END;
WHEN shape = 'rectangle' THEN area := length * width;
ELSE
BEGIN
DBMS_OUTPUT.PUT_LINE('No formula to calculate area of a' shape);
RAISE PROGRAM_ERROR;
END;
END CASE;
Iterative Control
LOOP
-- sequence of statements
END LOOP;
FOR num IN 1..500 LOOP
INSERT INTO roots VALUES (num, SQRT(num));
END LOOP;
DECLARE
salary emp.sal%TYPE := 0;
mgr_num emp.mgr%TYPE;
last_name emp.ename%TYPE;
starting_empno emp.empno%TYPE := 7499;
BEGIN
SELECT mgr INTO mgr_num FROM emp
WHERE empno = starting_empno;
WHILE salary <= 2500 LOOP SELECT sal, mgr, ename INTO salary, mgr_num, last_name FROM emp WHERE empno = mgr_num; END LOOP; INSERT INTO temp VALUES (NULL, salary, last_name); COMMIT; EXCEPTION WHEN NO_DATA_FOUND THEN INSERT INTO temp VALUES (NULL, NULL, 'Not found'); COMMIT; END; --Loop LOOP ... total := total + salary; EXIT WHEN total > 25000; -- exit loop if condition is true
END LOOP;
-- control resumes here
Sequential Control
--The GOTO statement lets you branch to a label unconditionally.
IF rating > 90 THEN
GOTO calc_raise; -- branch to label
END IF;
...
<
IF job_title = 'SALESMAN' THEN -- control resumes here
amount := commission * 0.25;
ELSE
amount := salary * 0.10;
END IF;
Writing Reusable PL/SQL Code
Subprograms
PROCEDURE award_bonus (emp_id NUMBER) IS
bonus REAL;
comm_missing EXCEPTION;
BEGIN -- executable part starts here
SELECT comm * 0.15 INTO bonus FROM emp WHERE empno = emp_id;
IF bonus IS NULL THEN
RAISE comm_missing;
ELSE
UPDATE payroll SET pay = pay + bonus WHERE empno = emp_id;
END IF;
EXCEPTION -- exception-handling part starts here
WHEN comm_missing THEN
...
END award_bonus;
Packages
CREATE PACKAGE emp_actions AS -- package specification
PROCEDURE hire_employee (empno NUMBER, ename CHAR, ...);
PROCEDURE fire_employee (emp_id NUMBER);
END emp_actions;
CREATE PACKAGE BODY emp_actions AS -- package body
PROCEDURE hire_employee (empno NUMBER, ename CHAR, ...) IS
BEGIN
INSERT INTO emp VALUES (empno, ename, ...);
END hire_employee;
PROCEDURE fire_employee (emp_id NUMBER) IS
BEGIN
DELETE FROM emp WHERE empno = emp_id;
END fire_employee;
END emp_actions;
Data Abstraction
Collections
PL/SQL collection types let you declare high-level datatypes similar to arrays, sets, and hash tables found in other languages. In PL/SQL, array types are known as varrays (short for variable-size arrays), set types are known as nested tables, and hash table types are known as associative arrays.
DECLARE
TYPE Staff IS TABLE OF Employee;
staffer Employee;
FUNCTION new_hires (hiredate DATE) RETURN Staff IS
BEGIN ... END;
BEGIN
staffer := new_hires('10-NOV-98')(5);
END;
/*Collections can be passed as parameters, so that subprograms can process arbitrary numbers of elements.You can use collections to move data into and out of database tables using high-performance language features known as bulk SQL. */
Records
DECLARE
TYPE TimeRec IS RECORD (hours SMALLINT, minutes SMALLINT);
TYPE MeetingTyp IS RECORD (
date_held DATE,
duration TimeRec, -- nested record
location VARCHAR2(20),
purpose VARCHAR2(50));
Object Types
PL/SQL supports object-oriented programming through object types. An object type encapsulates a data structure along with the functions and procedures needed to manipulate the data. The variables that form the data structure are known as attributes. The functions and procedures that manipulate the attributes are known as methods.
Object types reduce complexity by breaking down a large system into logical entities. This lets you create software components that are modular, maintainable, and reusable.
Object-type definitions, and the code for the methods, are stored in the database. Instances of these object types can be stored in tables or used as variables inside PL/SQL code.
CREATE TYPE Bank_Account AS OBJECT (
acct_number INTEGER(5),
balance REAL,
status VARCHAR2(10),
MEMBER PROCEDURE open (amount IN REAL),
MEMBER PROCEDURE verify_acct (num IN INTEGER),
MEMBER PROCEDURE close (num IN INTEGER, amount OUT REAL),
MEMBER PROCEDURE deposit (num IN INTEGER, amount IN REAL),
MEMBER PROCEDURE withdraw (num IN INTEGER, amount IN REAL),
MEMBER FUNCTION curr_bal (num IN INTEGER) RETURN REAL
);
Error Handling
/*PL/SQL makes it easy to detect and process error conditions known as exceptions. When an error occurs, an exception is raised: normal execution stops and control transfers to special exception-handling code, which comes at the end of any PL/SQL block. Each different exception is processed by a particular exception handler.
Predefined exceptions are raised automatically for certain common error conditions involving variables or database operations. For example, if you try to divide a number by zero, PL/SQL raises the predefined exception ZERO_DIVIDE automatically.
You can declare exceptions of your own, for conditions that you decide are errors, or to correspond to database errors that normally result in ORA- error messages. When you detect a user-defined error condition, you execute a RAISE statement. The following example computes the bonus earned by a salesperson. The bonus is based on salary and commission. If the commission is null, you raise the exception comm_missing. */
DECLARE
comm_missing EXCEPTION; -- declare exception
BEGIN
IF commission IS NULL THEN
RAISE comm_missing; -- raise exception
END IF;
bonus := (salary * 0.10) + (commission * 0.15);
EXCEPTION
WHEN comm_missing THEN ... -- process the exception
Monday, February 11, 2008
Creating another website in IIS
By default windows XP disables multiple websites under root i.e. IIS.
Follow the following steps to create another website in IIS.
Go the AdminScripts folder in the Inetpub Folder. The Inetpub will be created at the time of installing IIS. The path is C: ? Inetpub ? AdminScripts.
open command prompt as said and follow the steps.
Type cd C:\Inetpub\AdminScripts . This command causes the location will moved to AdminScripts folder.
Type adsutil.vbs enum w3svc /p command to get the list of websites in IIS. This will show the Default Web Site i.e. w3svc/1.
Type adsutil.vbs create_vserv W3SVC/2. This will create another website in IIS.
Type adsutil.vbs copy W3SVC/1 W3SVC/2, to copy the contents of default website to the newly created website.
Open the IIS to verify it.
To delete the newly created website use adsutil.vbs delete W3SVC/2 command.
To start and stop the IIS use net start w3svc and to stop IIS use net stop w3svc.
Follow the following steps to create another website in IIS.
Go the AdminScripts folder in the Inetpub Folder. The Inetpub will be created at the time of installing IIS. The path is C: ? Inetpub ? AdminScripts.
open command prompt as said and follow the steps.
Type cd C:\Inetpub\AdminScripts . This command causes the location will moved to AdminScripts folder.
Type adsutil.vbs enum w3svc /p command to get the list of websites in IIS. This will show the Default Web Site i.e. w3svc/1.
Type adsutil.vbs create_vserv W3SVC/2. This will create another website in IIS.
Type adsutil.vbs copy W3SVC/1 W3SVC/2, to copy the contents of default website to the newly created website.
Open the IIS to verify it.
To delete the newly created website use adsutil.vbs delete W3SVC/2 command.
To start and stop the IIS use net start w3svc and to stop IIS use net stop w3svc.
Wednesday, December 26, 2007
Oracle - Useful functions
/Create Table using As
CREATE TABLE New_Table_Name AS SELECT * FROM Table_Name WHERE Column1 >100;
SQL> SELECT 5/2 FROM DUAL
2 /
5/2
---------
2.5
SQL> SELECT -5/2 FROM DUAL
2 /
-5/2
---------
-2.5
SQL> SELECT ABS(-5/2) FROM DUAL
2 /
ABS(-5/2)
---------
2.5
SQL> SELECT ROUND(5/2) FROM DUAL;
ROUND(5/2)
----------
3
SQL> SELECT ROUND(-5/2) FROM DUAL;
ROUND(-5/2)
-----------
-3
SQL> SELECT CEIL(5/2) FROM DUAL;
CEIL(5/2)
---------
3
SQL> SELECT FLOOR(5/2) FROM DUAL;
FLOOR(5/2)
----------
2
SQL> SELECT TO_CHAR(SYSDATE) FROM DUAL;
TO_CHAR(S
---------
18-DEC-07
SQL> SELECT TO_DATE('18-Dec-07') FROM DUAL;
TO_DATE('
---------
18-DEC-07
SQL> SELECT TO_NUMBER('143') FROM DUAL;
TO_NUMBER('143')
----------------
143
SQL> SELECT UPPER('bALA') FROM DUAL;
UPPER('BALA')
--------------------------------
BALA
SQL> SELECT LOWER('sANdyA') FROM DUAL;
LOWER('SANDYA')
--------------------------------
sandya
SQL> SELECT SUBSTR('Bala krishnan',6,5) FROM DUAL;
SUBSTR('BALAKRISHNAN',6,5)
--------------------------------
krish
SQL> SELECT SUBSTR('Bala Krishnan',6) FROM DUAL;
SUBSTR('BALAKRISHNAN',6)
--------------------------------
Krishnan
SQL> SELECT NVL(NULL,'0') FROM DUAL;
NVL(NULL,'0')
--------------------------------
0
SQL> SELECT DECODE(NULL,NULL,0,1) FROM DUAL;
DECODE(NULL,NULL,0,1)
---------------------
0
SQL> SELECT LPAD(5,10,'*') FROM DUAL;
LPAD(5,10,'*')
-----------------
*********5
SQL> SELECT RPAD(6,10,'*') FROM DUAL;
RPAD(6,10,'*')
-----------------
6*********
SQL> SELECT LEAST(1,5,2,7) , GREATEST(1,5,2,7) FROM DUAL;
O/P
----
1 7
CREATE TABLE New_Table_Name AS SELECT * FROM Table_Name WHERE Column1 >100;
SQL> SELECT 5/2 FROM DUAL
2 /
5/2
---------
2.5
SQL> SELECT -5/2 FROM DUAL
2 /
-5/2
---------
-2.5
SQL> SELECT ABS(-5/2) FROM DUAL
2 /
ABS(-5/2)
---------
2.5
SQL> SELECT ROUND(5/2) FROM DUAL;
ROUND(5/2)
----------
3
SQL> SELECT ROUND(-5/2) FROM DUAL;
ROUND(-5/2)
-----------
-3
SQL> SELECT CEIL(5/2) FROM DUAL;
CEIL(5/2)
---------
3
SQL> SELECT FLOOR(5/2) FROM DUAL;
FLOOR(5/2)
----------
2
SQL> SELECT TO_CHAR(SYSDATE) FROM DUAL;
TO_CHAR(S
---------
18-DEC-07
SQL> SELECT TO_DATE('18-Dec-07') FROM DUAL;
TO_DATE('
---------
18-DEC-07
SQL> SELECT TO_NUMBER('143') FROM DUAL;
TO_NUMBER('143')
----------------
143
SQL> SELECT UPPER('bALA') FROM DUAL;
UPPER('BALA')
--------------------------------
BALA
SQL> SELECT LOWER('sANdyA') FROM DUAL;
LOWER('SANDYA')
--------------------------------
sandya
SQL> SELECT SUBSTR('Bala krishnan',6,5) FROM DUAL;
SUBSTR('BALAKRISHNAN',6,5)
--------------------------------
krish
SQL> SELECT SUBSTR('Bala Krishnan',6) FROM DUAL;
SUBSTR('BALAKRISHNAN',6)
--------------------------------
Krishnan
SQL> SELECT NVL(NULL,'0') FROM DUAL;
NVL(NULL,'0')
--------------------------------
0
SQL> SELECT DECODE(NULL,NULL,0,1) FROM DUAL;
DECODE(NULL,NULL,0,1)
---------------------
0
SQL> SELECT LPAD(5,10,'*') FROM DUAL;
LPAD(5,10,'*')
-----------------
*********5
SQL> SELECT RPAD(6,10,'*') FROM DUAL;
RPAD(6,10,'*')
-----------------
6*********
SQL> SELECT LEAST(1,5,2,7) , GREATEST(1,5,2,7) FROM DUAL;
O/P
----
1 7
Saturday, December 22, 2007
Oracle some tricks
// Other than SQL statements are not allowed in Oracle procedures. Only trick is Execute immediate
Execute immediate “DDL Commnds such as truncae table and crete table”
//ISQLW editor – to stop the execution of the query which takes long time.
ALT + F, C
//Debug tips
SET SERVER OUTPUT ON SIZE 100000;
DBMS_OUTPUT.Put_line('This is Bala');
SET SERVER OUTPUT OFF;
//GUI Tool for Oracle
TOAD and its free
//To Clear screen
CL SCR
//concatenation operator
SELECT 'Bala ' ' Loves ' 'Sandya' FROM DUAL
//To go to command prompt from a set of statements
/ or .
//To run the last statement or Execute the statements
RUN
//DECODE - If matches then this else that...
SQL>SELECT DECODE('&INP','r','Red color','g','Green color','b','Blue color','Default color') FROM DUAL
Enter value for inp: g
DECODE('G','R','REDCOLOR','G'
--------------------------------
Green color
Enter value for inp: b
DECODE('B','R','REDCOLOR','G'
--------------------------------
Blue color
Enter value for inp: sd
DECODE('SD','R','REDCOLOR','G
--------------------------------
Default color
//NVL - If Null Value Then
SQL> SELECT NVL('&inp','Null text') FROM DUAL;
Enter value for inp:
NVL('','NULLTEXT')
--------------------------------
Null text
Enter value for inp: Bala
NVL('BALA','NULLTEXT')
--------------------------------
Bala
//Spool
SQL> SPOOL C:\BALA.SQLSQL> SELECT 10 FROM DUAL;
10--------- 10
SQL> SPOOL OFF
//NLS - Configure for National Language Support
http://www.exzilla.net/docs/nls/oracleNLS01.php
http://download.oracle.com/docs/cd/B19188_01/doc/B15921/nls.htm
http://download-uk.oracle.com/docs/cd/B14117_01/olap.101/b10339/x_monitor018.htm
Execute immediate “DDL Commnds such as truncae table and crete table”
//ISQLW editor – to stop the execution of the query which takes long time.
ALT + F, C
//Debug tips
SET SERVER OUTPUT ON SIZE 100000;
DBMS_OUTPUT.Put_line('This is Bala');
SET SERVER OUTPUT OFF;
//GUI Tool for Oracle
TOAD and its free
//To Clear screen
CL SCR
//concatenation operator
SELECT 'Bala ' ' Loves ' 'Sandya' FROM DUAL
//To go to command prompt from a set of statements
/ or .
//To run the last statement or Execute the statements
RUN
//DECODE - If matches then this else that...
SQL>SELECT DECODE('&INP','r','Red color','g','Green color','b','Blue color','Default color') FROM DUAL
Enter value for inp: g
DECODE('G','R','REDCOLOR','G'
--------------------------------
Green color
Enter value for inp: b
DECODE('B','R','REDCOLOR','G'
--------------------------------
Blue color
Enter value for inp: sd
DECODE('SD','R','REDCOLOR','G
--------------------------------
Default color
//NVL - If Null Value Then
SQL> SELECT NVL('&inp','Null text') FROM DUAL;
Enter value for inp:
NVL('','NULLTEXT')
--------------------------------
Null text
Enter value for inp: Bala
NVL('BALA','NULLTEXT')
--------------------------------
Bala
//Cursor
DECLARE CURSOR CURPF IS
SELECT * FROM Table1
VarCPF CURPF%ROWTYPE;
BEGIN
FOR VarCPF IN CURPF LOOP
UPDATE Table2 SET Col1 = VarCPF.col1
WHERE Col2 = VarCPF.col2;
END LOOP;
END;
TEST USER
=========
SCOTT
TIGER
DBTEST
LOGIN AS SYSADMIN
=================
sys
*****
DBASE AS SYSDBA
Create and Grant permission
======================
SQL> CREATE USER baladba IDENTIFIED BY ****;
User created.
SQL> GRANT RESOURCE TO baladba;
Grant succeeded.
SQL> GRANT DBA TO baladba;
Grant succeeded.
SQL> GRANT CONNECT TO baladba;
Grant succeeded.
SQL> SELECT * FROM TAB;
//EXECUTE IMMEDIATE
SSQL := ' SELECT SUM('C2.CLASS ;
ssql := ssql ') into :p1 from EMP_TAX where payyear = :p2 and emp_no = :p3 ';
EXECUTE IMMEDIATE SSQL into p1 USING '2007','1117';
//Identify min value from different arrays
SELECT MIN(HRA) INTO EXHRA FROM
(SELECT HRA_ITD HRA FROM DUAL
UNION ALL
SELECT HRA_ACT HRA FROM DUAL
UNION ALL
SELECT COREPAY2 HRA FROM DUAL);
//Spool
SQL> SPOOL C:\BALA.SQLSQL> SELECT 10 FROM DUAL;
10--------- 10
SQL> SPOOL OFF
//NLS - Configure for National Language Support
http://www.exzilla.net/docs/nls/oracleNLS01.php
http://download.oracle.com/docs/cd/B19188_01/doc/B15921/nls.htm
http://download-uk.oracle.com/docs/cd/B14117_01/olap.101/b10339/x_monitor018.htm
Thursday, November 29, 2007
Standard Master 2005
Works directly against your source code, checking your naming conventions, commenting, and overall code construction.
Recently i was assigned a task to do code review of the team project, so i started looking for a tool and i tried SM 2005. It impressed me a because of userfriendlyness and i tested the pros and cons of SM 2005 in 2 hours. Few features like bulk comment, export the bug in xml, customization in Naming convention and code construct etc.
If FlexiSoft focus on the export and customization in error list , then it will be the best product. Export to Excel and word are missing. Hope the next version will fulfill the features.
Also i checked some other tools from other sites
My Choice :
http://www.flexisoftsolutions.com/ - Coding style, comments are handles properly and profile management and portability are good (My first choice)
http://submain.com - Very good, userfriendly, Excel and xml report, Naming conventions ... (This is my second choice)
http://www.gotdotnet.com - From Microsoft and free (Third)
http://www.ndepend.com - Suitable for Assembly comparison and dependency checking.
Subscribe to:
Posts (Atom)


