Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Dynamic SQL- Issue a connect stmt.
I have tried this and could not get it to work. I think connect is not a SQL statement, but a SQLPlus statement, and the dynamic_sql package only works on SQL, not SQLPlus.
Sarah Satterthwaite
Cambridge, MA
Manasa Rao wrote:
>
> All,
>
> I am trying to open another session using input parameters passed to the
> procedure. Can I open a session in a procedure and if so how do I stay in
> the opened session?
> Is it possible at all?
>
> I am placing the code that I used.
>
> Appreciate any ideas or suggestions.
> Radhika.
>
> create or replace procedure open_session(userid_in in varchar2,
> password_in in varchar2)
> is
> connect_string varchar2(14);
> sql_stmt varchar2(2000);
> curr_user varchar2(20);
> cursor_handle integer;
> feedback_v integer;
> begin
> connect_string := 'xxx_database'; --database connect string.
>
> /* create a cursor to user fo the dynamic sql */
> cursor_handle := DBMS_SQL.OPEN_CURSOR;
>
> /*construct the sql statement and parse it. */
> sql_stmt := 'connect
> '||userid_in||'/'||password_in||'@'||connect_string||';';
> dbms_output.put_line('Constructed SqlStmt is: '||sql_stmt);
>
> /* parse the sql statment */
> DBMS_SQL.PARSE
> (cursor_handle, sql_stmt, DBMS_SQL.NATIVE);
>
> /* execute the sql statement */
> feedback_v := DBMS_SQL.EXECUTE(cursor_handle);
>
> /* check to see which user is connected */
> select user
> into curr_user
> from dual;
> dbms_output.put_line(curr_user);
> dbms_output.put_line('Feedback'||feedback_v);
>
> /* close the cursor */
> DBMS_SQL.CLOSE_CURSOR(cursor_handle);
>
> EXCEPTION
> WHEN OTHERS
> THEN
> /* close cursor on failure */
> DBMS_SQL.CLOSE_CURSOR(cursor_handle);
>
> end validate_user;
> /
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
> --
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> --
> Author: Manasa Rao
> INET: rao_manasa_at_hotmail.com
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
-- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Sarah Satterthwaite INET: ssattert_at_earthlink.net Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Tue Feb 06 2001 - 20:50:42 CST
![]() |
![]() |