SQL connectivity test [message #654569] |
Sat, 06 August 2016 04:37 |
|
Prathikesh
Messages: 20 Registered: February 2015 Location: Hyderabad
|
Junior Member |
|
|
Hi Leaders,
Greetings of the day. Need help in this regards.
We have a table dynamic_sql_connect having two fields username, passwd. Below is the data in the table.
INSERT INTO dynamic_sql_connect ( username, passwd ) VALUES ( 'C11111', 'c11111' );
My another SQL script "test1.sql" will read the data from dynamic_sql_connect table and connect to the DB user "C11111"
and executes "test2.sql". If the database is having this user c11111 then only it will connect and execute the "test2.sql",
otherwise we get the error invalid username and password. I want to avoid this error. For that, I need sql/plsql code or
functions if any, to perform the authentication first. If authentication is succeeded then only "test2.sql" script should
execute otherwise it should report "C11111 user does not exists" message.
Thanks.
|
|
|
Re: SQL connectivity test [message #654570 is a reply to message #654569] |
Sat, 06 August 2016 04:53 |
John Watson
Messages: 8938 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
If I understand you correctly, this is impossible. You have a session, logged on. You then want to logon as someone else. That will disconenct your current session.
You had better explain what it is that you want to do, in business terms not technical, and then perhaps someone can suggest a solution.
|
|
|
Re: SQL connectivity test [message #654571 is a reply to message #654569] |
Sat, 06 August 2016 04:55 |
|
Prathikesh
Messages: 20 Registered: February 2015 Location: Hyderabad
|
Junior Member |
|
|
In my sql script "test1.sql", I have the code as below.
When I execute the "test1.sql" script, it will first read the username and password from dynamic_sql_connect table. then try to connect to new user to perform some other operations.
1. <read data from dynamic_sql_connect>
2. connect &username/&passwd; -- connect to the new user based on step1 data to perform some other operations.
3. perform some other operations.
If step 2 fails, I should get an exception. This is what I am expecting.
[Updated on: Sat, 06 August 2016 05:00] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: SQL connectivity test [message #654591 is a reply to message #654588] |
Sat, 06 August 2016 08:10 |
John Watson
Messages: 8938 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
Can you describe what it is that you want to achieve? From the point of view of the user? Not your idea of the solution, but the users' idea of the problem.
|
|
|
|
Re: SQL connectivity test [message #654613 is a reply to message #654593] |
Sun, 07 August 2016 23:00 |
|
Prathikesh
Messages: 20 Registered: February 2015 Location: Hyderabad
|
Junior Member |
|
|
Below is the requirement:
1. Connect to the database user scott. Run the script "read_data.sql".
2. The script "read_data.sql" will read the data from dynamic_tbl_connect table. This table is having 2 columns username and passwd. There is only 1 row associated with this table with (username, passwd) as ('C11111', 'c11111') accordingly.
3. We have to connect to the new schema with the above username and passwd. (Ex: connect c11111/c11111).
4. If the connection is successful then execute "mainwrapper.sql" script.
5. If the connection to new schema fails (i.e.: connect c11111/c11111 fails) then we should get the message like "No user c11111 exists in DB".
All this has to be done with the ".sql" script only. Please suggest. Thanks.
[Updated on: Sun, 07 August 2016 23:02] Report message to a moderator
|
|
|
|
Re: SQL connectivity test [message #654625 is a reply to message #654613] |
Mon, 08 August 2016 01:57 |
John Watson
Messages: 8938 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
This looks like a college homework assignment. I think you need to do it with a shell script. Where did this
Quote:All this has to be done with the ".sql" script only. come from? Is it part of the question, or is it your own words?
|
|
|
|
Re: SQL connectivity test [message #654627 is a reply to message #654613] |
Mon, 08 August 2016 02:11 |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Quote:Can you describe what it is that you want to achieve? From the point of view of the user? Not your idea of the solution, but the users' idea of the problem.
Please try to answer John's question in the way that he has requested.
What you posted here is your idea of the solution, not a statement of the problem. I'm sure that this is probably really frustrating for you, you have a problem, you have 'designed' what you believe is an appropriate solution, now you're 'just' trying to find a way to implement that solution and all you seem to be getting is "Explain the problem". BUt there's the rub, the solution that you've come up with isn't viable in its current form, so you need to go back a step to the actual problem to be solved, rather that trying to get an unworkable solution to work.
[Updated on: Mon, 08 August 2016 02:14] Report message to a moderator
|
|
|
|
|
Re: SQL connectivity test [message #654633 is a reply to message #654631] |
Mon, 08 August 2016 02:50 |
cookiemonster
Messages: 13925 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
And as we all keep telling you, this approach can not work.
So rather than keep telling us you have to do it in a way that can't be done, which will accomplish nothing except to annoy the rest of us, I suggest you actually post the business requirement as asked (and no business requirement ever goes into details about what language to use).
|
|
|