Popular Posts

Thursday, 22 August 2013

CREATE DYNAMIC TABLE

CREATE DYNAMIC TABLE.

Yes it easy for creating dynamic table....now what is dynamic table?
Its just the same HTLM table or asp.net table having same structure but getting the info from databse on demand basis(i.e DYNAMIC)....rest U ALL KNOW.(just kidding)
So lets see how can we accomplish this:

THE DESIGN PAGE:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>DYNAMIC TABLE</title>
</head>
<center><div id="divTable" runat="server">


</div>
</center>
</body>
</html>


COME on this much only.....yes this is the magic of ASP.NET...lets get on the code behind:

THE CODE BEHIND:

   public void getdynamictable()
    {
     //get your data from database or anything
        String query=" select name from Test_demo  where test_department=’ADMINISTRATOR’);

//HERE I am Getting all the emp name who are in admin department.
      




 string tablestring = "";
        //dt is datatable object which holds DB results.
     
  tablestring += "<table style='width:60%; border-style: solid'><tr  style='Font-Bold:True; Font-Size:X-Large; color:#000099 '><td>NAMES</td></tr>";
        foreach (DataRow dr in dt.Rows)
        {
            tablestring = tablestring + "<tr style='font-family:Monotype Corsiva; font-size: large; color: #FF3300; text-decoration: underline'><td>" + dr[0].ToString() + "</td><td>" + "<a href='MoredetailsOn emp.aspx?name=" + dr[0].ToString() + "'> EMP DETAILS</a> ";

        }
        tablestring = tablestring + "</table>";


        divTable.InnerHtml = tablestring;

    }


OUTPUT:

NAME
PIYUSHEMP DETAILS
TEST 1EMP DETAILS
TEST  2EMP DETAILS
TEST  3EMP DETAILS
TEST  4EMP DETAILS
TEST  5EMP DETAILS
THUS ALL THE RESULT IS FIRST STORED IN DATTABLE OBJECT.
IT ASSIGNS EACH ROW TO TABLE ROW.In addition I have given a link to get more information on employes(YOUR WISH)  in secound column of table.



So IT DONE EASY AND PERFECT..HENCE YOUR PROBLEM SOVED ..............................So JUST COPY AND (!!!!UNDERSTAND.......) AND GET AMAZED ON YOUR INTELLIGENCEIF ANY ERROR OR SUGGESTION IS ,ALWAYS WELCOME....................................................................THANKS FOR BEARING.............................................................................................................................. 

The TOP Most Common Oracle Errors

I have been in this industry(IT) not so LONG enough But still I can count the faces with such bad /funcky look, when every developer and DBA had a pile of dusty Oracle user guides on their desks and, every time their database or application coughed up an error, would thumb through the books with mounting desperation. Fortunately, the times have moved on and we now all outsource our memories to Google / Bing . Our desks are clear, but our need for external help whenever we are ambushed by unexpected errors is just as strong.

This article will list the top most error people get and let one by one we will discusses...
HAVE PATIENCEESS(  OHHH I know it difficult ,even to write the spelling)


Top  Most Searched For Oracle Errors

PositionErrorGlobal Monthly Searches*
1ORA-12154101,500
2ORA-0060040,500
3ORA-0172227,100
4ORA-1256022,200
5ORA-0311318,100
6ORA-0060414,800
7ORA-0093612,100
8ORA-0101712,100
9ORA-0155512,100
10ORA-0403112,100
11ORA-0025712,100
12ORA-2710112,100
13ORA-0091112,100
14ORA-009339,900
15ORA-014039,900
16ORA-014229,900
17ORA-040309,900
18ORA-009329,900
19ORA-010318,100
20ORA-200008,100
21ORA-125608,100
22ORA-065088,100
23ORA-010006,600
24ORA-125056,600
25ORA-200016,600
26ORA-125196,600
27ORA-010086,600
28ORA-000546,600
29ORA-018306,600
30ORA-009076,600
31ORA-009846,600
32ORA-014615,400
33ORA-011105,400
34ORA-000015,400
35ORA-020105,400
36ORA-125375,400
37ORA-031355,400
38ORA-010345,400
39ORA-009185,400
40ORA-040635,400



THESE ALL...NO THERE ARE MORE
JUST GOT BORED SO IF YOU HAVE NEW ONE PLEASE ADD.................


