RE: [OT] How to transpose a table in MS SQL Server 2000

2005-04-08 Thread Paul McCulloch
Assuming that month, val1 & val2 are the *names* of columns this is going to
be a tricky problem to solve with just SQL. You need to query the system
tables to extract the names of the columns.

The other problem is that the number of columns in your result set needs to
vary depending on the number of rows in your source data.

The only way I could solve this would be procedurally using TransactSQL
(create a temp table, populate it & select from it).

Paul

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: 08 April 2005 16:12
> To: Struts Users Mailing List
> Subject: RE: [OT] How to transpose a table in MS SQL Server 2000
> 
> 
> id/ID are synthetic keys and can be ignored (as well as 
> 'total').  So, the 
> simplified case is:
> 
> source_table
> -
> month   val1val2
> jan 1   2
> feb 3   4
> 
> target_target
> -
> VAL COL1COL2
> month   jan feb
> val11   3 
> val22   4
> 
> Thanks,
> Dennis
> 
> 
> 
> 
> 
> Paul McCulloch <[EMAIL PROTECTED]> 
> 04/08/2005 10:47 AM
> Please respond to
> "Struts Users Mailing List" 
> 
> 
> To
> 'Struts Users Mailing List' 
> cc
> 
> Subject
> RE: [OT]  How to transpose a table in MS SQL Server 2000
> 
> 
> 
> 
> 
> 
> I don't 100% understand your tables. Where does ID come from 
> (the values 1 
> &
> 2 exist in the first view, but 1,2,3,4 in the second).
> 
> Are the totals derived?
> 
> Give me the SQL for the first view and I'll have a look.
> 
> Paul
> 
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]
> > Sent: 08 April 2005 14:46
> > To: Struts Users Mailing List
> > Subject: [OT] How to transpose a table in MS SQL Server 2000
> > 
> > 
> > So, I have the following table:
> > 
> > id  month   val1val2total
> > 1   jan 1   2   3
> > 2   feb 3   4   7
> > 
> > And I'd like it transformed to:
> > 
> > ID  VAL COL1COL2
> > 1   month   jan feb
> > 2   val11   3 
> > 3   val22   4
> > 4   total   3   7
> > 
> > I'm guessing that it's possible, as I've seen variants of 
> > this type of 
> > tranformation.  I have googled this, but the solutions (I've 
> > found) are 
> > considerably more complicated and revolve around 
> > summing/aggregating, when 
> > I just need to change the structure of the results. 
> > 
> > Has anybody seen a solution that fits this problem?
> > 
> > Thanks,
> > Dennis
> > 
> > 
> > 
> > 
> > [EMAIL PROTECTED] 
> > 04/08/2005 09:26 AM
> > Please respond to
> > "Struts Users Mailing List" 
> > 
> > 
> > To
> > "Struts Users Mailing List" 
> > cc
> > 
> > Subject
> > [OT] RE: concurrency problem
> > 
> > 
> > 
> > 
> > 
> > 
> > As I hit the send button, something tickled in the back of my 
> > mind, and I 
> > began to remember that the spec forbids thread primitiives on 
> > bean methods 
> > 
> > and that the EJB container is responsible for handling 
> > concurrent access. 
> > Sounds like your provider might have a defect.
> > 
> > Dennis
> > 
> > 
> > 
> > 
> > 
> > [EMAIL PROTECTED] 
> > 04/08/2005 09:13 AM
> > Please respond to
> > "Struts Users Mailing List" 
> > 
> > 
> > To
> > "Struts Users Mailing List" 
> > cc
> > 
> > Subject
> > RE: concurrency problem
> > 
> > 
> > 
> > 
> > 
> > 
> > You're synchronizing on an object which is unique for each 
> > user, which 
> > might explain why more than 1 thread can concurrently enter 
> > the critsec. 
> > Wouldn't a better solution be to declare the method as synchronized?
> > 
> > Dennis
> > 
> > 
> > 
> > 
> > 
> > "Kalra, Ashwani" <[EMAIL PROTECTED]> 
> > 04/08/2005 08:53 AM
> > Please respond to
> > "Struts Users Mailing List" 
> > 
> > 
> > To
> > "Struts Users Mailing List" 
> > cc
> > 
> > Subject
> > RE: concurrency problem

RE: [OT] How to transpose a table in MS SQL Server 2000

2005-04-08 Thread DGraham
id/ID are synthetic keys and can be ignored (as well as 'total').  So, the 
simplified case is:

source_table
-
month   val1val2
jan 1   2
feb 3   4

target_target
-
VAL COL1COL2
month   jan feb
val11   3 
val22   4

