SQLPLUS define  variables for creating table.

I am doing the following in SQLPLUS
define l_date = to_char(sysdate,'yyyy')
define l_name = "'mytable'"
define l_tn = &l_name||&l_date
SQL> select &l_name||&l_date from dual;
old 1: select &l_name||&l_date from dual
new 1: select 'mytable'||to_char(sysdate,'yyyy') from dual
'MYTABLE'||
mytable2010
But when I use in this way I don't get YEAR.
SQL> select '&l_tn' from dual;
old 1: select '&l_tn' from dual
new 1: select 'mytable' from dual
'MYTABL
mytable
I want to create table in sqlplus using the following command:
create table &l_tn(x number)
Please let me know what I am doing wrong here.

Hi,
SQL functions (like TO_CHAR) and operators (like ||) are not executed in SQL*Plus commands (like DEFINE).
Test your variables after defining them; you'll see what I mean
define l_date = to_char(sysdate,'yyyy')
PROMPT     &l_date = l_dateOutput:
to_char(sysdate,'yyyy') = l_dateThat is, l_date is being set to a 23-character string, which starts with 't' and contains '(', ',' and ')', all of which are illegal in file names (probably; system-dependent).
I think you wanted it set to a 4-character string, such as '2010'.
Use the COLUMN ... NEW_VALUE (or ... OLD_VALUE) command to set a substitution variable to the results of a SQL calculation.
I think you're trying to do something like this:
COLUMN     year_col     NEW_VALUE     l_date
SELECT     TO_CHAR (SYSDATE, 'YYYY')     AS year_col
FROM     dual;
define l_name = mytable
CREATE TABLE  &l_name&l_date
...

