Sunday, 19 October 2014

Oracle HTML output

Oracle HTML output


In this small tutorial I will show you how you can display the output of the select command in a formatted HTML table from sqlPlus.

Tutorial info:


Name:Oracle HTML output
Total steps:1
Category:Oracle
Date:2007-11-15
Level:Beginner
Product:See complete product
Viewed:35720

Bookmark Oracle HTML output



AddThis Social Bookmark Button

Step 1 - HTML output from sqlPlus


Oracle HTML output
Oracle is a very feature rich high end database, however sqlPlus is one of it's weakness. Time to time it you need to list the content of a table or view in Oracle using sqlPlus and it usually results a hard interpretable output. There is the possibility to set line size parameter and modify the display size of the columns but it takes to much time.
I nice solution would be to display the output in a HTML format. Fortunately we can do that. Now I will show you 2 solutions. The first one is working from the command line and the second one is working inside sqlPLus.
1. Generate Oracle HTML output from command line:

Code:



  1.  



  2. sqlplus -S -M "HTML ON TABLE 'BORDER="2"'" user/password @test.sql>test.html



  3.  




In this example you need to create the test.sql file and put all your sql statements in this file. The result will be written into the test.html file.
2. Generate Oracle HTML output inside sqlPlus:

Code:



  1. SET markup HTML on



  2. spool test.html



  3. SELECT * FROM mytable;



  4. spool off



  5. SET markup HTML off




In this case you can write all of your sql statements between the spool commands. The test.html file will be generated in the actual directory.
As you can see these solutions are not the best as you can view the files in a browser and not in sqlPlus, however in a lot of cases this solution makes your life easier.

Oracle DBA FAQ - Understanding SQL SELECT Query Stateme

Oracle DBA FAQs and Tips - 400 Questions/Tutorials
This is a collection of FAQ and tips for Oracle DBA and developers. The clear answers and sample scripts provided can be used as learning tutorials or interview preparation guides.
It doesn't matter whether you are a beginner or an experienced Oracle DBA or developer, browse through our Oracle DBA FAQ and tips. They will always help you to improve your skills and find some good ideas to solve problems in your daily tasks.
So far, Our Oracle developers have written 400 questions and answers to share with you. Each one of them answers one commonly asked Oracle question with a short, but precise and clear SQL script. More questions will be available soon. Please come back to visit this page again.

This is a collection of 17 FAQs for Oracle DBA on fundamental concepts. The clear answers and sample scripts provided can be used as learning tutorials or interview preparation guides.
  1. What Is Oracle?
  2. What Is an Oracle Database?
  3. What Is an Oracle Instance?
  4. What Is a Parameter File?
  5. What Is a Server Parameter File?
  6. What Is an Initialization Parameter File?
  7. What Is System Global Area (SGA)?
  8. What Is Program Global Area (PGA)?
  9. What Is a User Account?
  10. What Is the Relation of a User Account and a Schema?
  11. What Is a User Role?
  12. What Is a Database Schema?
  13. What Is a Database Table?
  14. What Is a Table Index?
  15. What Is an Oracle Tablespace?
  16. What Is an Oracle Data File?
  17. What Is a Static Data Dictionary?
  18. What Is a Dynamic Performance View?
  19. What Is a Recycle Bin?
  20. What Is SQL*Plus?
  21. What Is Transport Network Substrate (TNS)?
  22. What Is Open Database Communication (ODBC)?
This is a collection of 21 FAQs for Oracle DBA on Oracle 10g Express Edition with installation and basic introduction. The clear answers and sample scripts provided can be used as learning tutorials or interview preparation guides.
  1. What Is Oracle Database 10g Express Edition?
  2. What Are the Limitations of Oracle Database 10g XE?
  3. What Operating Systems Are Supported by Oracle Database 10g XE?
  4. How To Download Oracle Database 10g XE?
  5. How To Install Oracle Database 10g XE?
  6. How To Check Your Oracle Database 10g XE Installation?
  7. How To Shutdown Your 10g XE Server?
  8. How To Start Your 10g XE Server?
  9. How Much Memory Your 10g XE Server Is Using?
  10. How To Start Your 10g XE Server from Command Line?
  11. How To Shutdown Your 10g XE Server from Command Line?
  12. How To Unlock the Sample User Account?
  13. How To Change System Global Area (SGA)?
  14. How To Change Program Global Area (PGA)?
  15. What Happens If You Set the SGA Too Low?
  16. What To Do If the StartDB.bat Failed to Start the XE Instance?
  17. How To Login to the Server without an Instance?
  18. How To Use "startup" Command to Start Default Instance?
  19. Where Are the Settings Stored for Each Instance?
  20. What To Do If the Binary SPFile Is Wrong for the Default Instance?
  21. How To Check the Server Version?
