Home » Developer & Programmer » Forms » Dynamic SQL Statement (Oracle8i and Forms6i)
Dynamic SQL Statement [message #467503] Sun, 25 July 2010 00:07 Go to next message
mkhalil
Messages: 108
Registered: July 2006
Location: NWFP Peshawar Pakistan
Senior Member
Dear Fellows,

Hope you are fine. I have a problem that i have hard coded the username.tablename in each select statement of all forms of my application. Now i want to use a dynamic variable in place of username in each select statement throughout the application. The example is:
select * from scott.emp

and i want to write it as:
select * from variable.emp

But at compilation of the form the compiler should know the above variable name.

I have tried to use following select statement but it does not work.
select user into :global.username from user_users

I think perhaps my problem would be solved with Dynamic SQL Statement but i have no experience by using this statement.

Would any guy help me in this regard? Thanks in advance for giving me your precious time and knowledge.

Muhammad Khalil
Re: Dynamic SQL Statement [message #467508 is a reply to message #467503] Sun, 25 July 2010 01:27 Go to previous messageGo to next message
Michel Cadot
Messages: 68686
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
I think perhaps my problem would be solved with Dynamic SQL Statement but i have no experience by using this statement.

Yes, you have to.

PL/SQL User's Guide and Reference
Chapter 7 Performing SQL Operations with Native Dynamic SQL

Regards
Michel
Re: Dynamic SQL Statement [message #467519 is a reply to message #467508] Sun, 25 July 2010 03:42 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
i have hard coded the username.tablename

Why did you do that?
Quote:
Now i want to use a dynamic variable in place of username in each select statement throughout the application.

Cool. I hope your application isn't complex.

Oracle invented synonyms; your life would be much easier if you used those database objects (along with required privileges granted). As you are modifying the application anyway, perhaps you could consider such an approach as well.
Re: Dynamic SQL Statement [message #467523 is a reply to message #467519] Sun, 25 July 2010 04:51 Go to previous messageGo to next message
mkhalil
Messages: 108
Registered: July 2006
Location: NWFP Peshawar Pakistan
Senior Member
You are absolutely right. I have searched the board as well as Google. I have also read out the link provided by Michal Cadot but the solution was not found.

My Client requirement is to change user name and passward whereas the hard coded user name cannot be changed. So please guide me or give me the solution that what to do?
Re: Dynamic SQL Statement [message #467525 is a reply to message #467523] Sun, 25 July 2010 05:56 Go to previous message
Michel Cadot
Messages: 68686
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
My Client requirement is to change user name and passward whereas the hard coded user name cannot be changed. So please guide me or give me the solution that what to do?

What is the relation between this and your first question?
In what the link I provided does not help you to build a dynamic query?

Regards
Michel
Previous Topic: need help with roles/synonyms
Next Topic: How to write query For ADD Button
Goto Forum:
  


Current Time: Thu Sep 19 17:45:50 CDT 2024