Thanks,
Dennis





Paul McCulloch <[EMAIL PROTECTED]> 
04/08/2005 10:47 AM
Please respond to
"Struts Users Mailing List" 


To
'Struts Users Mailing List' 
cc

Subject
RE: [OT]  How to transpose a table in MS SQL Server 2000






I don't 100% understand your tables. Where does ID come from (the values 1 
&
2 exist in the first view, but 1,2,3,4 in the second).

Are the totals derived?

Give me the SQL for the first view and I'll have a look.

Paul

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: 08 April 2005 14:46
> To: Struts Users Mailing List
> Subject: [OT] How to transpose a table in MS SQL Server 2000
> 
> 
> So, I have the following table:
> 
> id  month   val1val2total
> 1   jan 1   2   3
> 2   feb 3   4   7
> 
> And I'd like it transformed to:
> 
> ID  VAL COL1COL2
> 1   month   jan feb
> 2   val11   3 
> 3   val22   4
> 4   total   3   7
> 
> I'm guessing that it's possible, as I've seen variants of 
> this type of 
> tranformation.  I have googled this, but the solutions (I've 
> found) are 
> considerably more complicated and revolve around 
> summing/aggregating, when 
> I just need to change the structure of the results. 
> 
> Has anybody seen a solution that fits this problem?
> 
> Thanks,
> Dennis
> 
> 
> 
> 
> [EMAIL PROTECTED] 
> 04/08/2005 09:26 AM
> Please respond to
> "Struts Users Mailing List" 
> 
> 
> To
> "Struts Users Mailing List" 
> cc
> 
> Subject
> [OT] RE: concurrency problem
> 
> 
> 
> 
> 
> 
> As I hit the send button, something tickled in the back of my 
> mind, and I 
> began to remember that the spec forbids thread primitiives on 
> bean methods 
> 
> and that the EJB container is responsible for handling 
> concurrent access. 
> Sounds like your provider might have a defect.
> 
> Dennis
> 
> 
> 
> 
> 
> [EMAIL PROTECTED] 
> 04/08/2005 09:13 AM
> Please respond to
> "Struts Users Mailing List" 
> 
> 
> To
> "Struts Users Mailing List" 
> cc
> 
> Subject
> RE: concurrency problem
> 
> 
> 
> 
> 
> 
> You're synchronizing on an object which is unique for each 
> user, which 
> might explain why more than 1 thread can concurrently enter 
> the critsec. 
> Wouldn't a better solution be to declare the method as synchronized?
> 
> Dennis
> 
> 
> 
> 
> 
> "Kalra, Ashwani" <[EMAIL PROTECTED]> 
> 04/08/2005 08:53 AM
> Please respond to
> "Struts Users Mailing List" 
> 
> 
> To
> "Struts Users Mailing List" 
> cc
> 
> Subject
> RE: concurrency problem
> 
> 
> 
> 
> 
> 
> 
> Isnt that valid when request is going to same action. In my scenario, 
> different actions are invoked quickly and all the actions 
> have this call 
> to SFSB.   Which I want to synchronise
> 
> Thanks & Regds
>  Ashwani
> 
> Ext: 1860
> 
> 
> 
> 
> 
> 
> 
> > -Original Message-
> > From: James Mitchell [mailto:[EMAIL PROTECTED]
> > Sent: Friday, April 08, 2005 6:04 PM
> > To: Struts Users Mailing List
> > Subject: Re: concurrency problem
> >
> 
> >
> 
> > You'd be better off implementing token processing.
> >
> 
> > Struts includes token generation and helper methods to ensure
> 
> > only one valid
> 
> > request is handled at a time.  Look at the struts example 
> application
> 
> > (mailreader) for an example.
> >
> 
> > For detailed info on why this pattern works, see:
> > http://www.amazon.com/exec/obidos/tg/detail/-/0201634988/ref=l
> > pr_g_1/102-8250064-5792120?v=glance&s=books
> >
> 
> >
> 
> >
> 
> >
> 
> > --
> > James Mitchell
> > Software Engineer / Open Source Evangelist
> > Consulting / Mentoring / Freelance
> > EdgeTech, Inc.
> > 678.910.8017
> > AIM:   jmitchtx
> > Yahoo: jmitchtx
> > MSN:   [EMAIL PROTECTED]
> >
> 
> >
> 
> >
> 
> >
> 
> > - Original Message -

RE: [OT] How to transpose a table in MS SQL Server 2000

2005-04-08 Thread Paul McCulloch
I don't 100% understand your tables. Where does ID come from (the values 1 &
2 exist in the first view, but 1,2,3,4 in the second).