A collection of 25 FAQs on Oracle command-line SQL*Plus client tool. Clear answers are provided with tutorial exercises on creating tnsnames.ora and connecting to Oracle servers; SQL*Plus settings and environment variables; saving query output to files; getting query performance reports.
  1. What Is SQL*Plus?
  2. How To Start the Command-Line SQL*Plus?
  3. How To Get Help at the SQL Prompt?
  4. What Information Is Needed to Connect SQL*Plus an Oracle Server?
  5. What Is a Connect Identifier?
  6. How To Connect a SQL*Plus Session to an Oracle Server?
  7. What Happens If You Use a Wrong Connect Identifier?
  8. What To Do If DBA Lost the SYSTEM Password?
  9. What Types of Commands Can Be Executed in SQL*Plus?
  10. How To Run SQL Commands in SQL*Plus?
  11. How To Run PL/SQL Statements in SQL*Plus?
  12. How To Change SQL*Plus System Settings?
  13. How To Look at the Current SQL*Plus System Settings?
  14. What Are SQL*Plus Environment Variables?
  15. How To Generate Query Output in HTML Format?
  16. What Is Output Spooling in SQL*Plus?
  17. How To Save Query Output to a Local File?
  18. What Is Input Buffer in SQL*Plus?
  19. How To Revise and Re-Run the Last SQL Command?
  20. How Run SQL*Plus Commands That Are Stored in a Local File?
  21. How To Use SQL*Plus Built-in Timers?
  22. What Is Oracle Server Autotrace?
  23. How To Set Up Autotrace for a User Account?
  24. How To Get Execution Path Reports on Query Statements?
  25. How To Get Execution Statistics Reports on Query Statements?
A collection of 28 FAQs on Oracle SQL language basics. Clear answers are provided with tutorial exercises on data types, data literals, date and time values, data and time intervals, converting to dates and times, NULL values, pattern matches.
  1. What Is SQL Standard?
  2. How Many Categories of Data Types?
  3. What Are the Oracle Built-in Data Types?
  4. What Are the Differences between CHAR and NCHAR?
  5. What Are the Differences between CHAR and VARCHAR2?
  6. What Are the Differences between NUMBER and BINARY_FLOAT?
  7. What Are the Differences between DATE and TIMESTAMP?
  8. What Are the Differences between INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND?
  9. What Are the Differences between BLOB and CLOB?
  10. What Are the ANSI Data Types Supported in Oracle?
  11. How To Write Text Literals?
  12. How To Write Numeric Literals?
  13. How To Write Date and Time Literals?
  14. How To Write Date and Time Interval Literals?
  15. How To Convert Numbers to Character Strings?
  16. How To Convert Characters to Numbers?
  17. How To Convert Dates to Characters?
  18. How To Convert Character Strings to Dates?
  19. How To Convert Times to Character Strings?
  20. How To Convert Character Strings to Times?
  21. What Is NULL Value?
  22. How To Use NULL as Conditions?
  23. How To Concatenate Two Text Values?
  24. How To Increment Dates by 1?
  25. How To Calculate Date and Time Differences?
  26. How To Use IN Conditions?
  27. How To Use LIKE Conditions?
  28. How To Use Regular Expression in Pattern Match Conditions?
