Insert SQLERRM in the table

CREATE OR REPLACE
PROCEDURE cdsshell.prc_drop_partition (days IN NUMBER)
AS
l_sqlerrm VARCHAR2(4000);
BEGIN
<<Code >>
EXCEPTION
WHEN OTHERS THEN
l_sqlerrm := SQLERRM;
     INSERT INTO ctrl.ctrl_typ (ctrl_id,
     ctrl_typ,
ctrl_sum,
ctrl_detail,
ctrl_status,
ctrl_object,
ctrl_mapping,
ctrl_msg_inf,
ctrl_cd_err,
event_id)
VALUES ( ctrl.csr_ctrl_id_seq.NEXTVAL,
'ERR',
'SQL',
'Partition Management',
'ER',
v_table_name,
'Partition Management from cla, cdsshell, cdactimize',
l_sqlerrm,
SQLCODE,
(SELECT event_id FROM ctrl.ctrl_event
WHERE event_status = 'P'
AND event_desc = 'Partition Management'
AND TRUNC(end_dt) = TO_DATE('31-12-9999','dd-mm-yyyy')));
END;
SHOW ERRORS;
I get error on
l_sqlerrm := SQLERRM
PL/SQL: SQL Statement ignored
and
l_sqlerrm when inserting in the table.
PL/SQL: ORA-00984: column not allowed here
Please can I know what is wrong.
Thanks.

>
CREATE OR REPLACE
PROCEDURE cdsshell.prc_drop_partition (days IN NUMBER)
AS
l_sqlerrm VARCHAR2(4000);
BEGIN
<<Code >>
EXCEPTION
WHEN OTHERS THEN
l_sqlerrm := SQLERRM;
     INSERT INTO ctrl.ctrl_typ (ctrl_id,
     ctrl_typ,
ctrl_sum,
ctrl_detail,
ctrl_status,
ctrl_object,
ctrl_mapping,
ctrl_msg_inf,
ctrl_cd_err,
event_id)
VALUES ( ctrl.csr_ctrl_id_seq.NEXTVAL,
'ERR',
'SQL',
'Partition Management',
'ER',
v_table_name,
'Partition Management from cla, cdsshell, cdactimize',
l_sqlerrm,
SQLCODE,
(SELECT event_id FROM ctrl.ctrl_event
WHERE event_status = 'P'
AND event_desc = 'Partition Management'
AND TRUNC(end_dt) = TO_DATE('31-12-9999','dd-mm-yyyy')));
END;
SHOW ERRORS;
>
I get error on
l_sqlerrm := SQLERRM
PL/SQL: SQL Statement ignored
and
l_sqlerrm when inserting in the table.
PL/SQL: ORA-00984: column not allowed here
Please can I know what is wrong.
Thanks.when all else fails Read The Fine Manual
http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/sqlerrm_function.htm

