One common use of patterns in awk is for simple data validation task. Specially in ETL process, you can use it for source data cleansing.
In shell scripting, usually =~ operator is used for regular expression matching. There is a nice guide for advance shell script. Point 17 describes regular expression.
But in awk command ~ is used for matching. Suppose we want to filter a file which contains line delimited by "|" and print only those line whose second column contains "*8999*". So the awk command will be -
$ awk -F '|' 'if(($2 ~ "\*8999\*")){print NR,"|",$0;}}' $file
Thus, you can validate data using awk command. This is one of the great feature of awk command.
Monday, October 12, 2009
Saturday, September 12, 2009
Reset password in oracle
At first log in the server where oracle is installed using administrative account of the OS. Then set the ORACLE_SID user variable to the name of database service. So, if your database service name is orcl, then set the variable ORACLE_SID to value orcl. Then -
Log in sqlplus from command prompt of the server using the following command-
sqlplus "/as sysdba"
now you are connected.
Then you can change sys password by the following command-
alter user sys identified by *******;
Thus your password is reset. Now you can connect by any client s/w of oracle.
Log in sqlplus from command prompt of the server using the following command-
sqlplus "/as sysdba"
now you are connected.
Then you can change sys password by the following command-
alter user sys identified by *******;
Thus your password is reset. Now you can connect by any client s/w of oracle.
Sunday, August 30, 2009
protocol configuration of .asmx webservice
The default protocol configuration of .asmx webservice is -
<webServices>
<protocols>
<clear />
<add name="HttpSoap12" />
<add name="HttpSoap" />
<add name="HttpPostLocalhost" />
<add name="Documentation" />
</protocols>
</webServices>
So it supports data & payload in soap envelope and documentation for all; but supports post only for localhost. Thus if we want to test a webservice using post method, we can test it only from localhost.
If we want to allow to invoke the webservice via get & post method we have to add the following under the system.web node -
<webServices>
<protocols>
<clear />
<add name="HttpSoap12" />
<add name="HttpSoap" />
<add name="HttpPostLocalhost" />
<add name="Documentation" />
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
Suppose you want to invoke a webmethod(MethodName which takes a parameter param) of a webservice(SomeService.asmx) using get method, then you need to hit the following url-
http://localhost/WebXmlHttpDemo/SomeService.asmx/MethodName?param=value
<webServices>
<protocols>
<clear />
<add name="HttpSoap12" />
<add name="HttpSoap" />
<add name="HttpPostLocalhost" />
<add name="Documentation" />
</protocols>
</webServices>
So it supports data & payload in soap envelope and documentation for all; but supports post only for localhost. Thus if we want to test a webservice using post method, we can test it only from localhost.
If we want to allow to invoke the webservice via get & post method we have to add the following under the system.web node -
<webServices>
<protocols>
<clear />
<add name="HttpSoap12" />
<add name="HttpSoap" />
<add name="HttpPostLocalhost" />
<add name="Documentation" />
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
Suppose you want to invoke a webmethod(MethodName which takes a parameter param) of a webservice(SomeService.asmx) using get method, then you need to hit the following url-
http://localhost/WebXmlHttpDemo/SomeService.asmx/MethodName?param=value
Wednesday, July 15, 2009
batch update on a table from another table
CREATE TABLE A
(
NAME VARCHAR2(20 BYTE),
AGE INTEGER
)
CREATE TABLE B
(
NAME VARCHAR2(20 BYTE),
AGE INTEGER
)
Suppose we need to update the age of table B with the age of table A.
For oracle the command will be -
UPDATE tmp_B b
SET age = (SELECT a.age FROM tmp_A a WHERE a.name = b.name)
where b.name in (select a.name from tmp_A a);
Oracle also support n-ordered tuple. So if you want to update all row in a single run, the following command is also valid -
UPDATE tmp_B b
SET (age,name) = (SELECT a.age, a.name FROM tmp_A a WHERE a.name = b.name);
For MS Sql Server the command will be-
update tmp_B
set tmp_B.age=tmp_A.age
from tmp_A,tmp_B where tmp_A.name=tmp_B.name;
(
NAME VARCHAR2(20 BYTE),
AGE INTEGER
)
CREATE TABLE B
(
NAME VARCHAR2(20 BYTE),
AGE INTEGER
)
Suppose we need to update the age of table B with the age of table A.
For oracle the command will be -
UPDATE tmp_B b
SET age = (SELECT a.age FROM tmp_A a WHERE a.name = b.name)
where b.name in (select a.name from tmp_A a);
Oracle also support n-ordered tuple. So if you want to update all row in a single run, the following command is also valid -
UPDATE tmp_B b
SET (age,name) = (SELECT a.age, a.name FROM tmp_A a WHERE a.name = b.name);
For MS Sql Server the command will be-
update tmp_B
set tmp_B.age=tmp_A.age
from tmp_A,tmp_B where tmp_A.name=tmp_B.name;
Friday, July 3, 2009
Tuesday, June 30, 2009
Consume webservice From JavaScript
1. Add an asp:ScriptManager in form of the aspx page.
2. Add the service that you want to access in the script manager tag.
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/ZipCodeService.asmx" />
</Services>
</asp:ScriptManager>
here ZipCodeService.asmx is the path of the web service. In this case the web service resides in the same project. If this does not reside in the same project then add web reference.
3. Ensure that the web service added can be invoked from script. In case of .net, this is ensured by adding the following attribute to the class of the web service.
In ZipCodeService, this is ensured by -
[System.Web.Script.Services.ScriptService]
public class ZipCodeService : System.Web.Services.WebService
{
. . .
}
4. Now this web service is eligible to call from JavaScript. So call the webmethod of web service with full namespace name.
For detail please visit here
2. Add the service that you want to access in the script manager tag.
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="~/ZipCodeService.asmx" />
</Services>
</asp:ScriptManager>
here ZipCodeService.asmx is the path of the web service. In this case the web service resides in the same project. If this does not reside in the same project then add web reference.
3. Ensure that the web service added can be invoked from script. In case of .net, this is ensured by adding the following attribute to the class of the web service.
In ZipCodeService, this is ensured by -
[System.Web.Script.Services.ScriptService]
public class ZipCodeService : System.Web.Services.WebService
{
. . .
}
4. Now this web service is eligible to call from JavaScript. So call the webmethod of web service with full namespace name.
For detail please visit here
Subscribe to:
Posts (Atom)