A collection of 11 FAQs on Oracle SQL DDL statements. Clear answers are provided with tutorial exercises on creating, altering and dropping tables, indexes, and views.
  1. What Are DDL Statements?
  2. How To Create a New Table?
  3. How To Create a New Table by Selecting Rows from Another Table?
  4. How To Add a New Column to an Existing Table?
  5. How To Delete a Column in an Existing Table?
  6. How To Drop an Existing Table?
  7. How To Create a Table Index?
  8. How To Rename an Index?
  9. How To Drop an Existing Index?
  10. How To Create a New View?
  11. How To Drop an Existing View?
A collection of 15 FAQs on Oracle SQL DML statements. Clear answers are provided with tutorial exercises on inserting, updating and deleting rows from database tables.
  1. What Are DML Statements?
  2. How To Create a Testing Table?
  3. How To Set Up SQL*Plus Output Format?
  4. How To Insert a New Row into a Table?
  5. How To Specify Default Values in INSERT Statement?
  6. How To Omit Columns with Default Values in INSERT Statement?
  7. How To Insert Multiple Rows with One INSERT Statement?
  8. How To Update Values in a Table?
  9. How To Update Values on Multiple Rows?
  10. How To Use Existing Values in UPDATE Statements?
  11. How To Use Values from Other Tables in UPDATE Statements?
  12. What Happens If the UPDATE Subquery Returns Multiple Rows?
  13. How To Delete an Existing Row from a Table?
  14. How To Delete Multiple Rows from a Table?
  15. How To Delete All Rows from a Table?
A collection of 33 FAQs on Oracle SQL SELECT query statements. Clear answers are provided with tutorial exercises on selecting rows and columns from tables and views, sorting and counting query outputs, grouping outputs and applying group functions, joining tables, using subqueries.
  1. What Is a SELECT Query Statement?
  2. How To Select All Columns of All Rows from a Table?
  3. How To Select Some Columns from a Table?
  4. How To Select Some Rows from a Table?
  5. How To Sort the Query Output?
  6. Can the Query Output Be Sorted by Multiple Columns?
  7. How To Sort Query Output in Descending Order?
  8. How To Use SELECT Statement to Count the Number of Rows?
  9. Can SELECT Statements Be Used on Views?
  10. How To Filter Out Duplications in Returning Rows?
  11. What Are Group Functions?
  12. How To Use Group Functions in the SELECT Clause?
  13. Can Group Functions Be Mixed with Non-group Selection Fields?
  14. How To Divide Query Output into Groups?
  15. How To Apply Filtering Criteria at Group Level?
  16. How To Count Duplicated Values in a Column?
  17. Can Multiple Columns Be Used in GROUP BY?
  18. Can Group Functions Be Used in the ORDER BY Clause?
  19. How To Join Two Tables in a Single Query?
  20. How To Write a Query with an Inner Join?
  21. How To Define and Use Table Alias Names?
  22. How To Write a Query with a Left Outer Join?
  23. How To Write a Query with a Right Outer Join?
  24. How To Write a Query with a Full Outer Join?
  25. How To Write an Inner Join with the WHERE Clause?
  26. How To Write a Left Outer Join with the WHERE Clause?
  27. How To Name Query Output Columns?
  28. What Is a Subquery?
  29. How To Use Subqueries with the IN Operator?
  30. How To Use Subqueries with the EXISTS Operator?
  31. How To Use Subqueries in the FROM Clause?
  32. How To Count Groups Returned with the GROUP BY Clause?
  33. How To Return Top 5 Rows?
A collection of 22 FAQs on Oracle SQL transaction management. Clear answers are provided with tutorial exercises on starting and ending transactions, committing and rolling back transactions, transaction/statement-level read consistency, read committed isolation level, locks and dead locks.
  1. What Is a Transaction?
  2. How To Start a New Transaction?
  3. How To End the Current Transaction?
  4. How To Create a Test Table for Transaction Testing?
  5. How To Commit the Current Transaction?
  6. How To Rollback the Current Transaction?
  7. What Happens to the Current Transaction If a DDL Statement Is Executed?
  8. What Happens to the Current Transaction If the Session Is Ended?
  9. What Happens to the Current Transaction If the Session Is Killed?
  10. How Does Oracle Handle Read Consistency?
  11. What Is a READ WRITE Transaction?
  12. What Is a READ ONLY Transaction?
  13. How To Set a Transaction To Be READ ONLY?
  14. What Are the Restrictions in a READ ONLY Transaction?
  15. What Are the General Rules on Data Consistency?
  16. What Are Transaction Isolation Levels Supported by Oracle?
  17. What Is a Data Lock?
  18. How Data Locks Are Respected?
  19. How To Experiment a Data Lock?
  20. How To View Existing Locks on the Database?
  21. What Is a Dead Lock?
  22. How Oracle Handles Dead Locks?