Similar Messages

  • Using variables to insert data in the table

    I want to insert datas in the table. I use constants,
    all the constants are stored properly in the table. But,
    when I use variables I get the error message
    "Too few parameters. expected 6".
    (I declared all the fields of the table as text only.)
    My program is "newt.jsp"
    <%@ page language="java" import="java.sql.*" %>
    <html>
    <head>
    <title>storing customer information in the database</title>
    </head>
    <body>
    <%
    String cno1 = request.getParameter("cno");
    String n1 = request.getParameter("n");
    String add11 = request.getParameter("add1");
    String add21 = request.getParameter("add2");
    String phone1 = request.getParameter("phone");
    String email1 = request.getParameter("email");
    Connection con = null;
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:customer"," "," ");
    Statement statement1 = con.createStatement();
    Statement statement2 = con.createStatement();
    statement2.executeUpdate("create table cust1 (cno varchar(20),n varchar(20),add1 varchar(20),add2 varchar(20),phone varchar(20),email varchar(20))");
    statement1.executeUpdate("insert into cust1 (cno,n,add1,add2,phone,email) values(cno1,n1,add11,add21,phone1,email1)");
    catch(SQLException sqle) {
    System.err.println(sqle.getMessage());
    catch(ClassNotFoundException cnfe) {
    System.err.println(cnfe.getMessage());
    catch(Exception e) {
    System.err.println(e.getMessage());
    finally {
         try {
         if(con!=null) {
              con.close();
    catch(SQLException sqle) {
    System.err.println(sqle.getMessage());
    %>
    <br><br>
    Mr./Ms. <%=n1 %> <br>
    Your datas have been stored.<br>
    </body>
    </html>
    Those who know answer please reply.
    My thanks in advance.

    I would expect your insert statement to be this:
    statement1.executeUpdate("insert into cust1 (cno,n,add1,add2,phone,email) values('"+cno1+"','"+n1+"','"+add11+"','"+add21+"','"+phone1+"','"+email1+"')");
    If you just create a string, it's not going to fill in variables into the string by magic.

  • How to find last inserted record in the table.

    Version: Oracle 10g
    I have a table called "Manufacture" and 3 columns as mfno,itemname,quantity.
    How to find last inserted record in the table "Manufacture".
    As i come to know that Rowid is not result perfect results. Please provide your inputs.

    user13416294 wrote:
    Version: Oracle 10gThat is not a version. That is a product name. A version is 10.1.0.2 or 10.2.0.4, etc.
    I have a table called "Manufacture" and 3 columns as mfno,itemname,quantity.
    How to find last inserted record in the table "Manufacture".Not possible as your data model does not cater for it. That simple.
    If there is a need to determine some order or associate some time to an entity, then that should be part of the data model - and a relationship, or one or more attributes are needed to represent that information. Thus your data model in this case is unable to meet your requirements.
    If the requirements are valid, fix the data model. In other words - your question has nothing to do with Oracle and nothing to do with rowid, rowscn or other pseudo columns in Oracle. It is a pure data modeling issue. Nothing more.

  • How to generate the insert script of the  tables data present  in an entire

    How to generate the insert script of the tables data present in an entire schema in sqlplus environment
    with out toad can you please help me please!!!!!!!!!!!!!

    HI,
    First create this function to get insert scripts.
    /* Formatted on 2012/01/16 10:41 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE FUNCTION extractdata (v_table_name VARCHAR2)
       RETURN VARCHAR2
    AS
       b_found   BOOLEAN         := FALSE;
       v_tempa   VARCHAR2 (8000);
       v_tempb   VARCHAR2 (8000);
       v_tempc   VARCHAR2 (255);
    BEGIN
       FOR tab_rec IN (SELECT table_name
                         FROM user_tables
                        WHERE table_name = UPPER (v_table_name))
       LOOP
          b_found := TRUE;
          v_tempa := 'select ''insert into ' || tab_rec.table_name || ' (';
          FOR col_rec IN (SELECT   *
                              FROM user_tab_columns
                             WHERE table_name = tab_rec.table_name
                          ORDER BY column_id)
          LOOP
             IF col_rec.column_id = 1
             THEN
                v_tempa := v_tempa || '''||chr(10)||''';
             ELSE
                v_tempa := v_tempa || ',''||chr(10)||''';
                v_tempb := v_tempb || ',''||chr(10)||''';
             END IF;
             v_tempa := v_tempa || col_rec.column_name;
             IF INSTR (col_rec.data_type, 'CHAR') > 0
             THEN
                v_tempc := '''''''''||' || col_rec.column_name || '||''''''''';
             ELSIF INSTR (col_rec.data_type, 'DATE') > 0
             THEN
                v_tempc :=
                      '''to_date(''''''||to_char('
                   || col_rec.column_name
                   || ',''mm/dd/yyyy hh24:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
             ELSE
                v_tempc := col_rec.column_name;
             END IF;
             v_tempb :=
                   v_tempb
                || '''||decode('
                || col_rec.column_name
                || ',Null,''Null'','
                || v_tempc
                || ')||''';
          END LOOP;
          v_tempa :=
                v_tempa
             || ') values ('
             || v_tempb
             || ');'' from '
             || tab_rec.table_name
             || ';';
       END LOOP;
       IF NOT b_found
       THEN
          v_tempa := '-- Table ' || v_table_name || ' not found';
       ELSE
          v_tempa := v_tempa || CHR (10) || 'select ''-- commit;'' from dual;';
       END IF;
       RETURN v_tempa;
    END;
    SET PAUSE OFF
    SET LINESIZE 1200
    SET PAGESIZE 100
    SET TERMOUT OFF
    SET HEAD OFF
    SET FEED OFF
    SET ECHO OFF
    SET VERIFY OFF
    SPOOL  GET_INSERTS.SP REP
    SELECT EXTRACTDATA('EMP') FROM DUAL;
    SPOOL OFF
    SET PAUSE  ON
    SET LINESIZE 120
    SET PAGESIZE 14
    SET TERMOUT ON
    SET HEAD ON
    SET FEED 5
    SET ECHO ON
    SET VERIFY ON
    SELECT    'insert into EMP ('
           || CHR (10)
           || 'EMPNO,'
           || CHR (10)
           || 'ENAME,'
           || CHR (10)
           || 'JOB,'
           || CHR (10)
           || 'MGR,'
           || CHR (10)
           || 'HIREDATE,'
           || CHR (10)
           || 'SAL,'
           || CHR (10)
           || 'COMM,'
           || CHR (10)
           || 'DEPTNO) values ('
           || DECODE (empno, NULL, 'Null', empno)
           || ','
           || CHR (10)
           || ''
           || DECODE (ename, NULL, 'Null', '''' || ename || '''')
           || ','
           || CHR (10)
           || ''
           || DECODE (job, NULL, 'Null', '''' || job || '''')
           || ','
           || CHR (10)
           || ''
           || DECODE (mgr, NULL, 'Null', mgr)
           || ','
           || CHR (10)
           || ''
           || DECODE (hiredate,
                      NULL, 'Null',
                         'to_date('''
                      || TO_CHAR (hiredate, 'mm/dd/yyyy hh24:mi')
                      || ''',''mm/dd/yyyy hh24:mi'')'
           || ','
           || CHR (10)
           || ''
           || DECODE (sal, NULL, 'Null', sal)
           || ','
           || CHR (10)
           || ''
           || DECODE (comm, NULL, 'Null', comm)
           || ','
           || CHR (10)
           || ''
           || DECODE (deptno, NULL, 'Null', deptno)
           || ');'
      FROM emp;
    SELECT '-- commit;'
      FROM DUAL;now run the baove select statement you will get the following insert statements
    /* Formatted on 2012/01/16 10:57 (Formatter Plus v4.8.8) */
    --'INSERT INTO EMP('||CHR(10)||'EMPNO,'||CHR(10)||'ENAME,'||CHR(10)||'JOB,'||CHR(10)||'MGR,'||CHR(10)||'HIREDATE,'||CHR(10)||'SAL,'||CHR(10)||'COMM,'||CHR(10)||'DEPTNO)VALUES('||DECODE(EMPNO,NULL,'NULL',EMPNO)||','||CHR(10)||''||DECODE(ENAME,NULL,'NULL',''''|
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7369, 'SMITH', 'CLERK', 7902,
                 TO_DATE ('12/17/1980 00:00', 'mm/dd/yyyy hh24:mi'), 800, NULL, 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7499, 'ALLEN', 'SALESMAN', 7698,
                 TO_DATE ('02/20/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1600, 300, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7521, 'WARD', 'SALESMAN', 7698,
                 TO_DATE ('02/22/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1250, 500, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7566, 'JONES', 'MANAGER', 7839,
                 TO_DATE ('04/02/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2975, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7654, 'MARTIN', 'SALESMAN', 7698,
                 TO_DATE ('09/28/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1250, 1400,
                 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7698, 'BLAKE', 'MANAGER', 7839,
                 TO_DATE ('05/01/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2850, NULL,
                 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7782, 'CLARK', 'MANAGER', 7839,
                 TO_DATE ('06/09/1981 00:00', 'mm/dd/yyyy hh24:mi'), 2450, NULL,
                 10
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7788, 'SCOTT', 'ANALYST', 7566,
                 TO_DATE ('04/19/1987 00:00', 'mm/dd/yyyy hh24:mi'), 3000, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7839, 'KING', 'PRESIDENT', NULL,
                 TO_DATE ('11/17/1981 00:00', 'mm/dd/yyyy hh24:mi'), 5000, NULL,
                 10
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7844, 'TURNER', 'SALESMAN', 7698,
                 TO_DATE ('09/08/1981 00:00', 'mm/dd/yyyy hh24:mi'), 1500, 0, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7876, 'ADAMS', 'CLERK', 7788,
                 TO_DATE ('05/23/1987 00:00', 'mm/dd/yyyy hh24:mi'), 1100, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm, deptno
         VALUES (7900, 'JAMES', 'CLERK', 7698,
                 TO_DATE ('12/03/1981 00:00', 'mm/dd/yyyy hh24:mi'), 950, NULL, 30
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7902, 'FORD', 'ANALYST', 7566,
                 TO_DATE ('12/03/1981 00:00', 'mm/dd/yyyy hh24:mi'), 3000, NULL,
                 20
    INSERT INTO emp
                (empno, ename, job, mgr,
                 hiredate, sal, comm,
                 deptno
         VALUES (7934, 'MILLER', 'CLERK', 7782,
                 TO_DATE ('01/23/1982 00:00', 'mm/dd/yyyy hh24:mi'), 1300, NULL,
                 10
                );i hope this helps .
    Thanks,
    P Prakash
    Edited by: prakash on Jan 15, 2012 9:21 PM
    Edited by: prakash on Jan 15, 2012 9:22 PM

  • Unable to insert data in the table

    Hi,
    I've a document which has a doctype that points to a URL. When I try to insert this document in the table (xmltype column), I am getting the following errors:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00263: couldn't connect to host URL port 80
    Error at line 2
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at line 1
    Can someone please suggest how should I resolve this issue?
    Thanks in advance for all your help.

    Hi,
    Have you just added a new field or you have adjusted the dimensions of the cube along with that. Any change in dimension or change in structure you need to delete the data and reload.
    Regards
    Akhan

  • Inserting records in the table

    Hi All,
    I am working on a report where we are inserting huge numbers of records from an internal table to the ztable, I have been advised that rather than inserting all the records at one time we should divide the recods into small blocks may be let's say 100,000 of each block and try inserting the blocks in the ztable. So I was just wondering if anyone of you can help me with this how can I get this?
    my internal table is it_data_table and my ztable is z_data_table.
    Thanks,
    Rajeev

    Hi,
    Rather than inserting records from the workarea it is better if you use the inetrnal table for insertion. If youu have say 50025 records than it will hit the database that many times which definitely is a performance issue.If you have an internal table say 'it' and another internal table 'it_temp' with a similiar structure, you can try something like as follows
    loop at it.
      count = count + 1.
      it_temp = it.
      append it_temp.
      if count = 10000.
        insert ztable from table it_temp accepting duplicate keys.  "to avoid a dump if there are duplicates count = 0.
        refresh it_temp.
      endif.
    endloop.
    if it_temp is not initial.
      insert ztable from table it_temp accepting duplicate keys.
    endif.
    In the above code the loop will run the number of record times but, the insert statement will run only 50025/10000 times (i.e, 5 times). After the completion of the loop we need to add the remaining 25 records (because insert will work last inside the loop when 50000 records are reached), for that we will issue the insert statement after completion of the loop, after checking the it_temp table. So the total of 50025 records would be entered in a batch of 6 inserts rather than that many inserts if using just the workarea.
    I hope this does help you in your issue.
    Thanks and Regards,
    Sachin.

  • How to insert records into the Table?

    Dear Sir,
    I'm new to JDeveloper. Now I managed to create a Frame in JDeveloper with many Text fields and a button. In the back end, I have a procedure to insert records to a table, to which I pass the values of the fields as parameters. Now I'm not getting the steps to call the PL/SQL Stored procedure when I click on the button. I'm using Oracle 9i JDeveloper version 9.0.3.1. and Oracle 9i Database.
    Please give me the complete steps to achieve my task - it is quite urgent.
    Thanking You in advance.
    Regards,
    Senthil .A. Perumal.

    The JDBC tutorial will show you how to call a stored procedure from Java:
    http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm
    One more thing, why are you using such an old version of JDeveloper? any reason not to upgrade to the 10.1.3 version of JDeveloper?
    Also you might want to look into ADF and how it makes these type of database interactions easier.
    See this demo:
    http://www.oracle.com/technology/obe/obe1013jdev/adf_swing/master_detail_page_adfswing_bc.htm

  • ORA-1013 when trying to insert data into the table

    Hi,
    While inserting record into a table, we are getting the following error:
    ORA-1013
    01013, 00000, "user requested cancel of current operation"
    I could not find any information in alert log also.
    We have a bitmap index on this table. However, we never got this error till now.
    Also i found that the tablespace who stores data has lot of space and tablespace which consists of the indexes is close to 90% full today ( i dont know what was the space available yesterday when there was error).
    I know that information i provided might be very less, but i gave as much information as i can provide.
    Can you please help me in trouble shooting this problem.
    Thank you
    Giridhar

    Sorry. i forgot to give version information
    Oracle version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    OS: SunOS 5.10
    we got it only once yesterday. only for one table. not for any other tables.
    Thanks aalap for your quick response.
    Giridhar

  • Unable to insert rows into the table

    My insert statement below is not correct, when i try run, its encoutering error "table or view does not exist".
    Basically what i am doing here is collecting the table name in FOR variable which stores the table name in this variable. This variable, i am using as table. I know this is not the proper way, please let me how can insert the complete table rows with the following code.
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM Comp WHERE 1=2;
    DECLARE
         I INTEGER DEFAULT 1;
    S VARCHAR2(50);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CABLE%' and TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    INSERT INTO TEMP SELECT * FROM c.TABLE_NAME;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    The above insert statement is not correct. How can i write proper way.
    Thanks.
    Best Regards
    Arshad

    user13360241 wrote:
    My insert statement below is not correct, when i try run, its encoutering error "table or view does not exist".
    Basically what i am doing here is collecting the table name in FOR variable which stores the table name in this variable. This variable, i am using as table. I know this is not the proper way, please let me how can insert the complete table rows with the following code.
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM Comp WHERE 1=2;
    DECLARE
         I INTEGER DEFAULT 1;
    S VARCHAR2(50);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CABLE%' and TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    INSERT INTO TEMP SELECT * FROM c.TABLE_NAME;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    The above insert statement is not correct. How can i write proper way.
    Thanks.
    Best Regards
    ArshadSTMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT := STMT || S;
    EXECUTE IMMEDIATE STMT;

  • SQL Server 2012 Management Studio: Creating a Database and a dbo Table. Inserting VALUES into the table. How to insert 8 Values for future use in XQuery?

    Hi all,
    In my SQL Server 2012 Management Studio (SSMS2012), I tried to create a Database (MacLochainnsDB) and a dbo Table (marvel). then I wanted insert 8 VALUES into the Table by using the following code:
    USE master
    IF EXISTS
    (SELECT 1
    FROM sys.databases
    WHERE name = 'MacLochlainnsDB')
    DROP DATABASE MacLochlainnsDB
    GO
    CREATE DATABASE MacLochlainnsDB
    GO
    CREATE TABLE [dbo].[marvel] (
    [avenger_name] [char] (30) NULL)
    INSERT INTO marvel
    (avenger_name)
    VALUES
    ('Hulk', 1),
    ('Iron Man', 2),
    ('Black Widow', 3),
    ('Thor', 4),
    ('Captain America', 5),
    ('Hawkeye', 6),
    ('Winter Soldier', 7),
    ('Iron Patriot', 8)
    I got the following error Message:
    Msg 110, Level 15, State 1, Line 5
    There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
    How can I correct this problem?
    Please kindly help and advise.
    Thanks in advance,
    Scott Chang
    P. S.
    The reason I tried to create the Database, dbo Table, and then to insert the VALUES is to learn the following thing:
    You can query the entire node tree with the following xquery statement because it looks for the occurrence of any node with the /* search string:
    DECLARE @x xml;
    SET @x = N'<marvel>
    <avenger_name>Captain America</avenger_name>
    </marvel>';
    SELECT @x.query('/*');
    You can query the avenger_name elements from the marvel_xml table with the following syntax:
    SELECT xml_table.query('/marvel/avenger_name')
    FROM marvel_xml;
    It returns the following set of avenger_name elements:
    <avenger_name>Hulk</avenger_name>
    <avenger_name>Iron Man</avenger_name>
    <avenger_name>Black Widow</avenger_name>
    <avenger_name>Thor</avenger_name>
    <avenger_name>Captain America</avenger_name>
    <avenger_name>Hawkeye</avenger_name>
    <avenger_name>Winter Soldier</avenger_name>
    <avenger_name>Iron Patriot</avenger_name>
    You can query the fourth avenger_name element from the marvel_xml table with the following xquery statement:
    SELECT xml_table.query('/marvel[4]/avenger_name')
    FROM marvel_xml;
    It returns the following avenger_name element:
    <avenger_name>Thor</avenger_name>

    Hi Scott,
    The master database records all the system-level information for a SQL Server system, so best practise would be not to create any user-defined
    object within it.
    To change your default database(master by default) of your login to another, follow the next steps so that next time when connected you don't have to use "USE dbname" to switch database.
    Open SQL Server Management Studio
    --> Go to Object explorer(the left panel by default layout)
    --> Extend "Security"
    --> Extend "Logins"
    --> Right click on your login, click "propertites"
    --> Choose the "Default database" at the bottom of the pop-up window.
    --or simply by T-SQL
    Exec sp_defaultdb @loginame='yourLogin', @defdb='youDB'
    Regarding your question, you can reference the below.
    SELECT * FROM master.sys.all_objects where name ='Marvel'
    --OR
    SELECT OBJECT_ID('master.dbo.Marvel') --if non empty result returns, the object exists
    --usually the OBJECT_ID is used if a if statement as below
    IF OBJECT_ID('master.dbo.Marvel') IS NOT NULL
    PRINT ('TABLE EXISTS') --Or some other logic
    What is the sys.all_objects? See
    here.
    If you have any question, feel free to let me know.
    Eric Zhang
    TechNet Community Support

  • How to insert  ':&nbsp' to the table

    hai friends,
    i have a simple problem .. i need to insert *:&nbsp* this string into the table ...but it is a bind variable ..hence it is pop up for the input values...*but i need to insert the string itself*...how can i sove this problem...
    for escaping *&* i used the *\* but i can't trap
    like,
    SQL> insert into tst_tab values(':&nbsp');
    Enter value for nbsp: john
    old   1: insert into tst_tab values(':&nbsp')
    new   1: insert into tst_tab values(':john')
    1 row created.
                             actually i need to insert ":&nbsp" as a strings but i  cant...
                             note : *:* and  *&*so please help me to solve this problem...
    regards,
    john

    SQL> set define off

  • Insert only if the table is empty

    hi all
    i am searching on the net and would like to check/confirm if it is possible to do insert based on the condition if the table is empty else do update
    i am doing bulk insert in the table but only want to do it if the table is empty
    else i wanna do update
    in the bulk insert
    the code is as follow :
        forall x in 1..tableabc.count
             insert into table_name values tableabc(x);
         exit when tbaleabc%notfound;
            end loopcan you please let me know where i can put the condition ** an example would be very helpfull.
    looking forward to all your suggestions/help

    Is this question related to your other multiple threads?
    bulk update/insert
    bulk update
    https://forums.oracle.com/forums/thread.jspa?messageID=9964721#9964721
    https://forums.oracle.com/forums/thread.jspa?messageID=9952576#9952576
    https://forums.oracle.com/forums/thread.jspa?messageID=9954587#9954587
    Where you were repeatedly told to use merge, and that if merge needed tuning then to post the information needed for a tuning request?
    Instead of doing that you went back and edited out most of the content of your posts and start up yet another thread, where you have been advised to use merge but you will not because you have tested it and it is too slow.
    This is forum abuse and is leading to a lot of other members wasting their time repeating information spread across all your other threads and you need to stop it immediately.

  • How to insert data in the table without  join and using mapped rule value

    1.Table SOL_K
    A B C D – Columns Name
    C D A B –Coulmns Values Defined (Rule --- Defined)
    2.SECOND table SIC_K
    SIC_ K
    A B C D
    Kamal Micky NULL MANOJ
    3 Table SIC_Mapping
    Same Columns A B C D based On Table SOL_K defined rule
    I want to insert values(from table SIC K) into table SICMapping Table with the help of first table(SOL_K)(mapped rule)
    Required Result SIC_Mapping Table
    The output will be come like this.
    A B C D — Columns Name
    NULL MANOJ Kamal Micky ---- Came based on defined Mapping Rule

    What's your database version?
    That's a funny requirement.
    How about :
    select case sol.a
              when 'A' then sic.a
              when 'B' then sic.b
              when 'C' then sic.c
              when 'D' then sic.d
           end as a
         , case sol.b
              when 'A' then sic.a
              when 'B' then sic.b
              when 'C' then sic.c
              when 'D' then sic.d
           end as b
         , case sol.c
              when 'A' then sic.a
              when 'B' then sic.b
              when 'C' then sic.c
              when 'D' then sic.d
           end as c
         , case sol.d
              when 'A' then sic.a
              when 'B' then sic.b
              when 'C' then sic.c
              when 'D' then sic.d
           end as d
    from sol_k sol, sic_k sic
    ;XQuery can do the trick too :
    SQL> SELECT *
      2  FROM XMLTable(
      3   'for $i in ora:view("SIC_K")/ROW
      4    return element r {
      5     for $j in ora:view("SOL_K")/ROW/child::*
      6     return element {name($j)} {$i/child::*[name()=$j]/text()}
      7    }'
      8   columns
      9     a varchar2(30) path 'A'
    10   , b varchar2(30) path 'B'
    11   , c varchar2(30) path 'C'
    12   , d varchar2(30) path 'D'
    13  );
    A          B          C          D
               MANOJ      Kamal      Micky
    Edited by: odie_63 on 29 juin 2011 22:07

  • Relate to Inserting Record in the Table

    Dear Expert ,
    Records are getting inserted in a table to a perticular limit...then it stops inserting..
    when i delete all the records from that table...then again it starts inserting the new records. Again stops after a perticular limit...
    and goes on....
    why is it so..?
    this command is ok or not
    ALTER TABLE CCT_RM_DETAIL_HRI
    STORAGE (NEXT_EXTENT 50M, MAX_EXTENTS 200M,MIN_EXTENTS 1,INITIAL_EXTENT 100M, PCT_INCREASE 50M);

    I am not getting any error. And you've checked the logs too? Nothing there too?
    So what is occuring? Please understand, this is not normal behaviour for a database. Something somewhere is going wrong. But you need to explain to us in detail what you are doing, what you expect to happen and what actually happens. Because we cannot guess and we are not telepathic.
    Cheers, APC

  • Using Case statement to insert,update,delete  the tables

    Hi All,
    I have to check the databse ,
    if it is developement then
    insert/update/delete values in tables;
    if it staging then
    insert/update/delete values in tables;
    if it is production then
    insert/update/delete values in tables;
    thers is function available to check the current database
    For doing the about i am trying to write CASE statement like this
    SELECT function,
    case
    when fun = 'developement' then insert into table1 values ('abcd','1234')
    when fun = 'staging' then insert into table1 values ('abcd','1234')
    when fun= 'production' then insert into table1 values ('abcd','1234')
    else null
    from dual
    its throughing me an error
    please help
    Thanks,

    Hi,
    You can use CASE staement any place where an expression is expected.
    For example, in:
    UPDATE  table_a
    SET     col1 = exp1
    ,       col2 = exp2
    WHERE   exp3 = exp4;all the expressions are labled lke expn.
    Note that table_a, col1 and col2 are not expressions: you must hard-code these names, or use dynamic SQL.
    So it's okay to say:
    UPDATE  table_a
    SET     col1 = CASE
                       WHEN  db = 'development'  THEN  0
                       WHEN  db = 'staging'      THEN  1
                   END
    ,       col2 = CASE
                       WHEN  db = 'development'  THEN  NULL
                       WHEN  db = 'staging'      THEN  col2
                   END
    WHERE   db != 'production';In this example:
    in the development database, col1 is set to 0 and col2 is set to NULL
    in the staging database, col1 is set to 1 and col2 is unchanged (that is, set to what it already was)
    in the production database, nothing is changed (the WHERE condition is always FALSE)

Maybe you are looking for

  • Mail crashes when I try to add a rule

    I'm running 10.6.8. I have a somewhat large and complex mail folder. Everytime I try to add a rule mail gives me the spinning beach ball of death. I'm tried throwing away the rule plist. I've tried a clean install on a new disk with nothing on the di

  • BDC for KE52

    Hi All,      I have created a BDC for KE52 to change the Profit center. The problem is when ever i am executing the BDC it is not going to the initial screen although i have done the RECORDING properly which run from the initial screen. If i am chang

  • Breakdown of sub equipment

    Hi Gurus, I have an equipment that has sub equipments.  If I create an maintenance order for the sub equipment, I want the breakdown of the sub equipment to reflect in the main equipment.  Can I do that? Thanks, Paul

  • How to rename a particular node in an xml

    Hi All, I have a table called xmltable and I have inserted the below row in to the table, INSERT INTO XMLTABLE VALUES (4,'<?xml version="1.0"?> <Node_1 empID="202" empName="Pro1" oper="Update"> <Node_2 empID="20" empName="Pro2" oper="Update"> <Node_3

  • I need to send group email and forward group email?

    I need to send group emails and forward group emails and dont find that capability with ipad or iphone