FOR DETAILS ANALYSIS OF THESE ERROR PLEASE SEE:
LETS HANDLE THE ERRRORS ORACLE TOP 10.......

SQL Server Error Messages - Msg 205

Error Message:

Server: Msg 205, Level 16, State 1, Line 2

All queries in an SQL statement containing a UNION
operator must have an equal number of expressions intheir target lists.

Causes:

This error occurs when doing either a UNION or UNION ALL on two tables wherein the number of columns specified in the SELECT statement in the first table does not match the number of columns specified in the SELECT statement in the second table.

Lets SEE AN EXAMPLE:

CREATE TABLE [dbo].[TEST_TABLE] (
    [TESTID]                INT,
    [FirstName]             VARCHAR(50),
    [LastName]              VARCHAR(50),
    [GRADE]                 VARCHAR(50)
)    

CREATE TABLE [dbo].[OLDTEST_TABLE] (
    [TESTID]            INT,
    [FirstName]             VARCHAR(50),
    [LastName]              VARCHAR(50),
    [GRADE]                VARCHAR(50),
    [Dates]                DATETIME
)

To get a list of all names of the company, previous and past, you would do a UNION ALL of both tables, as follows:
SELECT * FROM [dbo].[TEST_TABLE]
UNION ALL
SELECT * FROM [dbo].[OLDTEST_TABLE]

But since the [dbo].[OLDTEST_TABLE] table has an extra column, [Dates], the following error is encountered:

Server: Msg 205, Level 16, State 1, Line 2
All queries in an SQL statement containing a UNION operator
must have an equal number of expressions in their target lists.


Solution/Workaround:

When performing a UNION or UNION ALL on two tables that do not have the same number of columns, you have to specify each column in the SELECT clause instead of doing a SELECT *.  Aside from this, for the table that has a lesser number of columns, you have to provide a filler for the missing column or columns, such as NULL values or empty strings for VARCHAR columns and 0 for numeric columns.
To avoid the error in the example above, here’s how the SELECT statement will look like:

SELECT [TESTID], [FirstName], [LastName],
       [GRADE], NULL AS [Dates]
FROM [dbo].[TEST_TABLE]
UNION ALL
SELECT [TESTID], [FirstName], [LastName],
       [GRADE], [Dates]
FROM [dbo].[OLDTEST_TABLE]

Since the [dbo].[TEST_TABLE] table contain current NAMES, it doesn’t have a column for the Dates.  To overcome the error, a NULL value is returned for that column



DELETE/TRUNCATE COMMAND BIG DIFFERENCE


The DELETE command is used to remove rows from a table. A WHERE clause can be used to only remove some rows. If no WHERE condition is specified, all rows will be removed. After performing a DELETE operation you need to COMMIT or ROLLBACK the transaction to make the change permanent or to undo it. Note that this operation will cause all DELETE triggers on the table to fire.
SQL> SELECT COUNT(*) FROM TEST;

  COUNT(*)
----------
        14

SQL> DELETE FROM TEST WHERE NAME = 'PIYUSH';

4 rows deleted.

SQL> COMMIT; //FOR EVERY DML COMMAND COMMIT IS NECESSARY

Commit complete.

SQL> SELECT COUNT(*) FROM TEST;

  COUNT(*)
----------
        10
TRUNCATE removes all rows from a table. The operation cannot be rolled back and no triggers will be fired. As such, TRUCATE is faster and doesn't use as much undo space as a DELETE.
SQL> TRUNCATE TABLE TEST;

Table truncated.

SQL> SELECT COUNT(*) FROM TEST;

  COUNT(*)
----------
         0
The DROP command removes a table from the database. All the tables' rows, indexes and privileges will also be removed. No DML triggers will be fired. The operation cannot be rolled back.
SQL> DROP TABLE TEST;

Table dropped.

SQL> SELECT * FROM TEST;
SELECT * FROM TEST
              *
ERROR at line 1:
ORA-00942: table or view does not exist

DROP and TRUNCATE are DDL commands, whereas DELETE is a DML command. Therefore DELETE operations can be rolled back (undone), while DROP and TRUNCATE operations cannot be rolled back.
From Oracle 10g a table can be "undropped". Example:
SQL> FLASHBACK TABLE TEST TO BEFORE DROP;

Flashback complete.
FOR MORE ON FLASHBACK SEE POST:

GET DROPED TABLE BACK VIA FLASHBACK UNDER ORACLE TIPS AND ERROR