Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to convert column into rows?

user8731258Feb 21 2010 — edited Nov 4 2010
Hi,
I have a table say a.IT has gt columns a_1,a_2,a_3.a_4.I have another table b.It has got only one column b.
Now i want to insert the 4 columns from table a into 4 rows of table b.
Can u please suggest the code.
I am using oracle 10g.

Comments

Sascha Herrmann

Hi!

Works for us. Strange that you don't get an exception. What does your ROLE_ONE look like?

Sascha

kdario

AFAIK conn.openProxySession() can fail silently(so you will get standard connection instead of proxy).

Also, because of connection pooling, always check if you already have proxy connection(and if so, close this connection) before opening new proxy connection.

So your code should look like this:

public void prepareSession (Session session){ 

myTransactionImpl myTrans = (myTransactionImpl)this.getDBTransaction();

      OracleConnection conn = hzpcTrans.getConnection();

      String currentUser = ADFContext.getCurrent().getSecurityContext().getUserName();

      java.util.Properties prop = new java.util.Properties();

      prop.put(OracleConnection.PROXY_USER_NAME, currentUser);

      try {

if(conn.isProxySession()){

            conn.close(OracleConnection.PROXY_SESSION);

        }

            conn.openProxySession(OracleConnection.PROXYTYPE_USER_NAME, prop);

if(!conn.isProxySession()){

            throw SomeException();

        }

            DatabaseMetaData meta = conn.getMetaData();            

            System.out.println("the user currently on the session is " + meta.getUserName());

        }

.catch.........

}

I'm not sure why you need custom connection factory(maybe you introduced some error there? )

You can retrieve OracleConnection like this:

PreparedStatement statement =  this.getDBTransaction().createPreparedStatement("commit", 1);

OracleConnection conn = (OracleConnection)statement.getConnection();

And don't forget to call super.prepareSession(session); 

Dario

unknown-7404

Already replied in your duplicate JDBC forum thread

https://community.oracle.com/thread/3570631

1 - 3
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 29 2010
Added on Feb 21 2010
10 comments
30,939 views