A collection of 23 FAQs on Oracle user account, schema and privileges. Clear answers are provided with tutorial exercises on creating user accounts, granting privileges for session connections, granting privileges for creating tables and inserting rows.
  1. What Is a User Account?
  2. What Is the Relation of a User Account and a Schema?
  3. What Is a User Role?
  4. What Are the System Predefined User Roles?
  5. What Are Internal User Account?
  6. How To Connect to the Server with User Account: SYS?
  7. How To Use Windows User to Connect to the Server?
  8. How To List All User Accounts?
  9. How To Create a New User Account?
  10. How To Change User Password?
  11. How To Delete a User Account?
  12. What Privilege Is Needed for a User to Connect to Oracle Server?
  13. How To Grant CREATE SESSION Privilege to a User?
  14. How To Revoke CREATE SESSION Privilege from a User?
  15. How To Lock and Unlock a User Account?
  16. What Privilege Is Needed for a User to Create Tables?
  17. How To Assign a Tablespace to a Users?
  18. What Privilege Is Needed for a User to Create Views?
  19. What Privilege Is Needed for a User to Create Indexes?
  20. What Privilege Is Needed for a User to Query Tables in Another Schema?
  21. What Privilege Is Needed for a User to Insert Rows to Tables in Another Schema?
  22. What Privilege Is Needed for a User to Delete Rows from Tables in Another Schema?
  23. How To Find Out What Privileges a User Currently Has?
A collection of 18 FAQs on database tables for DBA and developers. Clear answers are provided together with tutorial exercises to help beginners on creating, altering and removing tables, adding, altering and removing columns, and working with recycle bin.
  1. What Is a Database Table?
  2. How Many Types of Tables Supported by Oracle?
  3. How To Create a New Table in Your Schema?
  4. How To Create a New Table by Selecting Rows from Another Table?
  5. How To Rename an Existing Table?
  6. How To Drop an Existing Table?
  7. How To Add a New Column to an Existing Table?
  8. How To Add a New Column to an Existing Table with a Default Value?
  9. How To Rename a Column in an Existing Table?
  10. How To Delete a Column in an Existing Table?
  11. How To View All Columns in an Existing Table?
  12. How To Recover a Dropped Table?
  13. What Is Recycle Bin?
  14. How To Turn On or Off Recycle Bin for the Instance?
  15. How To View the Dropped Tables in Your Recycle Bin?
  16. How To Empty Your Recycle Bin?
  17. How To Turn On or Off Recycle Bin for the Session?
  18. How To List All Tables in Your Schema?
This is a collection of 14 FAQs for Oracle DBA on creating, dropping, rebuilding and managing indexes. The clear answers and sample scripts provided can be used as learning tutorials or interview preparation guides.
  1. What Is an Index?
  2. How To Run SQL Statements through the Web Interface?
  3. How To Create a Table Index?
  4. How To List All Indexes in Your Schema?
  5. What Is an Index Associated with a Constraint?
  6. How To Rename an Index?
  7. How To Drop an Index?
  8. Can You Drop an Index Associated with a Unique or Primary Key Constraint?
  9. What Happens to Indexes If You Drop a Table?
  10. How To Recover a Dropped Index?
  11. What Happens to the Indexes If a Table Is Recovered?
  12. How To Rebuild an Index?
  13. How To See the Table Columns Used in an Index?
  14. How To Create a Single Index for Multiple Columns?
