A question about the order of COLUMN sqlplus and PL/SQL

Hello everyone.



I would like to ask a question about sqlplus command COLUMN that I use in order to define the length of my queries of output columns. So, for example, I run something like:
COLUMN market FORMAT a20
That is why any column with the name 'the market' will be composed by sqlplus as 20 characters.

Currently I'm working on a PL/SQL script that makes this automatic procedure, in other words, instead of manually write for each column in the above COLUMN order, it uses the DBMS_SQL. He read first as input the name of the table and then inside a loop, it detects the maximum length.

For those interested, here is the Oracle documentation page that I found (example 8)
http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14258/d_sql.htm

If everything worked well enough I managed to recover the maximum of each column in my table length, except that I don't know how to use the COLUMN sqlplus command in my PL/SQL block. I would like to do something like that (it's just a pseudo-code)
FOR colIndex in 1 .. numberOfColumns LOOP
        currentColumnName = getColumnName(tableDescriptionObject, colIndex);
        currentColumnLength = getColumnLength(tableDescriptionObject, colIndex);
        
        COLUMN  currentColumnName FORMAT a -- and here after 'FORMAT a' I have to write currentColumnLenth but I don't know how to proceed.

END LOOP;
I would like to know is there a command in PL/SQL to define the appropriate column typeset in sqlplus length?


Thanks in advance,
Dariyoosh

Hi, Dariyoosh,

Sory, I don't think that there is a simple way to publish SQL * most orders fom PL/SQL.
PL/SQL runs in the database (back-end); There isn't any direct contact with SQL * more at the front end.

The best way I know is that PL/SQL script (myfile.sql) with orders of the COLUMN, and then have SQL * more run the script (@myfile).

Tags: Database

