SQL*Plus Tricks (Blog Post)

Yes, I know this is the APEX forum, so this post may be a bit off topic, but this is the community I'm used to, and I thought some of you might find it useful:
http://tylermuth.wordpress.com/2007/10/14/sqlplus-tricks/
Enjoy,
Tyler

Hello Tyler,
Interesting and useful blog entry.
Two general remarks (I hope you don’t mind):
1. When you are writing about a specific attribute/issue – like the PL/SQL Associative Arrays in this post – it would be helpful to mention the scope (Oracle versions) of the attribute/issue. You quoted from the 11g documentation, but from the comments, one can understand it was available in previous versions (Is it true?)
2. If you decided to correct your code, like in the second example, and make it better, it would be useful to somehow leave the old code, so people (who read the entry after the correction) can learn from it. You can cite the original code in your response to a comment, or just use a footnote. For novice like me, it’s important to see the “wrong” code, so will be able to (maybe) recognize it in our own code.
Looking forward to read more of your posts,
Arie.

Similar Messages

  • A query runs in under 1 minute is sql plus, but takes 15 in Discoverer

    I have a query that runs in under 1 minute is sql plus, but takes 15+mins in Discoverer. I use 3 parameters in discoverer which i specify as conditions in sql plus query. Any ideas on how to make it run faster??? BTW the query returns 10,000+ records. There is no formatting or sorting involved. Any ideas??? Seems the query execution plan is wrong...

    Hi,
    I agree with Michael to check your preference settings. Particulary since Plus/Viewer reads the pref.txt on the middle-tier and Desktop reads each individual PC registry.
    I would start with checking Query Prediction setttings.
    Try turning off Query Prediction. If it is not setup properly it can cause a delay. This is one difference between Discoverer and SQL*PLUS
    See forum post:
    Re: 20 mins and still predicting!!
    Re: Different Performance between Desktop-Query and SQL-Plus
    Hope that helps,
    Steve.

  • SQL Azure blog post cannot be accessed unless I log in with LiveId

    No idea where else I could have posted about this, so I post here. MSDN Blogs seem to have no support forums.
    The following two links:
    http://blogs.msdn.com/b/sqlazure/archive/2010/08/13/10049896.aspx
    http://blogs.msdn.com/b/appfabricannounce/archive/2010/08/13/finding-blocking-queries-in-sql-azure.aspx
    lead to the same blog post.
    Previously I could open that post no problem using any of the two links no problem at any time even without being logged in with LiveId. No more - now whenever I try to open it I'm required to log in. This happens all the time for the first link and sometimes
    for the second link too. If I Google for "find blocking sql azure queries" the first hit looks like below.
    I believe it should be this way. How can I get this fixed?

    Hi Dmitry,
    Please try it again, I just check we can visit it with annonymous access.
    For the search issue, it might be caused by Search Robot setting in the blog.
    You can also contact the blog author to check what happens:
    http://blogs.msdn.com/b/appfabricannounce/contact.aspx
    Thanks,
    Jinchun Chen

  • Errors while submitting the SQL * Plus  Report

    I am getting th efollowing Error while submitting the Concurrent request to run a report.
    FND_CANNOT FIND FILE
    concurrent manager encountered an error while running sql * plus for yours concurrent request
    Please respond ASAP

    Hi,
    Duplicate post see:
    Please advise on the Error immediately
    Regards,
    Gareth
    Blog: http://garethroberts.blogspot.com/

  • How to execute a mapping in sql plus?

    hi,
    OWB generate a package code from the mapping, for example if I have a package named map1, what is the request to execute ,in SQL
    PLUS, map1.main() which is the function main of this package?
    Thank you

    Hi
    There is a MAIN procedure you can use, if you have no mapping input parameters defined it will be like;
    PROCEDURE Main(p_status OUT VARCHAR2,
    p_max_no_of_errors IN VARCHAR2 DEFAULT NULL,
    p_commit_frequency IN VARCHAR2 DEFAULT NULL,
    p_operating_mode IN VARCHAR2 DEFAULT NULL,
    p_bulk_size IN VARCHAR2 DEFAULT NULL,
    p_audit_level IN VARCHAR2 DEFAULT NULL,
    p_purge_group IN VARCHAR2 DEFAULT NULL,
    p_job_audit IN VARCHAR2 DEFAULT 'TRUE');
    If you define mapping input parameters they will also be included in the signature of this procedure.
    See this post here for some details;
    http://blogs.oracle.com/warehousebuilder/2008/11/using_3rd_party_schedulers_with_owb_1.html
    Cheers
    David

  • How to get the SQL file name in SQL*plus

    hi all,
         I have created two sql file at C drive as "c:\Createtable.sql" and "c:\Deletetable.sql"
    afterwards i open
    C:\>sqlplus
    SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jan 30 11:37:10 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Enter user-name: scott/tiger
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> @C:\Createtable.sql'
    Table created.
    SQL> @'C:\Deletetable.sql'
    Table dropped.
    SQL>My problem is to get the name of the file as "c:\createtable.sql" and "C:\Deletetable.sql" in sql*plus enviornment.
    Thanks & Regards
    Singh

    Dear Damorgan,
         >>your version number to three decimal places
         My Oracle DB Version i have already stated in my previous post is 10.2.0.1.0
    Actually my problem is to get the sql files name we run in sqlplus enviornment with @ symbol. like
    i have created one sql file in c drive as
    "C:\Createtable.sql"
    afterwords i have connected to sqlplus as
    sql> conn scott/tiger
    sql>@c:\createtable.sql
    Now i want some query to get the name of the file which is run.
    In actual my problem is as
    i have suppose 10 or more SQL files in some folder ( sql1.sql, sql2.sql, sql3.sql ....).
    i created one file to call all the 10 sql files (main.sql)
    i have also one track_table which will keep track that which sql file is runned.
    I want some automated script which will insert the record in that track_table....... for that i need the name of sql file which is runned.
    Hope this will help you.
    Thanks & Regards
    Singh

  • Oracle 8i Lite: logging to sql plus - uid, password, host string - whats that

    If i install "Oracle 8i Lite" (just locally, not networked). There are two important things : "Navigator", and "SQL Plus". If in navigator, I create a local database called "xxx" (tables under 'system' user). Then if i need to query - i go to SQL Plus. Fine, but how do we log in - what is the "host string" ?.
    The login needs, Userid, Password, Host String. In some docs, it said the userid, password for 'system' account is 'system, manager' respectively. Anyways, now the host string , i had read the 'host string' will be like "@databasename", so I think for me, it will be "@xxx"
    But the way, I'm understing, i cant log, and SQL Plus says something "TNS: could not resolve service name". Maybe i have to something with that tnsnames.ora file....?
    Incase, you could give ANY information, kindly inform.
    Thanks
    null

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Mulyadi Kurniawan ([email protected]):
    Host string usually refers to the host string that is stored in your TNSNAMES.ORA file. You can open TNSNAMES.ORA with a text editor.
    If you get "TNS: could not resolve service name", it's either you have not start the database or your configuration in TNSNAMES.ORA is wrong.<HR></BLOCKQUOTE>
    hi,
    iam getting the same error(the TNS thing)can you be a bit more explaining regarding how to solve the problem.
    thanks
    null

  • Need help in sql plus

    i install in my computer the oracle9i
    my problem is that : i can login to sql plus
    althoge i was tring all the passwords that i know
    scott/tiger
    sys/change_on_install
    system/manager and the result is allways the same
    ora-12560 error
    how can i solve that problem?
    did i missed somthing during the installation?

    Thank you to EVERYONE!!
    I have been searching every possible forum to find out how to install/run SQL *Plus on a home computer without a server/network to work within.  As most just learning, I could not figure out how to get past the SQL Plus Username/Password/Host String logon.
    After much trial and error, I got through and I hope this helps a lot of people just starting out.
    I used 'SYSTEM' as my username and my password created on install.
    When installing I created a database and fixed the password so my default password was the password I created on install.
    As long as I had those two fields filled in, I could leave the Host String blank and I could still get into the SQL Plus workspace.
    Since I also created a database on install, I found that I could also use the name I gave the installed database (I didn't leave the default database name so I do not remember what the default name was, but I think the default password was 'manager' for those who were not tempted to change it).
    Worst case scenario if you forgot your database name given during install, you can do a search for all of your .ora files (usually in the drive you installed Oracle on). Open the tnsnames.ora file in Notepad and you can see which database names are available on your system. The path to my file was:
    D:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora
    You want the SERVICE_NAME = 'databasename'
    I hope this reduced someone's stress...and thanks for all the helpful hints on these threads...they led me to the final outcome!!
    In the end, I tried a lot of other combinations for the username/host strings with plenty of errors. You would think this information would be on page one of every Oracle install!! Or maybe it is and I am just a bit slow. : )
    Thanks again to all that posted with this initial question (years ago)...
    Brian Reeves
    Oracle Student

  • 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

  • SQL*PLUS

    I am new to oracle and I think this is a fairly simple question.
    When I log into sql*plus using the userid 'SCOTT/TIGER' it connects me to SCOTT schema
    by default.
    I have created a new schema and new users in the database with access to this new schema.
    Whenever I try to login using these new userids it always requires me to enter the new schema name in the 'Host String'. How do I set up these users to connect the new schema without entering the host string.
    I have similar problem in a pro*c program. Currently I connect to the database using following:
    strncpy((char *) db_name.arr, "sprllc", DBNAME_LEN);
    EXEC SQL DECLARE DB_NAME DATABASE;
    EXEC SQL CONNECT :username IDENTIFIED BY :password AT DB_NAME USING :db_name;
    while the examples use the 'SCOTT' user id to
    connect to 'SCOTT' schema without needing to declare DB_NAME.
    Any help is appreciated.
    Thanks
    null

    Thank you very much for your reply.
    I am running the datbase server, SQL*plus and Pro*C program on the same machine
    (Windows NT ) and I am still unable to connect without specifying the host string.
    The entry in the tnsnames.ora file for the database I am working with is as follows:
    SPRLLC =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = SPRLLC)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = SPRLLC)
    What I am confused about is the I am able to connect to same database with using user ids SYSTEM and SCOTT without specifying the host string.
    Thanks again for your help.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by SHAHANI():
    Hi, lakshmi
    I think U are littlte bit confusing the term schema and User in ORACLE user and Schema are the equivalant and Host string identifies the database string which is generally ORC. If u are on the same machine having Oracle server then u are not required to give Host string. The Host String is used to access remote server.
    Let if U created the new user
    user name/schema name :- lakshmi
    P.W lak
    then to connect on local machine just say
    connect lakshmi/lak; do not give Host string.
    If U are accessing remote server then give
    connect lakshmi/lak@ORCL
    where ORCL is Host string for the remote server. It may be any valid string having entry in the home\orant\net80\admin\tnsnames.orl file
    to locate the remote server.
    <HR></BLOCKQUOTE>
    null

  • Login Error SQL Plus in Oracle9i

    I installed completely Oracle9i on my system. I have to make databases, make forms and generate reports for my scool project. I cannot login to sql Plus using scott tiger . I think the problem is with HOST STRING. Can anyone help please.
    Thank you
    Sharif Vohra

    it would help if you post the error message(s), if any, that you are receiving while connecting.
    Did you install the database part (or the client tools only), and did you also create a
    starter (or customized) database while installing Oracle?

  • Not able to connect Oracle DBXE from sql*plus client

    Hi,
    I have installed Oracle 10gXE from oracle site. i have updated the tnsnames.ora also
    but when i try to connect the db through sql*plus client, i am redirected to .net debugger.
    Pls help me in this,
    Thanks in advance.
    -- Raja

    Hello,
    Can you clarify what you are trying to connect from? If it's B1 ( one ) then post to the [B1 forum|http://forums.sdn.sap.com/index.jspa#44].
    Otherwise need more info on the product you are using?
    Typically the Oracle Path must be in the PATH statement as well it requires the correct platform ( 32 or 64 ) bit client installed.
    Most BOE/CR products are 32 bit so you need to install the 32 bit client.
    Don

  • How to append timestamp to log file in SQL*Plus ?

    Version: 11.2.0.3
    Platform : RHEL 5.8 (But I am looking for platform independant solution)
    I want to append the timestamp to spooled log file name in SQL*Plus.
    The spooled log filename should look like
    WMS_APP_23-March-2013.logI tried the following 3 methods found in the google. But none of them worked !
    I tried this
    col sysdt noprint new_value sysdt_var
    SELECT TO_CHAR(SYSDATE, 'yyyymmdd_hh24miss') sysdt FROM DUAL;
    spool run_filename_&sysdt_var.Logas suggested in
    http://power2build.wordpress.com/2011/03/11/sqlplus-spool-name-with-embedded-timestamp/
    and this
    spool filename with timestamp
    col sysdt noprint new_value sysdt
    SELECT TO_CHAR(SYSDATE, 'yyyymmdd_hh24miss') sysdt FROM DUAL;
    spool run_filename_&sysdt..Logas suggested in
    http://powerbuildev.wordpress.com/2011/03/11/sqlplus-spool-name-with-embedded-timestamp/
    and this
    column tm new_value file_time noprint
    select to_char(sysdate, 'YYYYMMDD') tm from dual ;
    prompt &file_time
    spool logfile_id&file_time..logas suggested in
    Creating a spool file with date/time appended to file name
    None of the above worked in RHEL or MS DOS. Any workaround ?

    I have tested your suggestions. But I still couldn't append the date to the logfile in RHEL or MS DOS SQL*Plus
    Here are the attempts I've made. I am posting how the logfile looked like after every test.
    #Attempt1 with two dots (&sysdate..log )
    set echo on
    set feedback on
    set define off
    set pages 999
    column dcol new_value SYSDATE noprint
    select to_char(sysdate,'YYYYMMDD') dcol from dual;
    spool testlog.&sysdate..log
    select 'hello' from dual;
    spool off;Log File Name -- > testlog.&sysdate..log
    #Attempt2 with single dot (&sysdate.log)
    set echo on
    set feedback on
    set define off
    set pages 999
    column dcol new_value SYSDATE noprint
    select to_char(sysdate,'YYYYMMDD') dcol from dual;
    spool testlog.&sysdate.log
    select 'hello' from dual;
    spool off;Log File Name ---> testlog.&sysdate.log
    #Attempt3. Replacing first dot with Hyphen (testlog- ) to check if the first dot was causing the issue
    set echo on
    set feedback on
    set define off
    set pages 999
    column dcol new_value SYSDATE noprint
    select to_char(sysdate,'YYYYMMDD') dcol from dual;
    spool testlog-&sysdate.log
    select 'hello' from dual;
    spool off;Log Filename: testlog-&sysdate.log
    #Attempt4: replacing SYSDATE with SDATE
    set echo on
    set feedback on
    set define off
    set pages 999
    column dcol new_value SDATE noprint
    select to_char(sysdate,'YYYYMMDD') dcol from dual;
    spool testlog1.&SDATE..log
    select 'hello' from dual;
    spool off;Log File Name -- > testlog1.&SDATE..log

  • INSERTing chinese characters in SQL*plus

    Db version: 10gR2
    NLS_NCHAR_CHARACTERSET for my DB is AL16UTF16 by which i can store chinese characters. To INSERT using SQL*Plus, i tried to copy and paste some chinese characters from internet. When the characters get pasted, it becomes '?????' (question marks). What else do i have to set to store Chinese characters?
    SQL>  CREATE TABLE EMP2
      2   (EMPNO NUMBER,
      3   ENAME NVARCHAR2(500));
    Table created.
    SQL> Insert into emp2(empno,ename) values(889,UNISTR('????'));
    1 row created.
    SQL> COMMIT;
    Commit complete.
    SQL> SELECT * FROM EMP2;
         EMPNO ENAME
           889 ????

    Actually, it looks like Forums do something strange to URLs pasted into posts. Sorry!
    The thread URL is Re: store/retrieve data in lang other than eng when CHARACTERSET is not UTF8

  • SQL Plus not working in Oracle 8i personal edition

    I just installed Oracle 8i personal edition, went through all the steps. When I start SQL* Plus, I give it the SCOTT/TIGER combo, but when it tries to start up the database, it asks for another password, which I can't figurew out.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by John Meyer ([email protected]):
    I just installed Oracle 8i personal edition, went through all the steps. When I start SQL* Plus, I give it the SCOTT/TIGER combo, but when it tries to start up the database, it asks for another password, which I can't figurew out.<HR></BLOCKQUOTE>
    Fixed the problem yesterday.
    null

Maybe you are looking for

  • Can someone help me understand this? (java generics wildcards)

    Hi all. First of all this is my first post on sun forums. Besides that i only used java for few weeks now and i think java is quit a nice language. I do have a question regarding java generics and wildcard casting (if you can call it that). Assume yo

  • How can i get my music from my ipod t my itune/pc if the songs are not on my current itunes/pc

    Hallo, how can i get my music from my ipod t my itune/pc if the songs are not on my current itunes/pc Thank you. GarethfromQLD

  • Orders05 idoc mapping

    Hi, Please help me where to map below fields in orders05 idoc. 1) shipping terms 2) shipping via. 3) NSP Quote Number ( discount ) Thanks, Raghu.

  • Premiere CC 2014 randomly renders preview slowly

    It seems to be just one clip it randomly dislikes. The rest of the timeline renders just fine, and all of the footage is the same format. The whole timeline is about an hour and a half long. The sequence was built from another clip that is the majori

  • Lexmark X85 and Mac OS X 10.4.8?

    Hi, Are there updated drivers for this printer yet? I've got a Mac mini and can't get past the "Open Printer Center" button; supposedly because the software driver does not support Mac OS X 10.4. Also, how do I get the "scan" feature to work on this