Monday, April 2, 2012

How to update XML attribute, stored in SQL Table

Let say you have an XML stored in your Table.
You would like to update a particular attribute
using a stored procedure. To so the same follow below steps.

*******************************************************
Run below script in your SQL query analyzer
*******************************************************

--lets say I have Stored procedure as below.

Alter PROCEDURE updateFileTable
(
@file NVARCHAR(100),
@public NVARCHAR(100),
@fileTypeId NVARCHAR(100)
)
AS

-- Step 1 - Creating a Temporary table.
CREATE TABLE #FileTable
(
cFileName XML,
)
-- Step 2 - Inserting the test data give by you.

INSERT INTO #FileTable
([cFileName])
VALUES
(''+
''+
''+
'
')

----------------------------
PRINT 'Before Update'
SELECT * FROM #FileTable
----------------------------

--Step 3 - Updating the data.
-- here, in just tje below line the last 1 signifies that the while condition has returned true, and only then the update will take place

WHILE EXISTS (SELECT * FROM #FileTable WHERE cFileName.exist('/Files//File/@FileID[.=sql:variable("@file")]') = '1')
UPDATE #FileTable
SET cFileName.modify('replace value of (/Files//File/@FileID[.="1"])[1] with "10"')

----------------------------
PRINT 'After Update'
SELECT * FROM #FileTable
----------------------------

DROP table #FileTable

*******************************************************
Now EXECUTE the Stored PROCEDURE USING below STATEMENT.
*******************************************************

EXEC updateFileTable '1','false','9'

Tuesday, March 20, 2012

Linking the XSL Style Sheet to the XML Document



Using this approach, you do not need any code behind to have an
transformation for your only client side requirement.
Save following two files in your C:\SomeFolder

File1 - Home.xml

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="UseMeToTransform.xsl"?>
<Root>
<Item>
<cat>1</cat>
<Name>Car</Name>
</Item>
<Item>
<cat>2</cat>
<Name>Bike</Name>
</Item>
<Item>
<cat>3</cat>
<Name>Boat</Name>
</Item>
</Root>

File2 - UseMeToTransform.xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="Root">
<html>
<table border="1">
<tr>
<td>
<xsl:value-of select="'Category'"/>
</td>
<td>
<xsl:value-of select="'Name'"/>
</td>
</tr>
<xsl:for-each select="Item">
<tr>
<td>
<xsl:value-of select="cat"/>
</td>
<td>
<xsl:value-of select="Name"/>
</td>
</tr>
</xsl:for-each>
</table>
</html>
</xsl:template>
</xsl:stylesheet>

Now double click onthe Home.xml files you will get the desired output.
Where you can see that the date of Home.xml has been converted in to HTML contents.

Tuesday, December 6, 2011

How (QA Tester) frustrates developer :)

How Roshan D'Mello (QA Tester) frustrates developer (Mukesh Thakur)

Roshan D'Mello: Hey Mukesh, there is a bug in your code. Type a text in user name text box and press enter. Beep sound doesn't appear.

Mukesh Thakur: How can that be a bug? There is no requirement that beep sound should come. Anyway, I will assign it to offshore and get it fixed.



After 2 days,

Mukesh Thakur: Roshan, bug is fixed. Please verify.


After another 2 days,

Roshan D'Mello: I have re-opened the bug because sound is not coming in some PCs. Sound is coming in my machine, but my colleague Rajat Choudhry is not getting the sound.


After another 2 days,

Mukesh Thakur: Not a bug. I observed that your friend Rajat Choudhry has old IBM machine. Unlike your DELL machine, IBM machines do not have inbuilt speakers. So, to hear the sound in Rajat Choudhry's machine, please use head phones and then get the bug closed soon.


Another 2 days,

Roshan D'Mello: I have re-opened the bug because sound tone is different across different machines. Sound is coming as 'BEEP' in my machine, but my colleague Rajat Choudhry who is having IBM machine is getting the sound as 'TONG'.

Mukesh Thakur: Not a bug. Get lost man. What can we do for the bug? The two machines are built in such a way that they produce different sounds. Do you expect the developers to rebuild the IBM processors to make them uniform? Please close it.


Another 2 days,

Roshan D'Mello: I have re-opened the bug because intensity of beep sound produced on 2 different DELL machines is different. My machine produces beep sound of intensity 10 decibels whereas my friend's machine produces sound worth 20 decibels. Fix your code to make the sound uniform across all machines.


Another 2 days later,

Mukesh Thakur: Once again it is not a bug. I have noticed that the volume set is different on the two machines. Ensure that volume is same in both the machines before I get mad and then close the bug.


Another 2 days,

Roshan D'Mello: I have re-opened the bug.

Mukesh Thakur: What ?? Why? What more stupid reasons can be there for re-opening?

Roshan D'Mello: Sound intensity is different for machines placed at different locations (different buildings). So, I have re-opened it.


After 2 days,

Mukesh Thakur: I have made some scientists do an acoustical analysis of the two buildings you used for testing. They have observed that the acoustics in the two buildings varies to a large extent. That is why sound intensity is different across the 2 buildings. So, I beg you to please close the bugs.


After 1 year

Roshan D'Mello: I am re-opeing the bug. During the year, I requested the clients to arrange architects to build two buildings with same acoustical features, so that I can test it again. Now, when I tested, I found that intensity of sound still varying. So, I am re-opening the defect.

Mukesh Thakur: GROWLLLL.....I am really mad now. I am sure that the sound waves of the two buildings are getting distorted due to some background noice or something. Now I need to waste time to prove that it is because of background noice.

Roshan D'Mello: No need for that. We will put the machines and run them in vacuum and see.

Mukesh Thakur: (not alive)

Thursday, August 18, 2011

Support ANNA HAZARE… Now or Never….



Support ANNA HAZARE… Now or Never….

Summary of All scams of India : Rs. 910603234300000/-


See how Lokpal Bill can curb the politicians, Circulate it to create awareness

Existing System
System Proposed by civil society

No politician or senior officer ever goes to jail despite huge evidence because Anti Corruption Branch (ACB) and CBI directly come under the government. Before starting investigation or prosecution in any case, they have to take permission from the same bosses, against whom the case has to be investigated.
Lokpal at centre and Lokayukta at state level will be independent bodies. ACB and CBI will be merged into these bodies. They will have power to initiate investigations and prosecution against any officer or politician without needing anyone’s permission. Investigation should be completed within 1 year and trial to get over in next 1 year. Within two years, the corrupt should go to jail.

No corrupt officer is dismissed from the job because Central Vigilance Commission, which is supposed to dismiss corrupt officers, is only an advisory body. Whenever it advises government to dismiss any senior corrupt officer, its advice is never implemented.
Lokpal and Lokayukta will have complete powers to order dismissal of a corrupt officer. CVC and all departmental vigilance will be merged into Lokpal and state vigilance will be merged into Lokayukta.

No action is taken against corrupt judges because permission is required from the Chief Justice of India to even register an FIR against corrupt judges.
Lokpal & Lokayukta shall have powers to investigate and prosecute any judge without needing anyone’s permission.

Nowhere to go - People expose corruption but no action is taken on their complaints.
Lokpal & Lokayukta will have to enquire into and hear every complaint.

There is so much corruption within CBI and vigilance departments. Their functioning is so secret that it encourages corruption within these agencies.
All investigations in Lokpal & Lokayukta shall be transparent. After completion of investigation, all case records shall be open to public. Complaint against any staff of Lokpal & Lokayukta shall be enquired and punishment announced within two months.

Weak and corrupt people are appointed as heads of anti-corruption agencies.
Politicians will have absolutely no say in selections of Chairperson and members of Lokpal & Lokayukta. Selections will take place through a transparent and public participatory process.

Citizens face harassment in government offices. Sometimes they are forced to pay bribes. One can only complaint to senior officers. No action is taken on complaints because senior officers also get their cut.
Lokpal & Lokayukta will get public grievances resolved in time bound manner, impose a penalty of Rs 250 per day of delay to be deducted from the salary of guilty officer and award that amount as compensation to the aggrieved citizen.

Nothing in law to recover ill gotten wealth. A corrupt person can come out of jail and enjoy that money.
Loss caused to the government due to corruption will be recovered from all accused.

Small punishment for corruption- Punishment for corruption is minimum 6 months and maximum 7 years.
Enhanced punishment - The punishment would be minimum 5 years and maximum of life imprisonment.




Dear All, Please go through the details carefully & try to be part of this mission against corruption. Things to know about Anna Hazare and Lok pal Bill-:

1.Who is Anna Hazare?

An ex-army man(Unmarried). Fought 1965 Indo-Pak war.


2.What's so special about him?

He built a village Ralegaon Siddhi in Ahamad Nagar district, Maharashtra.


3.This village is a self-sustained model village. Energy is produced in the village itself from solar power, biofuel and wind mills. In 1975, it used to be a poverty clad village. Now it is one of the richest village in India. It has become a model for self-sustained, eco-friendly & harmonic village. 4. This guy, Anna Hazare was awarded Padma Bhushan and is a known figure for his social activities.


5. He is supporting a cause, the amendment of a law to curb corruption in India.


6. How that can be possible?

He is advocating for a Bill, The Lok Pal Bill (The Citizen Ombudsman Bill), that will form an autonomous authority who will make politicians (ministers), bureaucrats (IAS/IPS) accountable for their deeds.


7. It's an entirely new thing right..?

In 1972, the bill was proposed by then Law minister Mr. Shanti Bhushan. Since then it has been neglected by the politicians and some are trying to change the bill to suit their theft (corruption).


8. Oh.. He is going on a hunger strike for that whole thing of passing a Bill ! How can that be possible in such a short span of time? The first thing he is asking for is: the govt should come forward and announce that the bill is going to be passed. Next, they make a joint committee to DRAFT the LOK PAL BILL. 50% government participation and 50% public participation. Bcoz u can't trust the government entirely for making such a bill which does not suit them.


9.What will happen when this bill is passed?

A LokPal will be appointed at the centre. He will have an autonomous charge, say like the Election Commission of India. In each and every state, Lokayukta will be appointed. The job is to bring all alleged party to trial in case of corruptions within 1 year. Within 2 years, the guilty will be punished.


Pass this on n show ur support..



Spread it like fire; Our Nation needs us... Please Contribute... This is not just a forward, it’s the future of our Nation.



Contributed by Kavita Sharma



Just by Saying that the Indian System is bad,we cannot change the system..Inorder to change the system we all need to support and fight against it

Saturday, July 17, 2010

LETTER To BOSS...

A Boss looking through his Mail Box was astonished to see a mail from an Employee who was supposed to be busy working at Client side on a critical project. It had the subject - "TaTa - Bye Bye". With the worst premonition he opened the mail and read the content with trembling hands:-


Dear Sir,


It is with great regret and sorrow that I'm writing you, but I'm leaving the job. The offer was too lucrative and attractive for me to turn down. I had to abscond because I wanted to avoid a scene with the HR and you. I am sorry but I had no choice.


The project is working fine. There are only 108 isuses pending, out of which only 38% issues are High Priority. Hence I am sure there is no need to worry about. The next Phase of major enhancements I have been working upon, have been completed halfway. I am sure the new person who would replace me would not understand what all I had done so far. Hence, for his and your convenience, I have taken care to remove all the work that I had been doing this far for nearly 3 months now.


I am sure you will appreciate my insight and "big heart". I am ofcourse retaining the Originals that I had retrieved for the purpose of Passport verification with me, considering it as a parting gift from you. Ofcourse, I will not pay the bond amount that I owe the compnay (since I Am breaking the bond). But I will consider this as a parting gift from our Dear company. I moving out of town since the new company is situated in another City.


Also, I have changed my contact number. So you will not be able to get in touch with me, to congratulate me. But I know your blessings are always with me. Last but not the least. I also have the 7000 Rs entrusted to me by our company's cultural events group, for the upcoming movie event. I am sure you would have wanted me to keep it with myself as an added bonus from our company. I respect you very much, hence your wish is my command.


I thank you for that in advance, and assure you that I will surely invest them wisely (but not in your company's stocks of course).


Don't worry sir. I am 2 years experienced now, learning so much from your company. So I will surely use this knowledge to write better programs for the new company.


Someday I'm sure we will meet sometime in the future. If you wish, I will surely be glad to give my employee reference for you to apply for a job in the new company which I am joining.


Your faithful employee,


S. W. Engineer


At the bottom of the page were the letters "PS". Hands still trembling,


the Boss read:


PS: Dearest Boss, none of the above is true. I'm am still busy working at client side. I just wanted to remind you that there are worse things in life than my "Request to reconsider my Salary Appraisal" attached with this mail. Please approve it and call when it is safe for me to come to our Office to discuss this. My respect and Best Regards to you!

LAW OF THE GARBAGE TRUCK - Let the garbage go by.

How often do you let other people's nonsense change your mood? Do you let a bad driver, rude waiter, curt boss, or an insensitive employee
ruin your day? Unless you're the Terminator, for an instant you're probably set back on your heels.
However, the mark of a successful person is how quickly she can get back her focus on what's important.
Sixteen years ago I learned this lesson. I learned it in the back of a New York City taxi cab. Here's what happened.

I hopped in a taxi, and we took off for Grand Central Station. We were driving in the right lane when all of a sudden, and I mean
without warning, a black car jumped out of a parking space right in front of us. My taxi driver slammed on his brakes, skidded and missed
the other car's back end by just inches.

Here's what happened next. The driver of the other car, the guy who almost caused a big accident, whipped his head around and he started
yelling bad words at us. How do I know? Ask any New Yorker, some words in New York come with a special face.

Now, here's what blew me away. My taxi driver just smiled and waved at the guy. And I mean, he was friendly.
So, I said, "Why did you just do that? This guy almost ruined your car and sent us to the hospital!" And this is when my taxi
driver told me what I now call, "The Law of the Garbage Truck."

Many people are like garbage trucks. They run around full of garbage, full of frustration, full of anger, and full of disappointment.
As their garbage piles up, they need a place to dump it. And if you let them, they'll dump it on you.

When someone wants to dump on you, don't take it personally. You just smile, wave, wish them well, and move on.
You'll be happy you did. I guarantee it.

So this was it: The "Law of the Garbage Truck." I started thinking, how often do I let Garbage Trucks run right over me?
And how often do I take their garbage and spread it to other people: at work, at home, on the streets?
It was that day I said, "I'm not going to do it anymore."

Well now "I see Garbage Trucks." I see the load they're carrying. I see them coming to drop it off.
And like my Taxi Driver, I don't make it a personal thing; I just smile, wave, wish them well, and I move on.

One of my favorite Football players of all time, Walter Payton, did this every day on the football field. He would jump up as quickly as
he hit the ground after being tackled. He never dwelled on a hit. Payton was ready to make the next play his best. Good leaders know
they have to be ready for their next meeting. Good parents know that they have to welcome their children home from school with hugs and
kisses.

Leaders and parents know that they have to be fully present, and at their best for the people they care about.

The bottom line is that successful people do not let Garbage Trucks take over their day. What about you? What would happen in your life,
starting today, if you let more garbage trucks pass by you?

Here's my bet. You'll be happier. I guarantee it.

By David J. Pollay