A collection of 19 FAQs on creating and managing tablespaces and data files. Clear answers are provided with tutorial exercises on creating and dropping tablespaces; listing available tablespaces; creating and dropping data files; setting tablespaces and data files offline; removing corrupted data files.
  1. What Is an Oracle Tablespace?
  2. What Is an Oracle Data File?
  3. How a Tablespace Is Related to Data Files?
  4. How a Database Is Related to Tablespaces?
  5. How To View Tablespaces in the Current Database?
  6. What Are the Predefined Tablespaces in a Database?
  7. How To View Data Files in the Current Database?
  8. How To Create a New Oracle Data File?
  9. How To Create a New Tablespace?
  10. How To Rename a Tablespace?
  11. How To Drop a Tablespace?
  12. What Happens to Data Files If a Tablespace Is Dropped?
  13. How To Create a Table in a Specific Tablespace?
  14. How To See Free Space of Each Tablespace?
  15. How To Bring a Tablespace Offline?
  16. How To Bring a Tablespace Online?
  17. How To Add Another Datafile to a Tablespace?
  18. What Happens If You Lost a Data File?
  19. How Remove Data Files before Opening a Database?
This is a collection of 15 FAQs for Oracle DBA on creating Oracle database instances manually using CREATE DATABASE statement. Items in this FAQ collection are organized together to form a complete tutorial guide on creating a new database instance manually.
  1. How To Create an Oracle Database?
  2. How To Create an Oracle Database Manually?
  3. How To Select an Oracle System ID (SID)?
  4. How To Establish Administrator Authentication to the Server?
  5. How To Create an Initialization Parameter File?
  6. How To Connect the Oracle Server as SYSDBA?
  7. How To Create a Server Parameter File?
  8. How To Start an Oracle Instance?
  9. How To Start a Specific Oracle Instance?
  10. How To Start Instance with a Minimal Initialization Parameter File?
  11. How To Run CREATE DATABASE Statement?
  12. How To Do Clean Up If CREATE DATABASE Failed?
  13. How To Run CREATE DATABASE Statement Again?
  14. How To Create Additional Tablespaces for an New Database?
  15. How To Build Data Dictionary View of an New Database?
A collection of 17 FAQs to introduce PL/SQL language for DBA and developers. This FAQ can also be used as learning tutorials on creating procedures, executing procedures, using local variables, controlling execution flows, passing parameters and defining nested procedures.
  1. What Is PL/SQL?
  2. What Are the Types PL/SQL Code Blocks?
  3. How To Define an Anonymous Block?
  4. How Many Anonymous Blocks Can Be Defined?
  5. How To Run the Anonymous Block Again?
  6. What Is a Stored Program Unit?
  7. How To Create a Stored Program Unit?
  8. How To Execute a Stored Program Unit?
  9. How Many Data Types Are Supported?
  10. What Are the Execution Flow Control Statements?
  11. How To Use SQL Statements in PL/SQL?
  12. How To Process Query Result in PL/SQL?
  13. How To Create an Array in PL/SQL?
  14. How To Manage Transaction Isolation Level?
  15. How To Pass Parameters to Procedures?
  16. How To Define a Procedure inside Another Procedure?
  17. What Do You Think about PL/SQL?
A collection of 29 FAQs to introduce Oracle SQL Developer, the new free GUI client for DBA and developers. This FAQ can also be used as learning tutorials on SQL statement execution, data objects management, system views and reports, stored procedure debugging.
  1. What Is Oracle SQL Developer?
  2. What Operating Systems Are Supported by Oracle SQL Developer?
  3. How To Download Oracle SQL Developer?
  4. How To Install Oracle SQL Developer?
  5. How To Start Oracle SQL Developer?
  6. Is Oracel SQL Developer written in Java?
  7. How To Connect to a Local Oracle 10g XE Server?
  8. How To Connect to a Remote Server?
  9. How To Run SQL Statements with Oracle SQL Developer?
  10. How To Export Your Connection Information to a File?
  11. How To Run SQL*Plus Commands in SQL Developer?
  12. How To Work with Data Objects Interactively?
  13. How To Get a CREATE Statement for an Existing Table?
  14. How To Create a Table Interactively?
  15. How To Enter a New Row into a Table Interactively?
  16. What Is the Reports View in Oracle SQL Developer?
  17. How To Get a List of All Tables in the Database?
  18. How To Get a List of All User Accounts in the Database?
  19. How To Get a List of All Background Sessions in the Database?
  20. How To Create Your Own Reports in SQL Developer?
  21. How Many File Formats Are Supported to Export Data?
  22. How To Export Data to a CSV File?
  23. How To Export Data to an XML File?
  24. How To Create a Procedure Interactively?
  25. How To Run a Stored Procedure Interactively?
  26. How To Run Stored Procedures in Debug Mode?
  27. How To Assign Debug Privileges to a User?
  28. How To Set Up Breakpoints in Debug Mode?
  29. What Do You Think about Oracle SQL Developer?
