Set Column width in query (not using SQL*Plus)

How can I Set Column width in query
I understand you can set column width using
column col1 FORMAT A5
select col1 from table1;But this only works in SQL*Plus
I want to be able to do this in a regular SQL query window (not in SQL*Plus), how can I do it.....
I am using a 'SQL window' in PL/SQL Developer IDE
and when I use this syntax it says:
ORA-00900: Invalid SQL statement
Any suggestions are appreciated...
thanks,
M.

Did you try using RPAD or LPAD functions? They fill the unfilled part of a string with character you provide... either on right or left side depending on what function you use.
e.g.
SELECT RPAD('Smith', 10, ' ') Name FROM dual;http://www.adp-gmbh.ch/ora/sql/rpad.html
Edited by: Zaafran Ahmed on Nov 10, 2010 11:50 AM

Similar Messages

  • Column width for cl_gui_splitter_container not working

    Hello friends,
    I'm trying to set the column width in a splitter, but the width is not being changed. Can anyone help me ? Here is a draft of my code
    At the PBO of the screen form I have the following:
    data:
               gobj_split                       TYPE REF TO cl_gui_splitter_container,
              gobj_container_1        TYPE REF TO cl_gui_container,
               gobj_container_2       TYPE REF TO cl_gui_container,
               gobj_drawer_container  TYPE REF TO cl_gui_docking_container,
    gobj_right_container   TYPE REF TO cl_gui_docking_container,
    *-- Create Container for Drawer (Left)
       IF gobj_drawer_container IS INITIAL.
         CREATE OBJECT gobj_drawer_container
           EXPORTING
             repid     = gv_repid
             dynnr     = gv_dynnr
             extension = 400
           EXCEPTIONS
             others    = 1.
       ENDIF.
    *-- Create Container for the right
       IF gobj_right_container IS INITIAL.
         CREATE OBJECT gobj_right_container
           EXPORTING
             repid                       = gv_repid
             dynnr                       = gv_dynnr
             side                        = gobj_right_container->dock_at_right
             extension                   = 1500
           EXCEPTIONS
             cntl_error                  = 1
             cntl_system_error           = 2
             create_error                = 3
             lifetime_error              = 4
             lifetime_dynpro_dynpro_link = 5
             OTHERS                      = 6.
    ENDIF.
    *-- Create Split Object
    CREATE OBJECT gobj_split
         EXPORTING
           parent            = gobj_drawer_container
           rows              = 2
           columns           = 1
         EXCEPTIONS
           cntl_error        = 1
           cntl_system_error = 2
           OTHERS            = 3.
    *-- Split into two rows and one column
    CALL METHOD gobj_split->get_container "Container for Date & Information
         EXPORTING
           row       = 1
           column    = 1
         RECEIVING
           container = gobj_container_1.
       CALL METHOD gobj_split->get_container "Container for Main Options
       EXPORTING
         row       = 2
         column    = 1
       RECEIVING
         container = gobj_container_2.
    *-- Set Row and Column Modes to absolute
    CALL METHOD gobj_split->set_row_mode
         EXPORTING
           mode = gobj_split->mode_absolute.
       CALL METHOD gobj_split->set_column_mode
         EXPORTING
           mode = gobj_split->mode_absolute.
    *-- Set Row Height (THIS IS WORKING)
      gobj_split->set_row_height( EXPORTING id     = 1
                                                                               height = 50 ).
    *-- Set Column Width ( THIS IS NOT WORKING )
       gobj_split->set_column_width( EXPORTING id    = 1
                                                                                   width   = 50 ).    
    And this is what I get... no matter value I put in line 80, the width doesn't change.
    Does anyone have any idea why this is happening ?
    Thank you

    You splitted the parent container in two part upper and lower row (2 rows), so you are able to adjust the vertical size, but not the horizontal size (only 1 column)  this size must be adjusted on parent container.
    Regards,
    Raymond

  • How to set column widths in tables for selected table only, not globally throughout document?

    I've been utilizing the below script (thank you so much Ramkumar. P!) to set column widths throughout a sizable InDesign book with tables on every page and it is truly a time saver. At this point in time, I have three versions of it because there are different column widths throughout the book. Is it possible to augment the script to run only on a selected text frame (containing a table)? If so, would someone be kind enough to share the augmented script with me? I've been trying to figure out this seemingly simple change through trial and error with no success as yet. I realize this is a totally newbie request and I'm entirely at the mercy of the kindness of the Javascript gods that contribute within this forum. Seeing that in a different post related to this script, one such guru responded to a request as simple as "Where do I put the scripts in InDesign" gave me enough courage to ask for some help! Thank you in advance to anyone willing to provide a solution.
      var myDoc = app.activeDocument;
         var myWidths = [100, 100, 150, 150];
         for(var T=0; T < myDoc.textFrames.length; T++){
             for(var i=0; i < myDoc.textFrames[T].tables.length; i++){
                 for(var j=0; j < myWidths.length; j++){
                     myDoc.textFrames[T].tables[i].columns[j].width = myWidths[j];
         alert("Table width updated successfully...");

    Hello all
    I have the same problem in that I'm not a scripting person, but was able to get the above script working without problem, and it does set irregular table column widths perfectly, so thanks to Ramkumar. P for that.
    BUT, it changes the column width for ALL tables in the document, whereas I would like to just target the selected table.
    Any ideas as to how I might amend this script to achieve this?
    Thx, Christian

  • Why is this query not using the index?

    check out this query:-
    SELECT CUST_PO_NUMBER, HEADER_ID, ORDER_TYPE, PO_DATE
    FROM TABLE1
    WHERE STATUS = 'N'
    and here's the explain plan:-
    1     
    2     -------------------------------------------------------------------------------------
    3     | Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
    4     -------------------------------------------------------------------------------------
    5     | 0 | SELECT STATEMENT | | 2735K| 140M| 81036 (2)|
    6     |* 1 | TABLE ACCESS FULL| TABLE1 | 2735K| 140M| 81036 (2)|
    7     -------------------------------------------------------------------------------------
    8     
    9     Predicate Information (identified by operation id):
    10     ---------------------------------------------------
    11     
    12     1 - filter("STATUS"='N')
    There is already an index on this column, as is shown below:-
         INDEX_NAME INDEX_TYPE     UNIQUENESS     TABLE_NAME     COLUMN_NAME     COLUMN_POSITION
    1     TABLE1_IDX2 NORMAL     NONUNIQUE     TABLE1      STATUS     1
    2     TABLE1_IDX NORMAL     NONUNIQUE     TABLE1     HEADER_ID     1
    So why is this query not using the index on the 'STATUS' Column?
    I've already tried using optimizer hints and regathering the stats on the table, but the execution plan still remains the same, i.e. it still uses a FTS.
    I have tried this command also:-
    exec dbms_stats.gather_table_stats('GECS','GEPS_CS_SALES_ORDER_HEADER',method_opt=>'for all indexed columns size auto',cascade=>true,degree=>4);
    inspite of this, the query is still using a full table scan.
    The table has around 55 Lakh records, across 60 columns. And because of the FTS, the query is taking a long time to execute. How do i make it use the index?
    Please help.
    Edited by: user10047779 on Mar 16, 2010 6:55 AM

    If the cardinality is really as skewed as that, you may want to look at putting a histogram on the column (sounds like it would be in order, and that you don't have one).
    create table skewed_a_lot
    as
       select
          case when mod(level, 1000) = 0 then 'N' else 'Y' end as Flag,
          level as col1
       from dual connect by level <= 1000000;
    create index skewed_a_lot_i01 on skewed_a_lot (flag);
    exec dbms_stats.gather_table_stats(user, 'SKEWED_A_LOT', cascade => true, method_opt => 'for all indexed columns size auto');Is an example.

  • Setting column width in a command-line program

    Is there a way to send data to the screen in a command-line Java program that will be formatted as a number
    of columns with a set column width? I am looking for something similar to the C++ setw() I/O manipulator
    used in cout.
    Thanks,
    Steve

    If you go to: http://java.sun.com/docs/books/tutorial/essential/io/writingFiltered.html
    it will show you how to subclass a filtered output stream and add your own formatting methods.Then you can chain your new class to System.out
    like this:
    YourFilteredStream yfs = new YourFilteredStream(System.out); .
    Then:
    yfs.yourNewMethod(); goes directly to system out in the new format.

  • How can I set column width in JTable?

    How can I set column width in JTable?

    Also, read the JTable API before posting questions. You will find a link to the Swing tutorial on "How to Use Tables", which contains an example of doing exactly this.

  • How to set column width in alvgrid

    hi
    how to set column width in alvgrid.
    thanks.

    Hi,
    Check this,
    REPORT  ztest.
    DATA: BEGIN OF i_scarr_tab OCCURS 0.
            INCLUDE STRUCTURE  scarr.
    DATA: END OF i_scarr_tab.
    DATA: i_scarr LIKE TABLE OF i_scarr_tab WITH HEADER LINE,
          w_scarr LIKE LINE OF i_scarr_tab.
    DATA: o_grid      TYPE REF TO cl_gui_alv_grid,
          o_container TYPE REF TO cl_gui_custom_container.
    DATA: lt_fcat     TYPE lvc_t_fcat,
          ls_layo     TYPE lvc_s_layo,
          ls_sort     TYPE lvc_s_sort,
          lt_sort     TYPE lvc_t_sort,
          ls_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    START-OF-SELECTION.
      CALL SCREEN 9000.
    *&      Module  status_9000  OUTPUT
          text
    MODULE status_9000 OUTPUT.
      SET PF-STATUS '9000'.
      SET TITLEBAR '9000'.
    ENDMODULE.                 " status_9000  OUTPUT
    *&      Module  user_command_9000  INPUT
          text
    MODULE user_command_9000 INPUT.
      CASE sy-ucomm .
        WHEN 'BACK' OR 'EXIT'.
          SET SCREEN 0.
          LEAVE SCREEN.
      ENDCASE.
    ENDMODULE.                 " user_command_9000  INPUT
    *&      Module  init_9000  OUTPUT
          text
    MODULE init_9000 OUTPUT.
      IF o_container IS INITIAL.
        SELECT * FROM scarr INTO CORRESPONDING FIELDS OF TABLE
           i_scarr UP TO 100 ROWS.
        IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    Create a custom container control for ALV Control
          CREATE OBJECT o_container
              EXPORTING
                  container_name = 'CONTROL'.
    Create a ALV Control
          CREATE OBJECT o_grid
              EXPORTING i_parent = o_container.
          PERFORM build_field_catalgue.
          ls_layo-sel_mode = 'A'.
          CALL METHOD o_grid->set_table_for_first_display
            EXPORTING
              i_save          = 'A'
              i_default       = 'X'
              is_layout       = ls_layo
            CHANGING
              it_outtab       = i_scarr[]
              it_fieldcatalog = lt_fcat
              it_sort         = lt_sort[].
        ENDIF.
      ENDIF.
    ENDMODULE.                 " init_9000  OUTPUT
    *&      Form  build_field_catalgue
          text
    -->  p1        text
    <--  p2        text
    FORM build_field_catalgue .
      DATA: ls_fcat TYPE lvc_s_fcat.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          i_program_name         = sy-cprog
          i_internal_tabname     = 'I_SCARR_TAB'
          i_structure_name       = 'SCARR'
         i_client_never_display = 'X'
        CHANGING
          ct_fieldcat            = ls_fieldcat[]
        EXCEPTIONS
          inconsistent_interface = 1
          program_error          = 2
          OTHERS                 = 3.
      IF sy-subrc <> 0.
        MESSAGE 'FCAT Error' TYPE 'I'.
        EXIT.
      ENDIF.
      LOOP AT  ls_fieldcat.
        CLEAR ls_fcat.
        ls_fcat-fieldname = ls_fieldcat-fieldname.     "Fieldname
        ls_fcat-ref_table = ls_fieldcat-tabname.       "DDIC ref struct
        ls_fcat-inttype   = ls_fieldcat-inttype.       "Data type
        ls_fcat-outputlen = ls_fieldcat-outputlen.     "Column width
        ls_fcat-coltext   = ls_fieldcat-seltext_m.     "Column Header
        ls_fcat-seltext   = ls_fieldcat-seltext_m.     "Column Desc
        ls_fcat-ref_field = ls_fieldcat-ref_fieldname. "Reference field
        ls_fcat-ref_table = ls_fieldcat-ref_tabname.   "Reference table
        CASE  ls_fieldcat-fieldname.
          WHEN 'LUGGWEIGHT' OR 'FORCURAM'.
            ls_fcat-edit      = 'X'.
            ls_fcat-do_sum    = 'X'.
          WHEN 'URL'.
            ls_fcat-no_out = 'X'.
          WHEN OTHERS.
            ls_fcat-edit      = ' '.
            ls_fcat-do_sum    = ' '.
        ENDCASE.
        APPEND ls_fcat TO lt_fcat.
      ENDLOOP.
    ENDFORM.                    " build_field_catalgue
    check the programs bcalv_grid*.
    check this link for more detailed example.
    http://www.supinfo-projects.com/fr/2005/alv_display_fr/2/
    Regards
    Sruthi

  • 11g: can connet using SQL*PLUS, not with TOAD

    Hi
    I run into a problem with TOAD. I can't connect with my 11g database using TOAD. I don't get any messages it just gives me a little waiticon for a split second and then nothing happens. I can however connect to my 10g database using TOAD. Using SQL*Plus I can connect to both.
    I use TOAD 8.6. Do I need a newer version maybe??...

    I can connect like:
    hr/pw@xe
    or
    hr/pw@O11R1
    or directly, no problem. I can connect from SQLplus to both databases any way I want

  • Populating table using SQL*Plus

    Hi,
    I am trying to populate my destination table from the source using SQL*Plus. I keep get error message. The source table has 6 columns and the destination table has 11 columns. Data_type are different in both table. The following is my script and the output of the script:
    insert into bim_expense_element
    (select table_type_id, table_code_desc,
    table_value_4, table_value_6,
    table_description_1 &#0124; &#0124; table_description_2
    from edim_expense_element)
    SQL> /
    insert into bim_expense_element
    ERROR at line 1:
    ORA-00947: not enough values
    Please let me know what I did wrong. Thanks.
    Esther

    Hi Esther,
    You need to tell to Oracle what columns to fill in your insert like this:
    insert into bim_expense_element(bim_type_id, bim_code_desc, bim_table_value4, bim_table_value6, bim_description)
    select table_type_id, table_code_desc,
    table_value_4, table_value_6,
    table_description_1 | | table_description_2
    from edim_expense_element
    If the fields aren't of the same type you'll need to convert.
    null

  • Modifying Stored Procedue Using SQL Plus

    Can you modify an existing procedure using SQL Plus?

    you can write your own "editor"
    editproc.sql
    set feedb off echo off termout off head off trimsp on lin 10000 pages 0
    spool tmpproc.sql
    select dbms_metadata.get_ddl('PROCEDURE','&1') p from dual;
    spool off
    get tmpproc nolist
    ed
    set feedb 6 termout on
    /than, to edit procedure P in sqlplus
    SQL> @editproc P
    (... edit it ...)Procedure created.
    SQL>

  • Listener is listening but when we use sql*plus ORA-12203

    Hi all,
    listener is listening but when we use sql*plus ORA-12203
    we are trying to connect oracle database in VPN, all the configuration is ok, the listener is listening at db-server site with 1521
    we can connect with tnsping, but when we connect with
    sqlplus it not going through. any boidy has experienced this. any one can help?
    Thanks in advance

    TNSNAMES.ORA file is
    it works when i try with serice name factory through LAN, then im disconnectinag at LAN and try through VPN, it doesnt go.
    here is TNSNAMES.ORA copy .
    Beq-local.world =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (COMMUNITY = beq.world)
    (PROTOCOL = BEQ)
    (PROGRAM = oracle73)
    (ARGV0 = oracle73ORCL)
    (ARGS = '(DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))')
    (CONNECT_DATA = (SID = ORCL)
    Tcp-loopback.world =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (COMMUNITY = tcp.world)
    (PROTOCOL = TCP)
    (Host = 127.0.0.1)
    (Port = 1521)
    (CONNECT_DATA = (SID = ORCL)
    Example1.world =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (COMMUNITY = tcp.world)
    (PROTOCOL = TCP)
    (Host = Production1)
    (Port = 1521)
    (CONNECT_DATA = (SID = SID1)
    Example2.world =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (COMMUNITY = spx.world)
    (PROTOCOL = SPX)
    (Service = Server_lsnr)
    (CONNECT_DATA = (SID = ORCL)
    Example3.world =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (COMMUNITY = nmp.world)
    (PROTOCOL = NMP)
    (Server = FinanceServer1)
    (Pipe = ORAPIPE)
    (CONNECT_DATA = (SID = ORCL)
    factory =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (COMMUNITY = tcp.world)
    (PROTOCOL = TCP)
    (Host = DBSERVER)
    (Port = 1521)
    (CONNECT_DATA = (SID = MYDATABASE)
    factory1 =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (COMMUNITY = tcp.world)
    (PROTOCOL = TCP)
    (Host = 172.27.32.22)
    (Port = 1521)
    (CONNECT_DATA = (SID = MYDATABASE)
    )

  • Help Using SQL*Plus Format Commands (like TTITLE) in Packages

    Where (within a package) can/should SQL*Plus format commands such as TTITLE, COLUMN & BREAK be coded?

    A package is coded in PL/SQL.
    TTITLE, COLUMN and BREAK are SQL*Plus commands, they cannot be used in PL/SQL.
    If you want to output data (using dbms_output) in your package, you'll have to implement the features yourself. But probably just using SQL*Plus is better in your case.
    Regards,
    Rob.

  • Using sql*plus to login to oracle 9i

    I have installed Oracle 9i for windows and am trying to login using SQL*PLUS
    user: system
    pwd: manager
    Host String: BHURU
    It says TNS could resolve service name.
    I have all the services running in the admin monitor.
    Am I missing something?

    This is not a right forum to post your problem. This is SQL PL/SQL forum.
    Please post it in Database General Forum.
    Regards.
    Satyaki De.

  • Logging into ORACLE 9I using SQL*PLUS.TNS Error

    I have installed Oracle 9i for windows and am trying to login using SQL*PLUS
    user: system
    pwd: manager
    Host String: BHURU
    It says TNS could resolve service name.
    I have all the services running in the admin monitor.
    Am I missing something? Please advise.

    Can you post your tnsnames.ora file contents and listener.ora contents here?
    There may be tons of things wrong with the error actually,
    ORA-12154:     TNS:could not resolve the connect identifier specified
    Cause:     A connection to a database or other service was requested using a connect identifier, and the connect identifier specified could not be resolved into a connect descriptor using one of the naming methods configured. For example, if the type of connect identifier used was a net service name then the net service name could not be found in a naming method repository, or the repository could not be located or reached.
    Action:     
    - If you are using local naming (TNSNAMES.ORA file):
    - Make sure that "TNSNAMES" is listed as one of the values of the NAMES.DIRECTORY_PATH parameter in the Oracle Net profile (SQLNET.ORA)
    - Verify that a TNSNAMES.ORA file exists and is in the proper directory and is accessible.
    - Check that the net service name used as the connect identifier exists in the TNSNAMES.ORA file.
    - Make sure there are no syntax errors anywhere in the TNSNAMES.ORA file. Look for unmatched parentheses or stray characters. Errors in a TNSNAMES.ORA file may make it unusable.
    - If you are using directory naming:
    - Verify that "LDAP" is listed as one of the values of the NAMES.DIRETORY_PATH parameter in the Oracle Net profile (SQLNET.ORA).
    - Verify that the LDAP directory server is up and that it is accessible.
    - Verify that the net service name or database name used as the connect identifier is configured in the directory.
    - Verify that the default context being used is correct by specifying a fully qualified net service name or a full LDAP DN as the connect identifier
    - If you are using easy connect naming:
    - Verify that "EZCONNECT" is listed as one of the values of the NAMES.DIRETORY_PATH parameter in the Oracle Net profile (SQLNET.ORA).
    - Make sure the host, port and service name specified are correct.
    - Try enclosing the connect identifier in quote marks. See the Oracle Net Services Administrators Guide or the Oracle operating system specific guide for more information on naming.
    HTH
    Aman....
    Edited by: Aman.... on Oct 7, 2008 5:46 PM
    Added error info

  • Debugging procedure or packages using sql*plus reg

    Dear all,
    I am new to oracle, can any body provide me some information related to this below issues.
    a) suppose i have created a procedure using sql*plus tool then next day i wanted to debug or modify my stored procedure.
    Then what could approach using sql*plus
    b) same case if we consider for packages then for any specific stored procedure or functions what would be the approach to debug or modify using sql*plus
    yours cordination will be highly appreciate
    Thanks n regards
    Laxman

    Using SQL*Plus you can debug your stored pl/sql code only adding some "prints" in your code:
    SQL> create or replace procedure test is
      2  begin
      3  dbms_output.put_line('starting...');
      4  --do something here
      5  dbms_output.put_line('done step 1');
      6  --do something else here
      7  dbms_output.put_line('end procedure...');
      8  end;
      9  /
    Procedura creata.
    SQL> set serverout on
    SQL> exec test
    starting...
    done step 1
    end procedure...
    Procedura PL/SQL completata correttamente.Or writing logs in a log table:
    SQL> create table logtab(ts timestamp(9),mess varchar2(4000));
    Tabella creata.
    SQL> create or replace procedure test is
      2  begin
      3  insert into logtab values(systimestamp,'starting...');
      4  --do something here
      5  insert into logtab values(systimestamp,'done step 1');
      6  --do something else here
      7  insert into logtab values(systimestamp,'end procedure...');
      8  end;
      9  /
    Procedura creata.
    SQL> exec test
    Procedura PL/SQL completata correttamente.
    SQL> col ts for a40
    SQL> col mess for a40
    SQL> select * from logtab;
    TS                                       MESS
    25-DIC-09 15:33:13,656000000             starting...
    25-DIC-09 15:33:13,656000000             done step 1
    25-DIC-09 15:33:13,656000000             end procedure...Max
    [My Italian Oracle blog|http://oracleitalia.wordpress.com]

Maybe you are looking for