Are the totals derived?

Give me the SQL for the first view and I'll have a look.

Paul

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]
> Sent: 08 April 2005 14:46
> To: Struts Users Mailing List
> Subject: [OT] How to transpose a table in MS SQL Server 2000
> 
> 
> So, I have the following table:
> 
> id  month   val1val2total
> 1   jan 1   2   3
> 2   feb 3   4   7
> 
> And I'd like it transformed to:
> 
> ID  VAL COL1COL2
> 1   month   jan feb
> 2   val11   3 
> 3   val22   4
> 4   total   3   7
> 
> I'm guessing that it's possible, as I've seen variants of 
> this type of 
> tranformation.  I have googled this, but the solutions (I've 
> found) are 
> considerably more complicated and revolve around 
> summing/aggregating, when 
> I just need to change the structure of the results. 
> 
> Has anybody seen a solution that fits this problem?
> 
> Thanks,
> Dennis
> 
> 
> 
> 
> [EMAIL PROTECTED] 
> 04/08/2005 09:26 AM
> Please respond to
> "Struts Users Mailing List" 
> 
> 
> To
> "Struts Users Mailing List" 
> cc
> 
> Subject
> [OT] RE: concurrency problem
> 
> 
> 
> 
> 
> 
> As I hit the send button, something tickled in the back of my 
> mind, and I 
> began to remember that the spec forbids thread primitiives on 
> bean methods 
> 
> and that the EJB container is responsible for handling 
> concurrent access. 
> Sounds like your provider might have a defect.
> 
> Dennis
> 
> 
> 
> 
> 
> [EMAIL PROTECTED] 
> 04/08/2005 09:13 AM
> Please respond to
> "Struts Users Mailing List" 
> 
> 
> To
> "Struts Users Mailing List" 
> cc
> 
> Subject
> RE: concurrency problem
> 
> 
> 
> 
> 
> 
> You're synchronizing on an object which is unique for each 
> user, which 
> might explain why more than 1 thread can concurrently enter 
> the critsec. 
> Wouldn't a better solution be to declare the method as synchronized?
> 
> Dennis
> 
> 
> 
> 
> 
> "Kalra, Ashwani" <[EMAIL PROTECTED]> 
> 04/08/2005 08:53 AM
> Please respond to
> "Struts Users Mailing List" 
> 
> 
> To
> "Struts Users Mailing List" 
> cc
> 
> Subject
> RE: concurrency problem
> 
> 
> 
> 
> 
> 
> 
> Isnt that valid when request is going to same action. In my scenario, 
> different actions are invoked quickly and all the actions 
> have this call 
> to SFSB.   Which I want to synchronise
> 
> Thanks & Regds
>  Ashwani
> 
> Ext: 1860
> 
> 
> 
> 
> 
> 
> 
> > -Original Message-
> > From: James Mitchell [mailto:[EMAIL PROTECTED]
> > Sent: Friday, April 08, 2005 6:04 PM
> > To: Struts Users Mailing List
> > Subject: Re: concurrency problem
> >
> 
> >
> 
> > You'd be better off implementing token processing.
> >
> 
> > Struts includes token generation and helper methods to ensure
> 
> > only one valid
> 
> > request is handled at a time.  Look at the struts example 
> application
> 
> > (mailreader) for an example.
> >
> 
> > For detailed info on why this pattern works, see:
> > http://www.amazon.com/exec/obidos/tg/detail/-/0201634988/ref=l
> > pr_g_1/102-8250064-5792120?v=glance&s=books
> >
> 
> >
> 
> >
> 
> >
> 
> > --
> > James Mitchell
> > Software Engineer / Open Source Evangelist
> > Consulting / Mentoring / Freelance
> > EdgeTech, Inc.
> > 678.910.8017
> > AIM:   jmitchtx
> > Yahoo: jmitchtx
> > MSN:   [EMAIL PROTECTED]
> >
> 
> >
> 
> >
> 
> >
> 
> > - Original Message -
> 
> > From: "Kalra, Ashwani" <[EMAIL PROTECTED]>
> > To: "Struts (E-mail)" 
> > Sent: Friday, April 08, 2005 7:10 AM
> > Subject: concurrency problem
> >
> 
> >
> 
> >
> 
> > I am facing concurrency problem in following scenario.
> >
> 
> > All our action classes call same stateful session bean . 
> 
> > Each action class
> 
> > obtains the reference  from HTTPSession object and calls one
> 
> > and only one
> 
> > business method.
> > To prevent the concurrent access t

[OT] How to transpose a table in MS SQL Server 2000

2005-04-08 Thread DGraham
So, I have the following table:

id  month   val1val2total
1   jan 1   2   3
2   feb 3   4   7

And I'd like it transformed to:

ID  VAL COL1COL2
1   month   jan feb
2   val11   3 
3   val22   4
4   total   3   7

I'm guessing that it's possible, as I've seen variants of this type of 
tranformation.  I have googled this, but the solutions (I've found) are 
considerably more complicated and revolve around summing/aggregating, when 
I just need to change the structure of the results. 

Has anybody seen a solution that fits this problem?

Thanks,
Dennis




[EMAIL PROTECTED] 
04/08/2005 09:26 AM
Please respond to
"Struts Users Mailing List" 


To
"Struts Users Mailing List" 
cc

Subject
[OT] RE: concurrency problem






As I hit the send button, something tickled in the back of my mind, and I 
began to remember that the spec forbids thread primitiives on bean methods 

and that the EJB container is responsible for handling concurrent access. 
Sounds like your provider might have a defect.

Dennis





[EMAIL PROTECTED] 
04/08/2005 09:13 AM
Please respond to
"Struts Users Mailing List" 


To
"Struts Users Mailing List" 
cc

Subject
RE: concurrency problem






You're synchronizing on an object which is unique for each user, which 
might explain why more than 1 thread can concurrently enter the critsec. 
Wouldn't a better solution be to declare the method as synchronized?

Dennis





"Kalra, Ashwani" <[EMAIL PROTECTED]> 
04/08/2005 08:53 AM
Please respond to
"Struts Users Mailing List" 


To
"Struts Users Mailing List" 
cc

Subject
RE: concurrency problem







Isnt that valid when request is going to same action. In my scenario, 
different actions are invoked quickly and all the actions have this call 
to SFSB.   Which I want to synchronise

Thanks & Regds
 Ashwani

Ext: 1860







> -Original Message-
> From: James Mitchell [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 08, 2005 6:04 PM
> To: Struts Users Mailing List
> Subject: Re: concurrency problem
>

>

> You'd be better off implementing token processing.
>

> Struts includes token generation and helper methods to ensure

> only one valid

> request is handled at a time.  Look at the struts example application

> (mailreader) for an example.
>

> For detailed info on why this pattern works, see:
> http://www.amazon.com/exec/obidos/tg/detail/-/0201634988/ref=l
> pr_g_1/102-8250064-5792120?v=glance&s=books
>

>

>

>

> --
> James Mitchell
> Software Engineer / Open Source Evangelist
> Consulting / Mentoring / Freelance
> EdgeTech, Inc.
> 678.910.8017
> AIM:   jmitchtx
> Yahoo: jmitchtx
> MSN:   [EMAIL PROTECTED]
>

>

>

>

> - Original Message -

> From: "Kalra, Ashwani" <[EMAIL PROTECTED]>
> To: "Struts (E-mail)" 
> Sent: Friday, April 08, 2005 7:10 AM
> Subject: concurrency problem
>

>

>

> I am facing concurrency problem in following scenario.
>

> All our action classes call same stateful session bean . 

> Each action class

> obtains the reference  from HTTPSession object and calls one

> and only one

> business method.
> To prevent the concurrent access to this instance which

> occurs when user

> immediately presses two links quickly in succession I am

> using the following

> code block
>

>

> execute(...)  //execute methods of Action class
> {
> 
> 
>

> //Obtain the session from  Request.User will always be in session here
> session=request.getSession()
> Synchronised(session)
> {
> //call ejb's  business method.
> }
>

> }
>

> However sometimes  more than one thread is able to pass

> through, And I get

> exception from Appserver. As 2 threads are not allowed for

> statefull Session

> bean.
> Can there be problem in above code. Is it ok to synchronise

> on session

> object.
>

>

>

>

>

> Thanks & Regds
>  Ashwani
>

> Ext: 1860
>

>

>

>

>

>

>

> This message contains information that may be privileged or

> confidential and

> is the property of the Capgemini Group. It is intended only

> for the person

> to whom it is addressed. If you are not the intended

> recipient,  you are not

> authorized to read, print, retain, copy, disseminate, 

> distribute, or use

> this message or any part thereof. If you receive this 

> message in error,

> please notify the sender immediately and delete all  copies

> of this message.
>

>

>

> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>

>


This message contains information that may be privileged or confidential 
and is the property of the Capgemini Group. It is intended only for the 
person to whom it is addressed. If you are not the intended recipient, you 


are not authorized to read, print, retain, copy, disseminate,  distribute, 


or use this message or any part thereof. If you receive this  message in 
error, please notify t