A collection of 22 FAQs on PL/SQL language basics or DBA and developers. It can also be used as learning tutorials on defining variables, assigning values, using "loop" statements, setting "if" conditions, and working with null values.
  1. Is PL/SQL Language Case Sensitive?
  2. How To Enter Comments in PL/SQL?
  3. What Are the Types of PL/SQL Code Blocks?
  4. What Is an Anonymous Block?
  5. What Is a Named Program Unit?
  6. What Is a Procedure?
  7. What Is a Function?
  8. How To Declare a Local Variable?
  9. How To Initialize Variables with Default Values?
  10. How To Assign Values to Variables?
  11. What Are the Arithmetic Operations?
  12. What Are the Numeric Comparison Operations?
  13. What Are the Logical Operations?
  14. How Many Categories of Data Types?
  15. How Many Scalar Data Types Are Supported in PL/SQL?
  16. How To Convert Character Types to Numeric Types?
  17. What Are the Execution Control Statements?
  18. How To Use "IF" Statements on Multiple Conditions?
  19. How To Use "WHILE" Loop Statements?
  20. How To Use "FOR" Loop Statements?
  21. What Is NULL in PL/SQL?
  22. How To Test NULL Values?
A collection of 26 FAQs on PL/SQL managing our own procedures. It can also be used as learning tutorials on creating procedures and functions, executing and dropping procedures, passing actual parameters to formal parameters, making optional parameters.
  1. What Is a Procedure?
  2. What Is a Function?
  3. How To Define an Anonymous Procedure without Variables?
  4. How To Define an Anonymous Procedure with Variables?
  5. How To Create a Stored Procedure?
  6. How To Execute a Stored Procedure?
  7. How To Drop a Stored Procedure?
  8. How To Pass Parameters to Procedures?
  9. How To Create a Stored Function?
  10. How To Call a Stored Function?
  11. How To Drop a Stored Function?
  12. How To Call a Stored Function with Parameters?
  13. How To Define a Sub Procedure?
  14. How To Call a Sub Procedure?
  15. How To Define a Sub Function?
  16. Can Sub Procedure/Function Be Called Recursively?
  17. What Happens If Recursive Calls Get Out of Control?
  18. What Is the Order of Defining Local Variables and Sub Procedures/Functions?
  19. What Is the Difference between Formal Parameters and Actual Parameters?
  20. What Are the Parameter Modes Supported by PL/SQL?
  21. How To Use "IN" Parameter Properly?
  22. How To Use "OUT" Parameter Properly?
  23. How To Use "IN OUT" Parameter Properly?
  24. How To Define Default Values for Formal Parameters?
  25. What Are Named Parameters?
  26. What Is the Scope of a Local Variable?
A collection of 23 FAQs on working with database objects in PL/SQL. Clear answers are provided with tutorial exercises on running DML statements, assign table data to variables, using the implicit cursor, defining and using RECORDs with table rows.
  1. Can DML Statements Be Used in PL/SQL?
  2. Can DDL Statements Be Used in PL/SQL?
  3. Can Variables Be Used in SQL Statements?
  4. What Happens If Variable Names Collide with Table/Column Names?
  5. How To Resolve Name Conflicts between Variables and Columns?
  6. How To Assign Query Results to Variables?
  7. Can You Assign Multiple Query Result Rows To a Variable?
  8. How To Invoke Built-in Functions in PL/SQL?
  9. How To Retrieve the Count of Updated Rows?
  10. What Is the Implicit Cursor?
  11. How To Assign Data of the Deleted Row to Variables?
  12. What Is a RECORD in PL/SQL?
  13. How To Define a Specific RECORD Type?
  14. How To Define a Variable of a Specific RECORD Type?
  15. How To Assign Values to Data Fields in RECORD Variables?
  16. How To Retrieve Values from Data Fields in RECORD Variables?
  17. How To Define a Data Field as NOT NULL?
  18. How To Define a RECORD Variable to Store a Table Row?
  19. How To Assign a Table Row to a RECORD Variable?
  20. How To Insert a RECORD into a Table?
  21. How To Update a Table Row with a RECORD?
  22. How To Define a Variable to Match a Table Column Data Type?
