Command line in SQL/PLUS

When I start SQL/PLUS I see the following
13:56:06 sql>
13:56:06 sql>
13:56:06 sql>
...But I want so see sysdate, username and database
13:56:06 scott@entw>
13:56:06 scott@entw>
13:56:06 scott@entw>Does anybody have an idea?

in your client ORACLE_HOME/sqlplus/admin directory is the file gloogin.sql
This is executed whenever you login. As part of it, you can set your prompt. Here is the code I use.
COLUMN connect_id NEW_VALUE prompt_str
COLUMN carat NEW_VALUE carat
SELECT LOWER(user) || '@' || LOWER(i.host_name) ||':'||LOWER(t.instance) as connect_id,
DECODE(user, 'SYSTEM', '$',
'SYS', '#',
'>') carat
FROM v$thread t, v$instance i
SET sqlprompt "&prompt_str&carat " ;
SET sqlcontinue "&carat "
It requires access to v$thread and v$instance views. It will be simple enough to also include the time portion of sysdate with TO_CHAR(sysdate,'hh24:mi:ss') if you wish.

Similar Messages

  • Execute (or re-execute) commands in the SQL*Plus buffer

    I feel confused about sql plus / command. by defination, it Execute (or re-execute) commands in the SQL*Plus buffer. how do I know whether it execete or re-execute a command?
    for example, I run a select statement, seems I have to type / to get result. when I run a create table statement, it seems run twice with / and I got table exists error.
    Could someone clearify when should / be used and when not to use it.

    jz2 wrote:
    I feel confused about sql plus / command. by defination, it Execute (or re-execute) commands in the SQL*Plus buffer. how do I know whether it execete or re-execute a command?
    for example, I run a select statement, seems I have to type / to get result. when I run a create table statement, it seems run twice with / and I got table exists error.
    Could someone clearify when should / be used and when not to use it.I guess you are looking at things in the other way round. The / does what it says, it executes the command in the buffer. Don't think it "reexecutes". It simply executes the command. Be it already run or for the first time. For example,
    Running the code for 1st time.
    SQL> begin
      2  dbms_output.put_line('hi');
      3  end;
      4  .
    SQL> set serveroutput on
    SQL> /
    hi
    PL/SQL procedure successfully completed.
    Running again....
    SQL> l
      1  begin
      2  dbms_output.put_line('hi');
      3* end;
    SQL> /
    hi
    PL/SQL procedure successfully completed.
    SQL>So / simply executes. Now when you should use it and when not, that depends upon the kind of command you are trying to execute. Like you mentioned, for a select, it works by again giving the output. But for a DDL, its not the / which gives error but its the very nature of DDL that once issued, its committed so surely enough , next execution would throw an error only.
    HTH
    Aman....

  • New line in SQL plus

    Hi all,
    I would like to include content with a new line into an column of a table. I would like to run the script through SQL plus but because I want a new line in this content, SQL plus determines it as the end of the query.
    e.g. update <tablename>
    set <columnname> = ' bla bla
    bla bla'
    Is there a way I can get around this?

    Joyce,
    Try:
    SET SQLBL[ANKLINES] ON
    http://download-west.oracle.com/docs/cd/B13789_01/server.101/b12170/ch13.htm#sthref2829
    Alison

  • Run command line with SQL Developer

    Is is possible to run SQL Developer in command line mode?
    As SQL Developer is a unicode client to unicode database, it will be a good news for me. It is possible to run batch using SQL Developer to edit the database.

    Take the suggestions from SQL Developer from the command line , to which I can add you could use $SQL_PATH/login.sql or the same file located in your specified script dir, which will be called on making a connection.
    If you don't vote for the feature request at the SQL Developer exchange, don't be surprised no progress is being made...
    K.

  • Different behaviour in SQL*Plus and PL/SQL

    Does anyone know why the following SQL works from the command line in SQL*Plus but results in a syntax error when included within a cursor in a PL/SQL procedure?
    SELECT (SELECT 'dummy' FROM dual)
    FROM dual;
    null

    Is this what you require? This works...
    declare
    cursor cur_dummy is
    SELECT d.dum
    FROM (
    SELECT 'dummy' dum
    FROM dual
    ) d
    v_dummy varchar2(30);
    begin
    open cur_dummy;
    fetch cur_dummy into v_dummy;
    close cur_dummy;
    dbms_output.put_line(v_dummy);
    end;
    Cheers
    BigB
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Aqueel ([email protected]):
    In PL/SQL, every SELECT Statement must have a INTO clause. But still It's not working. Anyother know the answer?
    <HR></BLOCKQUOTE>
    null

  • "loadjava" is unknow command in SQL*Plus (Oracle8i)

    I am attempting to laod a java class in the database but when I type the command "loadjava" the SQL*Plus prompt indicates this is an unknown command. Is there a configuration problem I should address with the DBA?

    Chris,
    If you want the loadjava command, it's outside the database (a batch file if you're Windows). The other option is the CREATE OR REPLACE JAVA example I told you about in an earlier thread.
    Hope this helps,
    -Dan
    http://www.compuware.com/products/devpartner/db/oracle_debug.htm
    Debug PL/SQL and Java in the Oracle Database

  • Formatting output columns - ala SQL*Plus 'column' command

    SQL_Developer 1.5
    Is there a way to format the output of queries for numbers, etc. like the 'column' command found in SQL*Plus?
    I realize I can use the TO_CHAR() function in the SQL but was hoping there was something easier.
    Thanks very much!
    -gary

    it could be that the column of the table that you are trying to insert the data has a small length.

  • SQL*PLUS Verus using new Oracle10 xe   SQL commands window

    Can I run all manor of queries in SQL COMMAND as in sql*plus .Put another way
    does the new orcale 10 xe (SQL command window) have any restrictions at all in terms
    of code ?
    P.S. Up to now I think this DATABASE program is great.( still testing large files)
    Thanks
    Bob

    Great that's exactly the answer I was hoping to get, I am new to Oracle products
    but not new to SQL and find the new Oracle interface to be top notch compared to any
    "FREE" programs out there right now! I tried the free microsoft SQL server program
    and found almost no help or free tutorials like Oracle 10 xe has ( Way to go Oracle !)
    Thanks
    Bob

  • PLS-00201 error occurs when batching a stored procedure in SQL*Plus

    I have a batch file to run a stored procedure and spool the results to file. When I enter the commands manually in sql*plus the output works fine and my results are spooled to the output file. But when I run the same commands in the batched script I get an error.
    Any ideas?
    Stored Procedure:
    create or replace procedure MMP( p_cursor in out SYS_REFCURSOR)
    as
    begin
    open p_cursorfor select name, id from table;
    end;
    batch file 1:
    sqlplus -S user/pw@REPORTDV @sp_output_spooled.sql
    script file sp_output_spooled.sql
    Pasting these commands directly to the SQL*Plus command prompt spools the result set to file as expected.
    set colsep '|'
    set echo off
    set feedback off
    set termout off
    set heading off
    set linesize 9000
    set pagesize 0
    set trimspool on
    set headsep off
    spool output.TXT
    var rc refcursor
    execute MMP(:rc)
    print rc
    spool off
    exit
    The errors printed to output.TXT file after the batch is run and error occurs:
    BEGIN MMP(:rc); END;
    ERROR at line 1:
    ORA-06550: line 1, column 8:
    PLS-00201: identifier 'MMP' must be declared
    ORA-06550: line 1, column 8:
    PL/SQL: Statement ignored
    ERROR:
    ORA-24338: statement handle not executed
    SP2-0625: Error printing variable "rc"

    Hi,
    Your code worked fine for me.
    Is MMP procedure owned by the same user that is running the batch file or does it have proper privileges and synonym?
    vr,
    Sudhakar

  • SQL*Plus report: hide accept value in report

    HI all,
    I have created an SQL Report of an APEX-Application. The output is stored in a HTML file.
    All works fine but one think I want to hide in the HTML report.
    I try to describe what the problem is.
    I prompt the user to put in the application_id of the apex application:
                           accept v_application_Id char prompt 'Appliaction-ID:'
    In the HTML file the following output is shown:
    Report created on:
    25-Jun-2013, 10:06:04
    alt 8: where application_id = &&v_application_id
    neu 8: where application_id = 680
    Workspace
    WORKSPACE
    APPLICATION_ID
    APPLICATION_NAME
    ALIAS
    OWNER
    Q0Q0AUFTRAGSVERWALTUNG
    680
    Q0Q0AUFTRAGSVERWALTUNG
    F680317
    Q0Q0AUFTRAGSVERWALTUNG_ADMIN
    How can I hide the two lines
    alt 8: where application_id = &&v_application_id
    neu 8: where application_id = 680
    from the report?
    I have searched  this forum and toke a look into the documentation but I have nothing found.
    Could anyone please help me?
    Oracle 11g R2
    This is the SQL script what I run in SQL*Plus.
    -- start script
    accept v_application_Id char prompt 'Appliaction-ID:'
    spool C:\a\APEX.html
    set termout off
    SET MARKUP HTML ON SPOOL ON HEAD "<TITLE>SQL*Plus APEX-Report</title> -
    <STYLE TYPE=’TEXT/CSS’><!--BODY {bgcolor: ffffaa background: ffffc6} --></STYLE>"
    clear break
    clear buffer
    clear compute
    clear column
    clear sql
    set feedback off
    set serveroutput on
    -- Report Header
    ttitle left ' ' skip 1
    select TO_CHAR(sysdate,'dd-Mon-yyyy, hh24:mm:ss')  "Report created on:"
    from dual;
    -- Workspace
    ttitle left col 15 '<font face="Arial" size="+2" color="#0000FF">Workspace</font>' skip 1
    set linesize 300
    set pagesize 500
    set serveroutput on
    column workspace format a35
    column application_id format 99999999
    column application_name format a35
    column alias format a35
    column owner format a35
         select
             WORKSPACE,
             APPLICATION_ID ,
             APPLICATION_NAME,
             ALIAS,
             OWNER
         from apex_applications
         where application_id = &&v_application_id;
    ttitle off
         select
             APPLICATION_GROUP,
             APPLICATION_GROUP_ID,
             HOME_LINK,
             PAGE_TEMPLATE,
             ERROR_PAGE_TEMPLATE
         from apex_applications
         where application_id = &&v_application_id;
    set termout on
    set markup html off head '' body '' entmap off spool off pre off
    set feedback on
    set linesize 80
    set pagesize 50
    ttitle off
    set termout on
    set serveroutput off
    spool off
    set echo on
    -- End Script
    best regards
    ben
    Oracle 11g R2

    Hi, Ben,
    The SQL*Plus command to stop those messages is
    SET VERIFY OFF
    Put this command anywhere before the first use of a substitution variable, e.g. before the SPOOL command.
    Those "OLD" and "NEW" messages will stay suppressed until you either end the SQL*Plus session, or issue a SET VERIFY ON command.
    If you use SQL*Plus often, then, when you have a few minutes, look up the SET command in the SQL*Plus manual,
    SET System Variable Summary
    and read a little about each option.  You probably won't remember everything, but you probably will remember what kinds of things can be controlled by the SET command, and have a better idea of where to start looking in the future when you have a different problem.

  • SQL Plus flat file

    I'm trying to write a SQL script that will generate a comma delimited file for use with Excel. When I execute the following line by line in SQL Plus, everything works fine. However, when I save the script in a file and open the file with SQL plus, it doesn't generate the file.
    Can someone please tell me what I'm missing here?
    Thank you very much.
    Robert
    set heading off
    set feedback off
    set trimspool on
    set echo off
    set pagesize 0
    spool c:\spool\data.txt
    select la.code ||','|| lai.code|| ',' || la.title as data
    from drLAInstanceMeeting laim
    inner join drLearningActivityInstance LAI on lai.id=laim.learningActivityInstanceID
    inner join drLearningACtivity LA on la.id=lai.learningActivityID
    where abs(meetingEnd - meetingStart) > (6/24);
    spool off

    I have continued to play with the above script, and found more information that may be helpful. When the script is executed I receive the following error:
    Is there something I need to do to use the SET command in a saved script?
    SQL> list
    1 set heading off
    2 set feedback off
    3 set trimspool on
    4 set echo off
    5 set pagesize 0
    6 spool c:\spool\data.txt
    7 select la.code ||','|| lai.code|| ',' || la.title as data
    8 from drLAInstanceMeeting laim
    9 inner join drLearningActivityInstance LAI on lai.id=laim.learningActivityInstanceID
    10 inner join drLearningACtivity LA on la.id=lai.learningActivityID
    11 where abs(meetingEnd - meetingStart) > (6/24)
    12 /
    13* spool off
    SQL> /
    set heading off
    ERROR at line 1:
    ORA-00922: missing or invalid option

  • Using accept command within PL/SQL block

    Hi all i have a following Pl/SQL block which ia =as follows :-
    declare
    begin
    ...certain statements using while
    end;
    i need to take the user input using accept
    if i put the accept stmt betweeen begin and end i am getting following error :-
    accept myv number default 10 prompt 'Enter a number: '
    ERROR at line 48:
    ORA-06550: line 48, column 8:
    PLS-00103: Encountered the symbol "MYV" when expecting one of the following:
    := . ( @ % ;
    ORA-06550: line 48, column 30:
    PLS-00103: Encountered the symbol "PROMPT" when expecting one of the following:
    * & = - + ; < / > at in is mod remainder not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between || multiset member SUBMULTISET_
    Let me know how can i include accept stmt in Pl/SQL block
    Thanks

    You're missing a fundamental concept here.
    PL/SQL = embedded 4GL programming language in the Oracle database.
    SQL*Plus = CLI (Command Line Interface) client for an Oracle database.
    The ACCEPT command is a SQL*Plus command. Not a PL/SQL command.
    The PL/SQL engine sits inside the Oracle Server Process that services your client (SQL*Plus) session. That server process does not know who/what/where you are as a physical client. It does not know what platform and o/s you are using. It does not know what client you are using. It is after all a server process and should not and need not to know that.
    Nor can that Oracle Server Process running on the Data Server Platform access you client's hard drive, keyboard, mouse, screen, printer and so on.
    PL/SQL running in this Oracle Server Process therefore cannot read your keyboard to accept end-user input. PL/SQL therefore cannot write data to your screen.
    You need to make a clear distinction between SQL*Plus (a client) and Oracle PL/SQL (the server).

  • Could not view data in the Em while in the command line query works

    Hi, all,
    I have met with this problem for several times.
    I have an Oracle 10.0.2.0 running on Redhat linux E3.
    After I insert or just input some data in a table. I could see the new data in the command line.
    SQL> select * from tablename;
    But I could not see the new data in the EM. If I export the table to, say, MS Access, the new data doesn't show. The data is there, but I have to wait for some time. (several mins to hours)
    Do you have any idea of it??
    Thank you very much!
    Qian

    Thank you for your reply.
    Why sometimes it doesn't show in other sessions, but sometimes it shows?
    Any way, I will perform commit to see....
    Qian
    Message was edited by:
    QianChen

  • Print a report from sql*plus.

    Regards all
    Let me know whether it is possible to print a hard report rom sql*plus and how.
    waiting

    Let me know whether it is possible to print a hard report rom sql*plus Yes. SPOOL is a command to get SQL*Plus screen results to disk real-time.
    and how.A "report" is such a generic term, that you will have to get started with at least some reading :)
    http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/server.920/a90842/toc.htm
    (search for: "How Can I Learn SQL*Plus")
    You may also address specific questions about the SQL*Plus product (that are not really Database SQL and/or PL/SQL related) via the [Technologies>Tools>iSQL*Plus] forum rather than here.
    waiting That's up to you! Dig in!
    Michael O'Neill
    Publisher of the PigiWiki
    clever-idea.com

  • Code runs correctly when compiled by SQL developer but not SQL Plus

    I have a rather large package body I need to deploy and compile ... It's big and complex (I inherited the project). Our it dept is huge and scripts are deployed by the dba team and they seem to only use sql plus. My code deploys and runs fine when compiled in sql developer. Once I compile it from SQL plus it stops working. It runs and using debug statements I can see the values are correct but it no longer inserts the data into the proper tables. I get ZERO errors or warnings when this is compiled in SQL Plus and no errors are generated from the code at run time. I've diffed the extracts of the code from the DB after each deployment and the only difference is the blank lines which SQL Plus strips out when you load the file. Has anyone run into anything remotely similar and if so how did you solve it? I've tried modifying the code to no avail, adding in comments to preserve the white space makes no difference. The thing that really kills me is that there is no error at all.

    Ok this is the problem area.... vReplyMessage is a clob. I've replaced it in this section of processing with a varchar2(32000). And now it works. I still would like to know why though. Nothing is changed when I load it though sqlplus or sql developer but this line " update swn_recip_response_t set SWN_RECIP_RESPONSE = vTextReply where notification_id = v_notification_id; " would never execute with the clob. Logging showed that the clob had the correct value though. I am puzzled.
    begin
    call_SWNPost('http://www.sendwordnow.com/usps/getNotificationResults',vMessageText, vReplyMessage, v_status_code, v_status_phrase, '');
    exception
    when others then
    raise eJavaException;
    end;
    vTextReply := dbms_lob.substr( vReplyMessage, 32000, 1 );
    if (vDebug) then
    update PEMS_PROD_2.SWN_POST_LOG set response = 'notif_id == '|| v_notification_id || 'status code == '|| v_status_code|| ' '||vTextReply where log_pk = vLogPK;
    commit;
    end if;
    IF v_status_code = 200 then
    v_has_error := 'N';
    ELSE
    v_has_error := 'Y';
    END IF;
    -- we handle all exceptions below in case something goes wrong here.
    -- this area can die silently.
    vTextReply := replace(vTextReply,'<getNotificationResultsResponse xmlns="http://www.sendwordnow.com/usps">', '<getNotificationResultsResponse xmlns:xyz="http://www.sendwordnow.com/usps">');
    begin
    insert into swn_recip_response_t(notification_id) values (v_notification_id);
    exception
    when others then
    if (vDebug) then
    err_num := SQLCODE;
    err_msg := SUBSTR(SQLERRM, 1, 100);
    insert into PEMS_PROD_2.SWN_POST_LOG (LOG_PK, create_date, REQUEST, notification_id) values(pems_prod_2.swn_post_log_seq.nextval,sysdate,
    'err_num - '||to_char(err_num)|| ' error_msg - '|| err_msg, v_notification_id);
    commit;
    else
    null;
    end if;
    end;
    commit;
    begin
    update swn_recip_response_t
    set SWN_RECIP_RESPONSE = vTextReply
    where notification_id = v_notification_id;
    exception
    when others then
    if (vDebug) then
    err_num := SQLCODE;
    err_msg := SUBSTR(SQLERRM, 1, 100);
    insert into PEMS_PROD_2.SWN_POST_LOG (log_pk, create_date, REQUEST, notification_id) values(pems_prod_2.swn_post_log_seq.nextval,sysdate,
    'err_num - '||to_char(err_num)|| ' error_msg - '|| err_msg, v_notification_id);
    commit;
    else
    null;
    end if;
    end;
    commit;
    -- parse through the XML document and update the notification and recipient records
    -- parse the clob into an xml dom object
    begin
    vReplyMessage := vTextReply;
    ...

