Re: Multiple sqlplus sessions from a single sqlplus session
Date: Sun, 3 Jan 2021 14:45:09 -0500
Message-ID: <ab07b0cc-79fe-1467-3bc4-a5251ad313db_at_gmail.com>
Hi Kunwar,
You can have multiple threads, each thread connected to a different session. As a matter of fact, any ORM has a thread factory class which does precisely what I described. A single thread can maintain more than one connection. However, you asked about SQL*Plus. All of the mentioned tools are CLI tools: SQL*Plus, tmux, screen (GNU version of tmux, more standard and more well known than tmux) and SQL*Developer. When writing a program, you can do something like this:
try:
con1 = cx_Oracle.connect(username1)
query1 = con1.cursor()
query1.execute(sql)
query1.arraysize = nrows
con2 = cx_Oracle.connect(username2)
query2 = con2.cursor()
query2.execute(sql)
query2.arraysize = nrows
exceptcx_Oracle.DatabaseError asora_err:
oerr = ora_err.args[0]
print(f"Oracle error: {oerr}")
That is Python code, Java code would be similar. Connections con1 and con2 are independent of each other and maintain separate statuses. However, you should take great care when doing something like this because you must close both connections and close all cursors for both connections or you will have a very nasty memory leak in your application. Happy New Year!
On 1/1/21 10:25 PM, kunwar singh wrote:
> Thanks Sayan. Mladen for the response.
> I have developed a web application written in Java, that makes a
> single connection to the database and runs the query.
> Hence I cannot use sql developer as i already have the application.
> I will check on how to make use of tmux in the context of my application.
>
>
> On Fri, Jan 1, 2021 at 8:03 PM Sayan Malakshinov <xt.and.r_at_gmail.com
> <mailto:xt.and.r_at_gmail.com>> wrote:
>
> Hi Kunwar,
>
> To be honest I don't think it would be convenient to have merged
> dynamic query output with input prompt... It's much easier to use
> Tmux or other popular linux multitab terminals (on windows you can
> use Console2 or ConEmu with WSL)
>
>
>
> --
> Cheers,
> Kunwar
-- Mladen Gogala Database Consultant http://mgogala.byethost5.com -- http://www.freelists.org/webpage/oracle-lReceived on Sun Jan 03 2021 - 20:45:09 CET