A collection of 19 FAQs on working with database objects in PL/SQL. Clear answers are provided with tutorial exercises on defining, opening, and closing cursors, looping through cursors, defining and using cursor variables.
  1. What Is a Cursor?
  2. How Many Types of Cursors Supported in PL/SQL?
  3. What Is the Implicit Cursor?
  4. How To Use Attributes of the Implicit Cursor?
  5. How To Loop through Data Rows in the Implicit Curosr?
  6. How To Define an Explicit Cursor?
  7. How To Open and Close an Explicit Cursor?
  8. How To Retrieve Data from an Explicit Cursor?
  9. How To Retrieve Data from a Cursor to a RECORD?
  10. How To Use FETCH Statement in a Loop?
  11. How To Use an Explicit Cursor without OPEN Statements?
  12. Can Multiple Cursors Being Opened at the Same Time?
  13. How To Pass a Parameter to a Cursor?
  14. What Is a Cursor Variable?
  15. How To Define a Cursor Variable?
  16. How To Open a Cursor Variable?
  17. How To Loop through a Cursor Variable?
  18. How To Pass a Cursor Variable to a Procedure?
  19. Why Cursor Variables Are Easier to Use than Cursors?
A collection of 27 FAQs on Oracle loading data and exporting data. Clear answers are provided with tutorial exercises on saving data as flat files, loading data from flat, exporting and importing database, schema and tables, creating external tables.
  1. What Is the Simplest Tool to Run Commands on Oracle Servers?
  2. What Is the Quickest Way to Export a Table to a Flat File?
  3. How To Export Data with a Field Delimiter?
  4. What Is SQL*Loader?
  5. What Is a SQL*Loader Control File?
  6. How To Load Data with SQL*Loader?
  7. What Is an External Table?
  8. How To Load Data through External Tables?
  9. What Are the Restrictions on External Table Columns?
  10. What Is a Directory Object?
  11. How To Define an External Table in a Text File?
  12. How To Run Queries on External Tables?
  13. How To Load Data from External Tables to Regular Tables?
  14. What Is the Data Pump Export Utility?
  15. What Is the Data Pump Import Utility?
  16. How To Invoke the Data Pump Export Utility?
  17. How To Invoke the Data Pump Import Utility?
  18. What Are Data Pump Export and Import Modes?
  19. How To Estimate Disk Space Needed for an Export Job?
  20. How To Do a Full Database Export?
  21. Where Is the Export Dump File Located?
  22. How To Export Your Own Schema?
  23. How To Export Several Tables Together?
  24. What Happens If the Imported Table Already Exists?
  25. How To Import One Table Back from a Dump File?
  26. What Are the Original Export and Import Utilities?
  27. How To Invoke Original Export/Import Utilities?
A collection of 9 FAQs on Oracle ODBC drivers and connections. Clear answers are provided with tutorial exercises on installing Oracle ODBC drivers; TNS settings; defining DSN entries; connecting MS Access or ASP pages to Oracle servers.
  1. What Is Open Database Communication (ODBC)?
  2. How To Install Oracle ODBC Drivers?
  3. How To Find Out What Oracle ODBC Drivers Are Installed?
  4. How Can Windows Applications Connect to Oracle Servers?
  5. How To Create Tables for ODBC Connection Testing?
  6. How To Verify Oracle TNS Settings?
  7. How To Define a Data Source Name (DSN) in ODBC Manager?
  8. How To Connect MS Access to Oracle Servers?
  9. How To Connect ASP Pages to Oracle Servers?

Creating Simple REST WebServices using Netbeans