Maybe you are looking for

  • FAQ: How to share images from the Organizer to the Web

    Elements Organizer has a fair share of methods for sending images to the internet or across it to your friends and family directly. Here is a list of resources that helps explain the different functions to accomplish this task. [NOTE: While some of t

  • STO for multiple plants

    Hi, I need a help on one issue. I have 4 plants say A,B,C,D.(Under 1 Co code) I want to configure STO process.I have done it for 2 plants in the past. We have to crete internal customer & vendor (acct grp 0007). Now in SPRO,I have to do the set up fo

  • Large messages cannot be saved out from tracking

    Hi, Using BizTalk 2013 Enterprise, we cannot save out larger messages from tracking. In one example we have an XML-message of 6 MB, saving it renders a zero byte file. Smaller messages can be saved. Any ideas what this could be? Is it a known problem

  • Touch up dotted lines

    Hi there, Is it possible to give dotted lines in a pdf a better preview? I have a dotted line that looks crap @ 100% and leven at 2400% where as the text and bullets look fine @ 100%. Is there a way to fix this? I'm working with CS4. TIA

  • PI Sender JMS channel not reading data

    Hello All, Scenario is JMS to Proxy. I have configured the JMS PI sender channel as per the details given by legacy team and they validated and confirmed that the channel configuration is correct. Also PI JMS Sender channel is with green status and n