Similar Questions

  • A question about the order of the COIL and blank lines

    Hello everyone,



    I have a question on the order of the COIL. Here is the syntax of my sql script file
    HOST SET NLS_LANGUAGE=FRENCH_FRANCE.WE8MSWIN1252;
    SET SQLBLANKLINES ON;
    SET TRIMSPOOL ON;
    SET SERVEROUTPUT ON;
    SET LINESIZE 10000;
    SET PAGESIZE 10000;
    SET COLSEP '|';
    SET HEADING OFF;
    SET ECHO OFF;
    SET FEEDBACK OFF;
    SPOOL result.txt
    
    
    -- And here I write my sql queries.
    
    
    SPOOL OFF;
    It works quite well, and every time the script is run, the file ' * result.txt "* contains the result of the request." " However, whenever there is a blank line at the beginning of the file ' * result.txt* '. I don't know why this unwanted blank line is inserted automatically whenever I run my script. I have to delete manually (otherwise I have problems with my script Unix interpret these files) and as I have several files to update, this could be your time. Is it possible to get rid of this unwanted blank line?


    Thanks in advance,


    Kind regards
    Dariyoosh

    SET PAGESIZE 0;

  • Consider purchase of Wacom Cintiq 27 HD Touch - Questions about the tactile feature in Photoshop and Lightroom

    I'm considering buying a 27 HD Touch of Wacom Cintiq monitor. I have a few questions about the two programs Adobe and their use of the 'touch' feature - Photoshop CS6 and Lightroom 5.7 running on Windows 7.

    1 problems related to touch a feature in Lightroom and Photoshop CS6 and 5 resolved that you see on the forums of Wacom a year ago?

    2. If so, is there sufficient value gained through the tactile feature in Photoshop CS6 and Lightroom 5 to justify the $500 price difference between the Cintiq 27 HD vs Touch HD? (I realize that this is a subjective question based on the abundance of its cash).

    3. I intend to stay with CS6 as long as possible to avoid a monthly subscription, BUT I wonder if buy the Touch HD can provide additional key features in future releases of these products that do not exist currently. (It is a pie in the kind of sky in question).

    Thank you!

    Kent

    Support for Photoshop Touch is added by CC 2014.2.2.  However as the Pro Intuos Wacom tablets with touch can be used with earlier versions of Photoshop and the Wacom Tablets Configurator can custom features can be used with Photoshop touch tablets.  I use LR but I don't know that the same thing would be true for her. You can configure the setting for many applications. The device driver knows which application its interfacing with and uses the parameter set for each...

    I have disable most of touch when using Photoshop.  The main reason why I have a Tablet is Photoshop Brush tools. Like Eraser, clone stamp, etc, nothing is better then a pen when it come to create the layer mask.  For most programs, I always use a mouse and I use the keyboard, the mouse and the pen with Photoshop...

    I never wanted a Cintig I do not have my hand between my eyes and the work. I'm not an artist.

  • Question about the order of evaluation of the clause WHERE CLAUSE when the Oracle OF the syntax used to join tables

    Hello

    Oracle version: 11.1.0.7.0 - 64 bit

    I read the documentation online at joins. The page is avialable here: joins at

    My question is about the join order of evaluation of the conditions in clause and the conditions of those

    are not the join conditions and are placed in the WHERE clause.

    Consider the following pseudocode

    SELECT

    T1. Col1,

    T2.Col1

    Of

    Table1 t1 LEFT OUTER JOIN table2 t2

    WE

    (condition_expression1)

    WHERE

    (condition_expression2)

    Is it correct to say that if there is no column on the status of join (condition_expression1) in condition_expression2, then condition_expression2 is executed before condition_expression1? In other words, oracle always trying to filter based on the WHERE clause individually each table as much as possible before joining them based on the conditions on the article?

    Thanks in advance,

    Hello

    dariyoosh wrote:

    Hello

    Oracle version: 11.1.0.7.0 - 64 bit

    I read the documentation online at joins. The page is avialable here: joins at

    My question is about the join order of evaluation of the conditions in clause and the conditions of those

    are not the join conditions and are placed in the WHERE clause.

    Consider the following pseudocode

    SELECT

    T1. Col1,

    T2.Col1

    Of

    Table1 t1 LEFT OUTER JOIN table2 t2

    WE

    (condition_expression1)

    WHERE

    (condition_expression2)

    Is it correct to say that if there is no column on the status of join (condition_expression1) in condition_expression2, then condition_expression2 is executed before condition_expression1? In other words, oracle always trying to filter based on the WHERE clause individually each table as much as possible before joining them based on the conditions on the article? ...

    The reverse is actually closer to the truth, but we can't really make general statements like that.

    SQL is not a language of the proceedings.  Looking at the code SQL, we could say that the code does, but we cannot say much about how that code it.  In other words, SQL is a language that describes the results you get, not the way to get them.

    The optimizer will do everything what he thinks is faster if it does not change the results.  If any order in which they are applied (in outer joins or CONNECT BY queries, for example), then think of the join is done first, and the value of the WHERE clause is applied to the result of the join.

    Here is a query looks very much like you posted:

    SELECT d.deptno

    e.ename, e.sal

    OF scott.dept d

    LEFT OUTER JOIN scott.emp e ON e.deptno = d.deptno

    WHERE e.sal > = 3000

    ORDER BY d.deptno

    ;

    Output:

    DEPTNO ENAME SAL

    ---------- ---------- ----------

    10 KING 5000

    20 FORD 3000

    20 3000 SCOTT

    The scott.dept table contains deptnos 30 and 40; Why are they not in the result set?  The query behaves as if the outer join is made first (production 15 rows), then the WHERE clause has been applied.  All lines with deptno = 30 had sals down han 3000 and all single line with deptno = 40 was NULL in the sal column, then these lines are excluded (as well as other lines of deptnos 10 and 20), and only 3 lines above are left.

  • Question about the menu filters of Photoshop, and how he orders the elements

    I'm in my Plug-Ins in Photoshop CS5 folder, and everything is in order, it. Alien Skin has its own folder, with subfolders for 4 different plugins.

    However, inside Photoshop, under the menu filters, plugins aren't as orderly. On the one hand, the higher level is completely ignored, and all 4 plug-ins are immediately visible (not grouped under a "Alien Skin" level). In addition, one of the plugins is not grouped with the other three. It is at the end, AFTER the option "Browse filters online", only.

    Is it possible to customize the menu filters so things are ranked higher?

    No, there is no way to customize the order, and the records have nothing to do with it.

    The plugin manufacturer decides where their items are displayed in the menus.

  • Suggestions and Questions about the upgrade my Hardrive Mac and Ram.

    Hi This is my first time asking something in the forums. (At least I think) Well anyway, I got the Macbook Pro Mid 2012 13 "with the retina also runs the OS El captain. I do computer for school and sometimes animation video editing and ive noticed some performance as my projects get bigger and bigger issues. I want to improve my mac, but I'm not very tech savy and don't want to do something useless, so I had a few questions, I wanted to ask you.

    Do I need for my hard drive and my Ram?

    What effect will the upgrade of my Ram and what effect will be upgrading my hard drive with an SSD?

    I saw this SSD online and thought of novice opion that sounds get Id more bang for my buck (link) with her. Is this good? What more to kill? WiIll it still works? Could you suggest some other good affordable options?

    My next question if I decide to upgrade my Ram can provide you with some good affordable links to buy of new RAM sticks, is also 8 GB, the best he can do?

    My next question I watched a few videos online and by installing the updates level looks really easy and fast. But I use bootcamp (to play games sometimes), and I wanted to know if I save my files on my drive as ive seen people do videos, (something to wipe the drive and put it back in after installing updates) will be I lose my windows 7, I lost the disc to reinstall and he check so I really want to buy a new also do not want to lose the things I put in memory.

    From the retina MacBooks you is impossible to pass the ram as it is soldered to the logic board. As with the hard drive, it's just a card ssd and you can't get those anywhere because their hard to find.

  • questions about the uses of flash cs6 and the code that it exports VS. switch to other tools

    I looked at the overviews on the new version of flash and I did experiment a bit with muse and edge of adobe. I have also heard the announcement Friday 4.1 android devices will run is no longer the flash player. my questions are:

    1 does flash cs6 fuction basically the same design-wise, but when it comes to export the file, the code a combination of html and javascript rather than in a solid swf file as it was currently publishing my work as?

    2 East edge meant to supplement flash? or he will take some of the uses of the flash so edge can publish for flash and mobile devices will remain in the area of desktop applications?

    3. If I created full-flash sites in older versions of flash, can I import in cs6 and make them exported as functional across all devices?

    I guess that, overall, just trying to get an overview here so that I can decide how to move forward and what to focus on.

    Thank you!

    1. Yes. The Toolbox for CreateJS is an additional downloadable extension for Flash CS6. He's going to post html and js files that will provide the animation rather than the swf file that you would normally publish. The success or failure of the version of javascript from your animation is the result of the work within the Toolbox. You are a bit constrained in the use of the timeline in Flash for your animations. If you are only working in Actionscript, then the output will be very disappointing.

    2 edge outputs javascript, css and html for you give an animation. The user interface allows you to design within the limits of what can make the border. You can preview and adjust and adjust your animation work you. Edge is a tool of html5. It can create some animation html5. It is not a replacement for Flash. It's something that you can use to integrate the animation in html instead of Flash.

    The problems and the benefits of each are unique. It is a good substitute to learn javascript, css and HTML 5. If you don't understand the code that is created from each of these tools, you can easily end up with huge, inflated, files which improved. I'm very biased towards really knowing what is happening. If I need to change something, I want to be able to enter the code and make a change, do not add an extra piece of code to work around what was there. I don't use any of the timeline, and so nothing of what I publish using CreateJS. Well, he's going to publish, but nothing happens because there is nothing on the timeline to translate.

    You can download a trial version of Flash CS6 and try to box at tools for yourself. Edge is still in free preview, you can get a copy to http://labs.adobe.com and try to see how it works.

    Also, if you do not use the Greensock Animation with Flash platform, take a look at this. It has recently been extended to ensure similar Javascript for most libraries. http://www.greensock.com/

  • A question about the CREATE DATABASE LINK PUBLIC and ORA-12154 error

    Hi all


    I have a problem on the public database link creation and I would be grateful if you could kindly give me a helping hand. I have the following connection settings in my
    tnsnames.ora file:
    ...
    DGPAPROD.WORLD = 
         (DESCRIPTION = 
           (ADDRESS_LIST = 
            (ADDRESS = (COMMUNITY=tcp.world)
              (PROTOCOL=TCP)(HOST=ORASR001)(PORT=1521)
             ) 
           )
           (CONNECT_DATA = (SID = DGPAPROD))
        )
    ...
    Having the above mentioned parameters, I can connect to this remote database directly in a SQL * more shell:
    $ sqlplus username/[email protected]
    It works pretty well and the connection is established without any problem.

    Now, what I want to do is to create a public database of this remote database link to avoid the user/connection of switch for the visualization of the
    the content of this database. I proceeded in line with the syntax indicated in the Oracle online documentation:

    http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/statements_5005.htm#SQLRF01205

    This is why I run the following to create a public database link
    CREATE PUBLIC DATABASE LINK SR001_dblink CONNECT TO user IDENTIFIED BY password USING 'DGPAPROD.WORLD';
    Apparently there is no error and the link is created successfully. However, it cannot resolve the remote host and every time I run this query
    (myenterprise is the name of a table in the remote database)
    SELECT *
    FROM myenterprise@SR001_dblink
    
    ERROR at line 1:
    ORA-12154: TNS:could not resolve the connect identifier specified
    What causes this problem?

    Thanks in advance,


    Kind regards
    Dariyoosh

    You must have defined DGPAPROD. WORLD in tnsnames.oar on the server where DB is runnig.

  • OCP: Question about the critical files on control and collision

    Hello

    I am currently a student at OCP certification exam 1z0-053.

    To do this, I bought the all-in-one fixed Oracle Press (http://www.mcgrawhill.ca/professional/products/9780071629188/)

    During his studies, I would like to test, to prove things and simulate the operation to get more familiar as possible with important concepts.

    The study guide covers the fact that when a critical file is damaged or lost, the proceedings will end. The critical files listed are: all copies of the controlfile, a data file that belongs to the SYSTEM table, a data file which is part of the current tablespace undo.

    As said here's the quote:

    Some of the files are important. Damage to a critical file means that the database instance will end if it is open and cannot be reopened until the damage is repaired.

    [...]

    Practically the moment where that the damage occurs, the instance will end. As always, first reaction of the DBA to an instance crashed should be to attempt a start. It will fail in NOMOUNT mode, with an error message appropriate. The alert log will show what controlfile copy is missing and also - in the section list of parameters to initialize default - controlfile how many copies there are actually is and where they are.

    A self-test at the end of the chapter, it is:

    1. loss of these files will cause a database open failed? (Choose all good answers.)

    A. a controlfile multiplex

    B. A multiplexed log file online

    C. a multiplexed log file archive

    D. an undo tablespace datafile asset

    E. a tablespace temporary assets tempfile

    F. Since the SYSAUX tablespace data file

    G. a file of data space of SYSTEM tables

    H. a data file containing the user's critical data

    [...]

    Answer:

    1. A, D and G. damage to any copy controlfile put an end to the proceedings, as damage to critical tablespaces: SYSTEM and break current tablespace.

    So, under the 11.2.0.3 when I delete or corrupt a control file copy, the instance is not crashing and the database continue to work. Alerts log is only regularly notifynig controlfile missing:

    Fri Aug 30 10:16:02 2013

    Errors in the /u01/app/oracle/diag/rdbms/ocp1/ocp1/trace/ocp1_m000_26767.trc file:

    ORA-00210: could not open the specified control file

    ORA-00202: control file: ' / u01/app/oracle/oradata/ocp1/control03.ctl'

    ORA-27041: could not open the file

    Linux-x86_64 error: 2: no such file or directory

    Additional information: 3

    I'm not really knowledge.

    I have to stick to what is said in the book or the experienced facts?

    Thank you

    Bruno

    The information contained in the Guide of the exam are not correct as written.  The Oracle instance would end on the loss of a single control file.  Oracle documentation on the management of the control files is here:

    Management of control files

    It says: "If a control file is damaged due to a disk failure, the associated instance should be stopped. Once the drive is repaired, damaged control file can be restored using the intact copy of the control of the other disk file and the instance can be restarted. »

    "Stop" means that the instance has become unstable.  Unstable case act differently depending on the situation this way, the book is not (cannot) document the specific behavior that may occur.  While the loss of a control file means that the DBA should be abandoned to the instance, it is a very different thing from the instance to the destination of its own.

    The ultimate source is always the Oracle documentation. I checked the page of errata for this book to McGraw-Hill.  I only see an extra.  Submit this to them and get your name on the page as a contributor.

  • question about the position of horizontal scrolling and grit

    Hey!

    I want a picture come outside of the browser with the movement of the scroll, the problem is that I can't block at the edge of the browser. Its an image with link to the top of the page and I just want it to be a small tab, but it keeps going all the way in my content area and does not hang on the edge of the screen. Am I missing something? I have poitioned at the edge of the browser in design mode, and iv as triple checked.

    The button positioning on the edge of the area of browser in design mode is not the same as the edge of browser window. It is just a representation, since the browser window can evolve differently at your disposal. To have the button on the edge of the window would require you to pin the button, but then you cannot use scroll motion: you can use scroll opacity, however, so it's a choice of having a floating manuscripts button in, or pinned button that fades in.

  • Question about the order of stop/f

    Hello

    We follow several Windows computers using software from a 3rd party provider. (N-Able Technologies) Recently on our servers, we have observed that after some automated routines, we would find that the "Unscheduled stop" window was displayed after these routines.  After asking a few questions to N-Able, I discovered that their routine included restarting the command shutdown / r/f in order to ensure that the judgment is carried out successfully.

    My question would be as follows:

    This could potentially be dangerous to all servers that we have with SQL or Exchange databases on them?  It may cause corruption if the databases are forced to stop?

    We have servers ranging from 2003 to 2012 with the majority of them being SBS servers.

    Thank you

    Jesse

    Being a server COMPUTER related, I recommend that you ask on the TechNet forums. This site is more for individual consumers.

    See: http://forums.technet.microsoft.com

  • Question about the installation of 11g R2 and 10g R2

    Hi, my system is Windows 7, 32-bit with Service Pack 1.

    Can I install Oracle 10 g R2? Or Oracle 11g R2?

    Could someone send me the download links?

    Thank you very much.

    Happy Thanksgiving!

    Salvation;

    Several user forum already answered your question,

    Can I install Oracle 10 g R2? Or Oracle 11g R2?

    Both version can be installed on win 7. 10g to 10.2.0.5 version. For this version and also 10.2.0.1 reference, you must connect metalink and must raise SR or contact the local oracle office. Because as mentioned here only 11.2 download available

    If your Windows 7 is version home you can create vmmachine on your win7 OS that download oracle linux(OEL 5.x) of delivery site that install this on your vmmachine and can use it for your db instalation problem

    Could someone send me the download links?

    As mention before only 11g download available on OTN:
    http://www.Oracle.com/technetwork/database/Enterprise-Edition/downloads/index.html

    PS: Please don't forget to change the status thread answer whether it is possible when believe you your thread replied, he pretend to wasting time in other forums users while they are looking outstanding which is not answered, thank you for understanding

    Respect of
    HELIOS

  • Questions about the realization of Internet C2C and B2C site.

    Hi all!

    Recently, I try to learn muse to make a site of C2C. I would like to know if it is possible to do through Muse. The thing I'm doing is such as Gumtree.com, Craigslist or eBay. I want people to post their own products and sell them, and I will get a percentage of their sales. That's what I intend to do. Is it possible to do such a thing with Muse? If so would you please lend me a helping hand. I really like to know more and if there are tutorials autour I am open to anything that can guide me.

    Thank you for your interest.

    This is not possible with Muse. This would require that a large database and back end together.

  • Question about the structure of fact sheets and articles.

    Hey there,

    What is my goal:


    One of my clients asked if it was possible to establish a DPS document:

    When you scroll your application of left to right (and vice versa), you always get to the TOP of the page when you enter a new article.

    I was wondering if there was a way to fix this somwhere? I can't really

    Thanks in advance.

    Hello Kevin,

    as much as I know it is currently not possible. When you open a freshly downloaded topic, you'll start always on the top of the page, but as soon as you navigated down in an article, the application will be

    Save the laast 'saw' the page and go back to this post as soon as you arrive backt to the article.

    Maybe you should apply for a feature of addes in option switch in the DPS App Builder.

    Kind regards

    Michael

    CrossIP communications gmbh

    next generation conversion PDF4DPS

  • A question about the comparison with REGEXP_LIKE models and [[: alpha:]]

    Hi all

    I created the following table:
    CREATE TABLE names(
    name VARCHAR2(10));
    
    INSERT INTO names(name) VALUES('dariyoosh');
    INSERT INTO names(name) VALUES('John');
    INSERT INTO names(name) VALUES('Peter');
    INSERT INTO names(name) VALUES('Frank');
    INSERT INTO names(name) VALUES('Bernard250');
    INSERT INTO names(name) VALUES('Jack12');
    Now, I want to write a query that returns the names that consist only of letters. So I wrote:
    SELECT name
    FROM names
    WHERE REGEXP_LIKE(name, '[[:alpha:]]+');
    However, this also returns alphanumeric names. I don't understand why, because I know (please, correct me if I'm wrong)
    [[:alpha:]]
    refers only to letters, no?

    You kindly could guide me where I made a mistake in my query?

    Thanks in advance
    :)

    Hello

    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    
    SQL>
    SQL> SELECT NAME
      2    FROM names
      3   WHERE REGEXP_LIKE(NAME,
      4                     '^[[:alpha:]]+$');
    
    NAME
    ----------
    dariyoosh
    John
    Peter
    Frank
    
    SQL> 
    

    Kind regards

Maybe you are looking for