Java WebService Tutorial - Part 11 (Writing Simple REST WebService using Netbeans & GlassFish)


In this part we will see how to write a Simple REST Style Web Service using NetBeans and GlassFish Server Server and we will test the service.

Requirements:

1. NetBeans ID
2. GlassFish Server.

Usually NetBeans comes along with the GlassFish Server and also in build support for generating REST Services using the Jersey Framework.
So , once we have installed the NetBeans ID and GlassFish we can create our first webservice now.

Note : This is a quick guide of creating REST using Jersey Framework, we are not going in detail about the annotations we are using in the REST Webservice , we will discuss the basic annotation right now ,in later part we will cover in detail about each annotations with respective example.
Step 1:

Open NetBeans ID.

File-->New ---> New Project --> Java Web-->Web Application and click the "Next" Button.

Give a name to the Project say "MyFirstREST" (I am using this name here for this example) and click the "Next"Button.

Select the Server as "GlassFish Server" and select the J2EE Version as "Java EE 5" click the "Finish"Button.
So , now our project folders are created .













Step 2:

Creating Package.

Right click on the Project Node "MyFirstREST" and select :

New ---> Java Package and give name as "com.test" (You can provide your own name for this example i am using this name)
Now we have a package where all our service class will be kept.

Step 3:

Writing the REST Business Logic.

 There are couple of annotations i liked to discussed here, these are the very basic and commonly used annotations.

@Path  -- Mention the Path from which you want to access a REST Service either class level or method level.

@GET -- Performs HTTP get Operation useful for getting info read only.

@Produces - This Produces the Respective output in different format such as XML,JSON,TEXT,HTML etc to the client.
Step 4:

Implementing the Jersey Framework & Writing our First REST Service 

NetBeans generally comes along with the Jersey Framework if you don't have the Framework install , manually you should have to download it and add the jars to the libraries.

But i am not going to discuss about that , i assume you all are smart guys , and you have NetBeans with J2EE Supported version , so basically you will have Jersey supported framework install in the NetBeans Itself.

So , We don't need actually write any code from implementing this frame work in web.xml, NetBeans automatically does for us., that's the advantage of using NetBeans.

So now this can achieve by following these steps :

Right click on the "com.test"(Package i am using for this example, you can use your own)ans select 

New--->Other--->WebService-->RESTful WebServices from Patterns.















Select patterns as "Simple Root Resource" and Press the "Next" Button















Give path Name as"MyPath" and class Name as"MypathResource" and select the MIME Type as "text/plain". and importantly select the check box for Jersey framework and click the "finish" Button.


















Step 5:

Develop the code.

By default a class name called "MypathResource" will be created with some methods and instance variable define in it.Delete the code and replace with the following code.

package com.test;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.PathParam;
import javax.ws.rs.Consumes;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
@Path("Mypath")
public class MypathResource {
    @GET
    @Produces("text/plain")
    public String getText() {
        return "My First RESTful Servivce....";
    }
}
This is the very basic and simplest RESTful Service , it will accept the Path "MyPath" in the URL and invoke the method getText which in turn return a Response as Text with the wording "My First RESTful Servivce..."
 
Step 6:

Clean & Build , Deploy to check the service.

Right Click on the Project Node "MyFirstREST" and select Clean and build this will clean the directory and compiles the Java files and  creates a WAR Archive.

Once , the Clean and build is finish successfully again RightClick on the ProjectNode "MyFirstREST" and select "Deploy".

Once the Deployment is done we can check the service by:
Right click on the REST Service created under folder called "Restful Web Service" and  select "Test Resource Uri"















or  we can directly access using the URL

Note : The Port Number will differ based upon your Server Configuration Setting.

Result :
















Main Components :

How all these is happening ?

The main Gate Keeper or the main Servlet for this is specified in the web.xml which performs the Jersey Mechanism , Please refer the image below for detail explanation of Jersey Servlet define in web.xml .























That's all for the day, In the Next Section we will be seeing different useful annotations and how to produce different form of Outputs.


Thanks for Reading.
Please provide your valuable suggestion and comments.



<< Prev                                   Index                                         Next>>

-----------------------------------------------------------------------------------------------