Similar Messages

  • How to define variable for value range in Bex Query?

    Hi
    How to define variable for Keyfig. value range on runtime like characteristic in Bex Query?
    Example: On runtime user select one of the following condition:
    1)User want to those records where amount is greater than $1000
    2)User want to those records where amount is greater than $1000 and less than $5000
    3)User want to those records where amount is greater than and equal to $1000

    Hi ,
    Need to Use exceptions & conditions for this scenario's  & need to create variable for exceptions based on condtions.
    Below document provides steps how to make selections at run time for a kfg.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60b33a28-dca2-2d10-f3b2-d2096b460b1e?QuickLink=index&overridelayout=true&48842368468641
    Regards,
    Seshu.P

  • System Variable For Internal table count

    Can anybody tell me what the system variable for internal table count?
    I just wants to know how many recoreds are there in my internal table ?
    Regards,
    pandu.

    Hi ,
    DESCRIBE TABLE <itab> [LINES <l>] [OCCURS <n>] [KIND <k>].
    If you use the LINES parameter, the number of filled lines is written to the variable <lin>. If parameter, the you use the OCCURS value of the INITIAL SIZE of the table is returned to the variable <n>. If you use the KIND parameter, the table type is returned to the variable <k>: ‘T’ for standard table, ‘S’ for sorted table, and ‘H’ for hashed table.
    using variable
    SY-TFILL
    After the statements DESCRIBE TABLE, LOOP AT, and READ TABLE, SY-TFILL contains the number of lines in the relevant internal table.
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3798358411d1829f0000e829fbfe/content.htm
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Feb 21, 2008 4:53 PM

  • ORA-47401: Realm violation for create table on SYS.REGISTRY$HISTORY

    Hi i have 10.2.0.4 db with db vault on RHEL4. I am applying jan2010 patch on it. After applying patch when i am trying to recompile views i am facing the below error.(I am executing this after starting up database in upgrade mode)
    SQL> @$ORACLE_HOME/cpu/view_recompile/view_recompile_jan2008cpu.sql
    BEGIN
    ERROR at line 1:
    ORA-47401: Realm violation for create table on SYS.REGISTRY$HISTORY
    ORA-06512: at line 16
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
    With the Partitioning, Oracle Label Security, OLAP, Data Mining,
    Oracle Database Vault and Real Application Testing options
    [oracle@rac1 view_recompile]$
    Plese help me on this.
    Regards,
    snp

    Perhaps you are tripping over Bug 6928496. I suspect best bet is to open a SR with Oracle rather than hope for similar occurance within the user community.

  • Reg : class for creating table control

    hi everyone,
                 is there any class for creating table control?my requirement is
                  created 2 custom containers,one for alv display and other for table control display.
    For alv i used cl_gui_alv->set_table_first_display,likewise any class for creaitng table control?????????
    pleas find me a solution......
                      thanks in advance......

    Hi,
    You can use the class CL_TABLECONTROL for creating table control and the method SET_VALUES shall be used to fill values for tha tabcntrl.
    Else, you can use the Table Control Wizard to create the tabcntrl easily.
    Regards,
    Renjith Michael.

  • Is it a third party API for creating table in J2ME?

    I am a newbie to J2ME and i would like to know that whther is there any third party API for creating table in J2ME beside using Canvas to draw the table? Please help...

    its not the "L shape" that holds it better rather the higher GAUSS rating on the older connector.
    Apple redesigned the NEW magsafe to be weaker AND of a diff. design with lower neodymium magnetic gauss rating for a reason
    people at coffee shops etc were getting their macbooks yanked to the ground when someone tripped over the cord.
    The new neodymium is a N35 gauss and the older Lshape was N40 or N45 gauss (too tight)
    I know what youre talking about, but Apple redesigned it that way for several good reasons, despite it "coming out easier" on the bed for which ,
    as Apple Inc. states, it is "not intended to be used" (nor in laps, couches...etc.)

  • Stored procedure for creating tables

    Is it possible to create a stored procedure which only contains create tables? I prepare everything on an environment and want to transfer everything, except the data, on anothe environment. Therfore I thought of an stored procedure which does everything automatically. Additional I want to create a package which contains all necessary stored procedures (which are already finished). Is it better to insert the create-table-lines in the package?
    Thanks for your help!

    PL/SQL is not the appropriate tool for this.
    What does Oracle RDBMS products like Apex use to install? SQL*Plus scripts. A combination of SQL code and anonymous PL/SQL blocks.
    This is also what we use to install any one of a dozen Oracle systems we have developed.. it is as simple as running 'sqlplus "/ as sysdba" @installer <tablespace> <schema> <password>'.
    Trying to do this type of thing in PL/SQL... lots of disadvantages, lots of complexities, and very little (if any) benefit.

  • How to define selectedRowKeys for a table?

    Hi,
    I have a table defined in jsff page and it is not defined using searchResultsIterator. Instead it is defined using CollectionModel.
    How can I define the selectedRowKeys attribute for this table?
    Table code:
    <af:table value="#{pageFlowScope.PipeProvidesListBean.pipeProvidesCollectionModel}"
    var="row" emptyText="#{inventoryUIBundle.TABLE_EMPTY_TEXT_NO_ROWS_YET}"
    selectionListener="#{pageFlowScope.PipeProvidesListBean.providesPipeSelectionListener}"
    rowBandingInterval="0" id="t1"
    rowSelection="#{pageFlowScope.PipeProvidesListBean.rowSelection}"
    binding="#{pageFlowScope.PipeProvidesListBean.resultsTable}">
    <af:column sortProperty="id" sortable="false" headerText="#{inventoryUIBundle.ID}" id="c5">
    <af:commandLink action="summary" id="cl1" actionListener="#{bindings.openSubTaskForSummary.execute}">
    <af:setActionListener from="#{row.oid}" to="#{objectId}"/>
    <af:outputText value="#{row.id}" id="ot1"/>
    </af:commandLink>
    </af:column>
    <af:column headerText="#{inventoryUIBundle.NAME}" id="c1">
    <af:outputText value="#{row.name}" id="ot5"/>
    </af:column>
    </af:table>
    Thanks
    Ravi

    You can limit the number of rows using a trigger. Below is quick and dirty example that has not been fully tested.
    test@ORCL> create table rowlimit (col1 number);
    Table created.
    Elapsed: 00:00:00.34
    test@ORCL> create or replace trigger limit_rows
      2  before insert
      3  on rowlimit
      4  declare
      5    v_count number;
      6  begin
      7     select count(*)
      8     into v_count
      9     from rowlimit;
    10
    11     if v_count >= 4 then
    12       raise_application_error(-20000, 'Table can have no more then 4 rows');
    13     end if;
    14  end;
    15  /
    Trigger created.
    Elapsed: 00:00:00.09
    test@ORCL> insert into rowlimit values(1);
    1 row created.
    Elapsed: 00:00:00.03
    test@ORCL> insert into rowlimit values(2);
    1 row created.
    Elapsed: 00:00:00.00
    test@ORCL> insert into rowlimit values(3);
    1 row created.
    Elapsed: 00:00:00.00
    test@ORCL> insert into rowlimit values(4);
    1 row created.
    Elapsed: 00:00:00.00
    test@ORCL> insert into rowlimit values(5);
    insert into rowlimit values(5)
    ERROR at line 1:
    ORA-20000: Table can have no more then 4 rows
    ORA-06512: at "TEST.LIMIT_ROWS", line 9
    ORA-04088: error during execution of trigger 'TEST.LIMIT_ROWS'
    Elapsed: 00:00:00.04
    test@ORCL> commit;
    Commit complete.
    Elapsed: 00:00:00.00
    test@ORCL> select count(*) from rowlimit;
      COUNT(*)
             4
    Elapsed: 00:00:00.00
    test@ORCL>

  • Passing variable to create table command

    Is it possible to pass a varaiable to the create table command.
    At each yearend we have to manually create copy tables of the years data these are held as table_name_2002 etc. The original table only holds the current years data. We would like to create a script to create all these, along the lines of
    CREATE TABLE table_name_||'&year'
    AS
    SELECT * FROM table_name;
    As his is run every year we would like to be able to run the same script, and just pass in the year each time.
    however i cannot get this to work, is there another way round this?
    Thanks

    try this (assuming the year is passed in as the first runtime parameter):
    CREATE TABLE table_name_&1.
    AS
    SELECT * FROM table_name;
    otherwise if you do not want to work with runtime parameters you can do it like this so that v_year is only asked for once:
    define vv_year="&v_year."
    CREATE TABLE table_name_&vv_year.
    AS
    SELECT * FROM table_name;
    or you can ask for it your self, which is probably the nicest way of dealing with it ;) :
    accept v_year char prompt Please input the year:
    CREATE TABLE table_name_&v_year.
    AS
    SELECT * FROM table_name;
    HTH,
    Lennert

  • How to define variable for below scenario in report

    Hi,
         iam designing a report in that report  if i enter the user selection was for Fiscal Year/Qtr = 2008/Q3, the data retrieved will be the Fiscal Year/Quarter selection and for the last 20 Launch Year/Quarters based on the Fiscal Year/Quarter i.e. from Launch Year/Qtr 2003/Q4 to 2008/Q3.
         how to acheive this in report. plz help me

    Hi ,
    Need to Use exceptions & conditions for this scenario's  & need to create variable for exceptions based on condtions.
    Below document provides steps how to make selections at run time for a kfg.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/60b33a28-dca2-2d10-f3b2-d2096b460b1e?QuickLink=index&overridelayout=true&48842368468641
    Regards,
    Seshu.P

  • How to define variable for smart form in coding

    hi all,
    i have to create a variable for smart form which is i already created in  smart form but facing some sort of difficulties.
    for example:
    DATA:  formname  TYPE ZCCCL_GOODS_RECEIPT.(SMART FORM NAME)
    DATA:  formname  TYPE ZCCL_RETURN_VENDOR. (SMART FORM NAME)
    DATA:  formname   TYPE ZCCL_GOODS_RESERVATION.(SMART FORM NAME)
    CASE in_mseg-bwart.
      WHEN '101' or '105' or '321'.
      formname = 'FORM_RECEIPT'.
      WHEN '122' or '124'.
      formname = 'FORM_RETURN_VENDOR'.
      WHEN '201' or '261'.
      formname = 'FORM_GOODS_RESERVATION'.
    ENDCASE.
    So this the logic im using but it gave me error like:
    Type  ZCCCL_GOODS_RECEIPT is unknown.
    Kindly tell me if this coding is wrong than what should i use.
    Thanks.

    Declare variable name for smartform as
    Formname type TDSFNAME in import tab.

  • V3.0, NLS_LENGTH_SEMANTICS byte vs. char for CREATE TABLE

    Hi,
    When creating a new table (via "New Table" or "Data Load ...")
    NLS_LENGTH_SEMANTICS of table columns are always in byte even when NLS_LENGTH_SEMANTICS
    is set to char for the instance (and so as default for all sessions) and has not explicitly changes for the current session.
    Is there a way to change this behavior or could this be a gebnerell problem in 3.0.
    I would like SQL Developer to use the standard settings of the instance as long as I don't set it different for a session.
    Please give me a littel hint how to solve this issue.
    Thanks in advance.
    Andre
    --2011/07/15-------------------------------------------------------------------------------------------
    Hello,
    I'm not sure wether or not this is a too complicated or just as silly question.
    However it's still an issue for me.
    It would be great if someone could at least confirm or refuse it.
    Hoping for an answer- Thank you again!
    Andre
    Edited by: andreml on Jul 15, 2011 2:10 AM
    Edited by: andreml on Jul 15, 2011 2:11 AM

    Hi,
    If you click on any given table in the Connections view, an object viewer opens for that table. Its column tab lists all columns with attributes for column_name, data_type, and so on. The data_type info includes the length semantics, e.g., VARCHAR2(30 BYTE).
    Regards,
    Gary Graham
    SQL Developer Team

  • Is it planned to add feature for creating tables and lists in Adobe Edge Reflow?

    First of all, thank you very much guys for all your work!
    In my opinion Adobe Edge Reflow is missing quite important features, like creating tables and lists. For me it's a reason why I can't switch to Reflow. Any plans for implementing these? Is there any place where I can see the list of planned feature implementation? Didn't find it.

    Missing tables is a big one for me too, especially when doing data-grids. My last prototype was using multiple responsive data-grids where I used the simpler essential/optional hide column approach, instead of stacking or scrolling the data. I had used Reflow in the past for basic content prototypes... but had to do this one by hand... took longer. Using divs for this did not collapse properly in all the browsers, plus the back-end team use widgets that only generate tables. Here is the example:
    http://www.topwebworks.com/assets/test/prototype/riocompass_prototype_v1

  • Minimum privileges for creating table

    I wanted to know of the minimum set of privileges for creating a table in Oracle 11g database. First I created a schema and granted the create table privilege to the schema. When I tried to create a table in the schema, it was giving a message of like privileges required on the tablespace. Granting the resource privilege grants the unlimited quota on all the tablespaces including SYSTEM and SYSAUX tablespace which may not be an ideal scenario. So, my query is that what are the minimum set of privileges for creating a table in Oracle 11g database.
    I hope, my question is clear.
    Please revert with the reply to my query.
    Regards

    Hi,
    If you are going to use the read only :
    SQL> create user anar identified by anar;
    User created.
    SQL> grant create session, select any table, select any dictionary to anar;
    Grant succeeded.
    SQL> conn anar/anar
    Connected.
    SQL> create table test(id number);
    create table test(id number)
    ERROR at line 1:
    ORA-01031: insufficient privileges
    SQL> desc test.test
    Name                                      Null?    Type
    ID                                                 NUMBER
    SQL> insert into test.test values (1);
    insert into test.test values (1)
    ERROR at line 1:
    ORA-01031: insufficient privileges
    SQL> update test.test set id = 15;
    update test.t set id = 15
    ERROR at line 1:
    ORA-01031: insufficient privileges
    Thank you

  • Funktion for "Create Table" Statement

    Dear all,
    I am looking for a function to create a "create table"-SQL statement from an existing SAP Dictionary table. Does anybod y know a abap function to do this. With the SQL Statement I want to create the table in an external Database.
    Kind Regards
    Roman Becker

    Hi please enter db_create* in se37 and pick the desired function needed.
    here are few Function modules for u.
    DB_CREATE_TABLE
    DB_CREATE_TABLE_AS_SELECT
    DB_CREATE_TABLE_AS_SELECT_S
    DB_CREATE_TABLE_S              As DB_CREATE_TABLE, also returns the generated statements
    Satish

Maybe you are looking for

  • Why won't bearshare read my ipod?

    I need help

  • Calling report through URL

    Hi, How to call a report through a URL?. If there are more than one bind parameter in the report ,how the values for each parameter to be supplied through the URL and what should be separating character b/w parameter values (is it ',' or '&' or somet

  • J2iun tr.code

    Dear all, My client want to utilize the amount so we are trying in j2iun tr.code the problem in j2iun cenvat BED is not tallying with trial balance . all the trial balances as per standard SAP please advise in j2iun 7,00,0000 but as per trial balance

  • How to create custom class for Swing compnents

    import java.awt.Color; import java.awt.Font; import javax.swing.JLabel; import javax.swing.*; public class SampleJFrame extends JFrame {     public static void main(String[] args) {         SampleJFrame frame      =      new SampleJFrame();         J

  • HT1491 I am trying to reset my security questions and I am not getting any reset email. Can somebody help me?

    I am making my first purchase on iTunes and since it is my first purchase, the security questions were asked.  I forgot the answers to the security questions and requested for an email to reset my answers. It has been three days now and I still haven