Friday, September 26, 2014

Reloading image in Word Document automatically.

There are certain instances where a single picture is used in multiple documents. When this picture changes, all the documents has to be updated manually every time. The purpose of the document is to list down the steps to upload a picture and import it from a specified location. Whenever there is a change in the picture, the same will be reflected into all the documents automatically when the document is opened.

The below are the steps to be followed
  • Upload a picture in a specified location. For ex: - Sharepoint.
  • Open a word document where the picture has to be inserted.
  • Navigate to Insert-->Quick Parts-->Field as shown below
  • Once the field is clicked, the below options are displayed.

a.       On the right hand side, select “IncludePicture”
b.      Enter the URL where the image is uploaded.
c.       Check the checkbox “Data not stored with Document”.

  • Click Ok. Now the image will display in the document.
  • Save and close the document.
  • Now, try to change the image in the Sharepoint, with the same naming convention. In this example “Microsoft.jpg” and open the document. You will see the new image in place of old one without modifying the document.
  • You can try yourself and check it out. :)

Monday, April 7, 2014

PL/SQL Block Structure

The smallest meaningful grouping of code is known as a block. A block is a unit of code that provides execution and scoping boundaries for variable declarations and exception handling.
PL/SQL allows you to create anonymous blocks (blocks of code that have no name) and named blocks, which may be packages, procedures, functions, triggers, or object types.

A PL/SQL block has up to four different sections, only one of which is mandatory:



Example:-

--Header Section
PROCEDURE myFirstProcedure(NAME IN Varchar2)
IS

--Declaration Section
SALARY NUMBER;
JOINING_DATE DATE;

BEGIN
--Execution Section
INSERT INTO EMPLOYEE
(emp_name, salary, joining_date)
VALUES
(name, salary, joining_date);

EXCEPTION
--Exception Section
WHEN DUP_VAL_IN_INDEX
THEN
DBMS_OUTPUT.PUT_LINE ("Duplicate Value, Cannot Insert.");

END;
/

Thursday, March 27, 2014

SQL*Plus Tasks - SPOOL command

You want to save output from a SQL*Plus session to a file to get record of your actions, or because you are dynamically generating commands to execute later. This can be done in SQL*Plus with the help of SPOOL command:

SQL> SPOOL report.txt
SQL> @run_report.sql
...output scrolls past and gets written to the file report.txt...
SQL> SPOOL OFF

The first command, SPOOL report, tells SQL*Plus to save everything from that point forward into the file report.txt. The file extension of .lst is the default and can be overridden by supplying your own extension in the SPOOL command like specified above.

SPOOL OFF tells SQL*Plus to stop saving the output and to close the file.

SQL*Plus Tasks - DEFINE Keyword

SQL*Plus can also create and manipulate its own in-memory variables, and it sets aside a few special variables that will affect its behavior. Actually, there are two separate types of variables in SQL*Plus: DEFINEs and bind variables. To assign a value to a DEFINE variable, you can use the DEFINE command:

SQL> DEFINE X = "UMASARATH"

To view the value of x, specify:

SQL> DEFINE X
DEFINE X               = "UMASARATH" (CHAR)
SQL>

You would refer to such a variable using an ampersand (&). SQL*Plus does a simple substitution before sending the statement to the Oracle database, so you will need single-quote marks around the variable when you want to use it as a literal string.

SQL> select '&x' from dual;
old   1: select '&x' from dual
new   1: select 'UMASARATH' from dual

'UMASARAT
---------
UMASARATH

SQL>

Saturday, February 22, 2014

The javax.servlet Package

The javax.servlet package contains a number of interfaces and classes that establish the framework in which servlets operate. The most significant of these is Servlet. All servlets must implement this interface or extend a class that implements the interface

Interface
Description
Servlet
Declares life cycle methods for a servlet.
ServletConfig
Allows servlets to get initialization parameters
ServletContext
Enables servlets to log events and access information about their environment.
ServletRequest
Used to read data from a client request.
ServletResponse
Used to write data to a client response.

The following table summarizes the core classes that are provided in the javax.servlet package:

Class
Description
GenericServlet
Implements the Servlet and ServletConfig interfaces.
ServletInputStream
Provides an input stream for reading requests from a client.
ServletOutputStream
Provides an output stream for writing responses to a client.
ServletException
Indicates a servlet error occurred.
UnavailableException
Indicates a servlet is unavailable.


The Servlet Interface

  1. All servlets must implement the Servlet interface.
  2. It declares the init( ), service( ), and destroy( ) methods that are called by the server during the life cycle of a servlet.
  3. A method is also provided that allows a servlet to obtain any initialization parameters.
    1. Void destroy()
    2. ServletConfig getServletConfig()
    3. String getServletInfo()
    4. Void init(ServletConfig sc) throws ServletException
    5. Void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
  4. The init( ), service( ), and destroy( ) methods are the life cycle methods of the servlet. These are invoked by the server. The getServletConfig( ) method is called by the servlet to obtain initialization parameters. A servlet developer overrides the getServletInfo( ) method to provide a string with useful information (for example, author, copyright etc)

The ServletConfig Interface

The ServletConfig interface allows a servlet to obtain configuration data when it is loaded. Here are some methods

  1. ServletContext getServletContext( )
  2. String getInitParameter(String param)
  3. Enumeration getInitParameterNames( )
  4. String getServletName( )

The ServletContext Interface

The ServletContext interface enables servlets to obtain information about their environment. Here are some methods

  1. Object getAttribute(String attr)
  2. String getMimeType(String file)
  3. String getRealPath(String vpath)
  4. String getServerInfo( )
  5. void setAttribute(String attr, Object val)




Servlet API

Two packages contain the classes and interfaces that are required to build servlets.
  1. javax.servlet
  2. javax.servlet.http
These packages are the standard extensions provided by Tomcat. Hence, these are not included in Java 6.

Please follow the links for more information.

Sunday, February 9, 2014

Apache Maven - How To Enable Proxy Setting

There might be a chance in your company is that a firewall is set up a and an HTTP proxy server to stop user to connect to internet directly. If you are behind a proxy, Maven will fail to download any dependencies.
To make it work, you have to declare the proxy server setting in Maven configuration file settings.xmlIt can be found in conf directory, i.e.,  {M2_HOME}/conf/settings.xml.
{M2_HOME}/conf/settings.xml
<!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>
Un-comment the proxy options and fill in your proxy server detail and save it.

Done, your Apache Maven should be able to connect to the Internet via your proxy server now. Restart is NOT required as Maven is just a command, when you call it, it will read this file again.