SQL Select Commands.

I am on 10G and can not get this statement to work. Any help would be great.
I need to determine percentage of profite. The first step I was able to do which was deterine the profite for all items.
"Select title, (retail-cost) profit from books;" (subtracting cost from retail) I need to divide the profit by the cost then multipy by 100 to determine the profit percentage.
Any help.
Thanks
Loosing my mind.

Simply
Select title, (retail-cost) profit, ((retail-cost)*100/cost) PercenProfit from books;"
{code}
thx                                                                                                                                                                                                                                       

Similar Messages

  • SQL: combined SELECT-command possible???

    Hello Experts!
    in the enclosed SQL-command I'm actually selecting from table EKPO only the open POs with no reference in order-history (EKBE). Now I want to enlarge/combine this command in that way that additionally records from order history (EKBE) with a special movement type in EKBE are selected on top.
    Is it possible or do need a second select-command in the Z-application???
    THANKS for a response.
    Regards,
    Bernd
    select ebeln ebelp menge meins txz01 bukrs matkl
             werks matnr mtart labnr elikz pstyp from ekpo as b
        into (itab-bestnr, itab-pos, itab-best_mng,itab-meins, itab-text,
             itab-bukrs, itab-matkl, itab-werks, itab-matnr, itab-mtart,
             itab-labnr, itab-elikz, itab-pstyp)
        where ( mtart = 'ETMW' or mtart = 'ETVB' ) and
              menge > 0 and
              loekz <> 'L' and
              loekz <> 'S' and
              elikz <> 'X' and  " Endliefer-KZ
              ebelp not in ( select ebelp from ekbe where
                                    ebeln = b~ebeln ).
    Edited by: Bernd Thielemann on Jul 21, 2008 4:37 PM

    The result should be all open orders!
    1.) no EKBE
    2.) EKBE but quantity of goods receipt (WE) is less than quantity of the PO
    3.) intercompany-POs (stock transport order) have other movement types (like LFS and WA) which do not effect the status of the open PO until good-receipt movement is posted in the receiving plant .
    First/Second condition is realized. Third condition is the gap until now.
    Regards,
    Bernd

  • Maximum length of SQL*Plus Command?

    I'm typing a long query into SQL*Plus (Linux, version 9.2.0.1... yes, I know it's ancient).
    If I run this query, all works fine:
    select 'update myauditing_table set test_details='''||grantee||''' where myaudit_refno=''A.FE'';' from (select case when upper(value) in ('DBO','TRUE')  then (select agg_concat(grantee) from dba_tab_privs where table_name='AUD$')
    else (select 'AUDIT_TRAIL is set to: '||value from dual) end as grantee from v$parameter where upper(name)='AUDIT_TRAIL' order by grantee);
    'UPDATEMYAUDITING_TABLESETTEST_DETAILS='''||GRANTEE||'''WHEREMYAUDIT_REFNO=''A.F
    update myauditing_table set test_details='AUDIT_TRAIL is set to: DB' where myaud
    it_refno='A.FE';(In other words, is SQL that generates other SQL: if AUDIT_TRAIL is set to something interesting, tell me who has access to the AUD$ table. And it's working fine... the agg_concat function mentioned is simply Tom Kyte's stragg function under another name, as lifted word-for-word from http://www.sqlsnippets.com/en/topic-11591.html)
    Now this is what happens if I take out the linebreak after the mention of AUD$, so that the command is submitted as one single line of code:
    SQL> select 'update myauditing_table set test_details='''||grantee||''' where myaudit_refno=''A.FE'';' from (select case when upper(value) in ('DBO','TRUE')  then (select agg_concat(grantee) from dba_tab_privs where table_name='AUD$') else (select 'AUDIT_TRAIL is set to: '||value from dual) end as grantee from v$parameter where upper(name)='AUDIT_TRAIL' order by grantee);
    SP2-0734: unknown command beginning "s set to: ..." - rest of line ignored.The error message indicates that the text has been 'split' at the 'AUDIT_TRAIL is set to...' bit, so that "s set to" is being treated as a new command, which is of course syntactically invalid. There is definitely no other change in text between the two versions, apart from the removal of a carriage return before the "else" statement.
    Possibly a coincidence, but the first "s" in "s set to" appears at position 258 in the entire text... close to a possible 255 or 256 character limit, perhaps?
    The same problem happens whether I run the command as a script (@mysql.sql) or typed in directly into a client SQL*Plus session. Is there some inherent limit to the length of commands that SQL*Plus can process in this version? My code runs fine on 10g and 11g databases/clients, whether it's on one line or two. Anyone know of a bug in 9i regarding this? And if there's a workaround (other than the obvious one of upgrading, of course!)

    As mentioned, it's choking at the 258th character, not the 240th. Also, it's a SELECT statement, not a COPY command (one relates to the database, the other is an internal SQL*Plus feature). And someone else also kindly pointed out that SQL*Plus has a command limit length (i.e., database-related commands) of 2500 characters. So I don't think that's the issue.
    I can be a bit more specific about this one now, though. I've a sequence of Solaris boxes running 9.2.0.1 up, and the results are that 9.2.0.1 is affected; and it's a problem for 9.2.0.7:
    SQL> select * from v$version;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - 64bit Production
    PL/SQL Release 9.2.0.1.0 - Production
    CORE    9.2.0.1.0       Production
    TNS for Solaris: Version 9.2.0.1.0 - Production
    NLSRTL Version 9.2.0.1.0 - Production
    SQL> select 'update myauditing_table set test_details='''||grantee||''' where myaudit_refno=''A.FE'';' from (select case when upper(value) in ('DBO','TRUE')  then (select agg_concat(grantee) from dba_tab_privs where table_name='AUD$') else (select 'AUDIT_TRAIL is set to: '||value from dual) end as grantee from v$parameter where upper(name)='AUDIT_TRAIL' order by grantee);
    SP2-0734: unknown command beginning "s set to: ..." - rest of line ignored.And...
    SQL> select * from v$version;
    BANNER
    Oracle9i Enterprise Edition Release 9.2.0.7.0 - 64bit Production
    PL/SQL Release 9.2.0.7.0 - Production
    CORE    9.2.0.7.0       Production
    TNS for Solaris: Version 9.2.0.7.0 - Production
    NLSRTL Version 9.2.0.7.0 - Production
    SQL> select 'update myauditing_table set test_details='''||grantee||''' where myaudit_refno=''A.FE'';' from (select case when upper(value) in ('DBO','TRUE')  then (select agg_concat(grantee) from dba_tab_privs where table_name='AUD$') else (select 'AUDIT_TRAIL is set to: '||value from dual) end as grantee from v$parameter where upper(name)='AUDIT_TRAIL' order by grantee);
    SP2-0734: unknown command beginning "s set to: ..." - rest of line ignored.But in 10.2.0.1, the problem disappears.
    I am not sure, but it is perhaps related to metalink note 285913.1, since we did get some ORA-00600: internal error code, arguments: [qernsRowP], [1] errors in the alert log with a slightly different version of the above query. Changing the query obviously alters the test, though, so it may be completely unrelated.
    Either way, I think it's definitely a version-specific SQL*Plus bug (though it would be nice if any other 9i owners out there could try it and report back!)
    Anyway, the workaround is simply to submit the command on two separate lines, wherever possible. And of course... to upgrade.

  • Using a VARCHAR2 in a SELECT command

    I'm trying to query for a given path in a hierarchy of products. However, I want to be able to have it return multiple values. So, I created a string in my function below that returns identifiers like "(34, 43, 54)" to be used in a SELECT IN. The function works fine, but the select command fails. How can I get the SELECT to work?
    CREATE TABLE PRODUCT (
      PRODID NUMBER,
      PARENTID NUMBER,
      CATID NUMBER,
      ALIAS VARCHAR2(128)
    CREATE OR REPLACE FUNCTION FIND_PRODS_BY_PATH
    (CAT_ID IN NUMBER, IN_PATH IN VARCHAR2) RETURN VARCHAR2 IS
      PROD_IDS VARCHAR2(1024);
    BEGIN
      PROD_IDS := '(';
      FOR PROD IN (SELECT PRODID, SYS_CONNECT_BY_PATH(ALIAS, '/') AS PATH FROM PRODUCT
        WHERE CATID=CAT_ID CONNECT BY PRIOR PRODID=PARENTID)
      LOOP
        IF REGEXP_LIKE(PROD.PATH, IN_PATH) THEN
          IF LENGTH(PROD_IDS) > 1 THEN
            PROD_IDS := PROD_IDS || ', ';
          END IF;
          PROD_IDS := PROD_IDS || PROD.PRODID;
        END IF;
      END LOOP;
      PROD_IDS := PROD_IDS || ')';
      RETURN PROD_IDS;
    END FIND_PRODS_BY_PATH;
    *** Doesn't like the varchar2 returned from the function ***
    SELECT * FROM PRODUCT WHERE PRODID IN FIND_PROD_BY_PATH(5, '/my/product/path/*');
    Error report:
    SQL Error: ORA-01722: invalid number
    *** Function works ***
    SELECT FIND_PROD_BY_PATH(5, '/my/product/path/*') FROM DUAL;
    FIND_PRODS_BY_PATH(5, '/my/product/path/*')                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    (301152, 301202, 301252, 301302, 301403)

    Your function is effectively returning a single string, which is not automatically devived into individual tokens for using in the IN clause.
    How to circumvent this is best described here:
    http://www.oracle.com/technology/oramag/oracle/07-mar/o27asktom.html
    (search for "Varying IN Lists")

  • Exporting SQL Select statement to spreadsheet

    Hi all, basic question that I couldn't find the answer to while googling and searching the Oracle documentation.
    What is the code for exporting the result of a SQL Select statement to a spreadsheet such as Excel or Calc? In Oracle SQL Developer I tried saving the output as an XML file but it did not come out properly and I tried using EXPORT at the end of the statement but it gave an error message and I am not sure if this is the right command or what the syntax is. Thanks.

    Here's an example of one way to create CSV files that most spreadsheet type applications are able to read...
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.
    There are other methods for specifically creating Excel workbooks with multiple sheets etc. and details can be found in the SQL and PL/SQL FAQ at the top of the forum:
    {message:id=9360007}

  • Problem on select command for table AFKO-GSTRS,AFKO-GSUZS

    Hi all Abaper,
    I faced a problem on using select command to select out the records from table AFKO (Production order header)
    If i want to select out records that
    AFKO-GSTRS >= 14.4.2006 (schedule start date)
    AFKO-GSUZS >= 00:00:00 (schedule start time)
    AFKO-GSTRS <= 15.4.2006 (schedule start date)
    AFKO-GSUZS <= 00:00:00 (schedule start time)
    The select statement:
    SELECT AUFNR RSNUM DISPO GSTRS GSUZS
            INTO TABLE GT_AFKO FROM AFKO
                    WHERE
           ( GSTRS >= GV_ST_DATE AND GSUZS >= GV_ST_TIME )
       AND ( GSTRS <= P_DATE AND GSUZS <= P_TIME ).
    PS.  if GV_ST_DATE = 14.4.06,  GV_ST_TIME = '00:00:00'
            P_DATE AND = 15.4.06,      P_TIME = '00:00:00'
    This statement just select out records in
    between 14-15.4.06 and at time '00:00:00'.
    some Production orders at 14.04.06 ,'09:00:00' will be filter out.
    I know the problem on that system just consider the date and time separately.
    Does anyone know how to link the date and time up? or does any data type allow for combination of date and time data?
    Thx for your reply in advance~

    Thx Amit and Vijay.
    The data type for GV_ST_DATE, P_DATE are <b>SY-datum</b>
    and GV_ST_TIME, P_TIME  are <b>SY-UZEIT</b>
    Actually, P_DATE & P_TIME are user input parameters.
    The records I wanna get are the period back 24 hrs from P_DATE & P_TIME.
    For example, if user input P_DATE = 15.04.2006,
                               P_TIME = '10:00:00'.
    Then records selected out should be:
    from 14.04.2006 , '10:00:00' TO 15.04.2006, '10:00:00'
    if production order schedule start = <b>14.04.2006 , 09:00:00</b>
    it will be <b>included</b>.
    if production order schedule start = <b>15.04.2006 , 01:00:00</b>
    it will be <b>excluded</b>.
    However, the following statement cannot get the desired records.
    Select....
    where GSTRS >= GV_ST_DATE AND GSUZS >= GV_ST_TIME
    AND   GSTRS <= P_DATE AND GSUZS <= P_TIME.
    Since GV_ST_TIME & P_TIME are both = '00:00:00',
    for Production order( sch start date = 14.04.2006 , sch start time = 09:00:00 ), '09:00:00' is greater than '00:00:00' but it is not less than '00:00:00'.
    Thus, this Pro. Order will be filtered!!
    However can improve my SQL statement to get the desired data?

  • Long select command

    hey, I have a real long select command and it goes down to the next row of my sql*plus. when i try to perform it it says the from statement is in the wrong spot but its just getting confused. how do i fix this?

    Just manually edit the query and add adequate line feeds. That would make the query readable too.

  • SELECT Command on Associative Array

    Guys,
    I have a question on associative arrays in ORACLE.
    I m working on one assignment where I am not allowed to create any object into the database e.g. Create temporary tables, use of cursors etc.
    For data manipulation i used associative array, but at the end i want to show that result in pl/SQL developer.
    I know that I can't use select command on associative arrays.
    Any alternative/solution for it?
    Also is there any way that i can write the contents of associative array to a .csv file?

    user13478417 wrote:
    I m working on one assignment where I am not allowed to create any object into the database e.g. Create temporary tables, use of cursors etc.Then cease to use Oracle - immediately. As you are violating your assignment constraints.
    ALL SQL and anonymous PL/SQL code blocks you send to Oracle are parsed as cursors. And as you are not allowed to use cursors, it will be impossible to use Oracle as cursors is exactly what Oracle creates... and creates a lot of. For every single SQL statement. And every single anonymous PL./SQL block.
    For data manipulation i used associative array, Why? Arrays is a poor choice in Oracle as a data structure most times as it is inferior in almost every single way to using a SQL table structure instead.
    Pumping data into an array? That already severely limits scalability as the array requires expensive dedicated server (PGA) memory. It does not use the more scalable shared server (SGA) memory.
    Manipulating data in an array? That requires a "+full structure scan+" each time as it does not have the indexing and partitioning features of a SQL table.
    Running a SQL select on an array? That is using a cursor. That also means copying the entire array structure, as bind variable, from the PL/SQL engine to the SQL engine. An excellent way to waste memory resources and slow down performance... but hey you can still shout "+Look Ma, no --brains-- hands, I'm not using any SQL tables as dictated by my assignment!+".... +<sigh>+
    Any alternative/solution for it?You mean besides using Oracle correctly ?
    You could reload the shotgun and shoot yourself in the other foot too. That should distract you for from the pain in the first foot.

  • Sql delete command

    I have one table emp, here emp having 3 fields, names like empno,ename,job.
    SQL> select *From emp;
    EMPNO ENAME JOB
    23 SEKHAR JAVA
    34 RAVI DBA
    12 ramesh testing
    I want to delete empno column and job column do not use rowid,fields.
    I want output like this
    SQL> select *From emp;
    EMPNO ENAME JOB
    kumar
    ravi
    raja
    karhtik
    send me command.
    thanks in advance.

    Hi,
    By using unused command you can delate the specific column either logically and physically.
    Logically drop the unused columns:-
    ALTER TABLE table_name SET UNUSED (column_name);
    ALTER TABLE table_name SET UNUSED (column_name1, column_name2);
    Physically drop the unused columns:-
    ALTER TABLE table_name DROP UNUSED COLUMNS;
    ALTER TABLE table_name DROP COLUMN column_name;
    ALTER TABLE table_name DROP (column_name1, column_name2);
    I think its helpful to you.
    Regards,
    Narendra G.

  • ** Is it possible to give select command from multiple tables in JDBC

    Hi Friends,
    Is it possible to give the select command to select data from multiple tables directly in the 'Query SQL statement' in JDBC sender communication channel ? (Instead of Stored Procedure)
    Thanking you.
    Kind Regards,
    Jeg P.

    Hi,
    here is a sample:
    Table #1
    Header
    Name EmpId Status
    Jai 5601 0
    Karthik 5579 0
    Table #2
    Name Contactnumber
    Jai 9894268913
    Jai 04312432431
    Karthik 98984110335
    Karthik 04222643993
    select Header.Name, Header.EmpId, Item.Contactnumber from Header,Item where Header.Name = (select min(Header.Name) from Header where Header.Status = 0) and Header.Name = Item.Name
    Regards Mario

  • SQL describe command not running in JSP

    Hello All,
    i hope u all will be enjoying ur lives :)
    i have a problem that when i run the SQL describe command it gives me the error that Invalid SQL Statement...
    the command syntax is
    desc tablename; OR describe tablename;
    and i am doing it like that
    ResultSet rs = stmt.executeQuery("describe CF");
    where CF is the name of table..
    actually what i want to do is get the columns and its datatypes dynamically.. means that i want i get all the tables first from database then whichever table i select i can display its records and also add delete and modify the records...
    if anyone have already code of this ..please email me at
    [email protected]
    i will be very very thank ful for that..
    otherwise tell me the solution of the above problem :(
    thanx in advance
    RANA

    You can get all the information about the table using the meta data. Run a dummy query (I don't think it even needs to return any results), and then grab the meta data
    from the result set:
    ResultSet rs = null;
    ResultSetMetaData rsmd;
    int numcolumns = 0;
    Vector field = new Vector();
    rs = statement.executeQuery( "select * from mytable where field='nevermatchme'");
    rsmd = rs.getMetaData();
    numcolumns = rsmd.getColumnCount();
    for ( int i = 1 ; i <= numcolumns ; i++ ) {
    field.add( rsmd.getColumnName(i) );
    You now have a Vector with one element per database field, each containing a String of that fields name. I believe it is also possible to get field
    type, etc also the MetaData.

  • SQL COPY command Weird outcome!!

    Hi,
    On Friday I have refreshed two tables from one database to another using SQL COPY command.But today I found something weird that two tables have data which were before refresh.
    the command I hadused:
    copy from test/xxxx@db3to test/yyyy@db1 insert master_table using select * from master_table;What could be the reason.??

    COPY Command is used to COPY database table from one Schema to another Schema.

  • Need to execute SQL PLUS commands from C# code

    Hello all,
    This is my first question here and hopefully I will get my solution :)
    Right now we are doing 3 tasks manually
    1) Clearing everything from a DB.
    We use sql plus and execute this :
    RAMNIVAS_CI/RAMNIVAS_CI@orclwex3
    set pages 0
    set lines 80
    spool c:\delete_objects_CI
    select 'drop '||object_type||' '||object_name||';'
    from user_objects;
    spool off
    start c:\delete_objects_CI.lst
    purge recyclebin;
    set pages 100
    select count(*) from user_objects;
    RAMNIVAS_CI/RAMNIVAS_CI@orclwex3 are the username and pwd which gets input when we paste entire thing in sql plus
    2) Then we restore that DB again using sql plus to do it using the command:
    imp file=CL.DMP log=CL.log buffer=1000000 fromuser=RAMNIVAS_CL touser=RAMNIVAS_CL statistics=none grants=n commit=y
    3)Execute sql scripts on it using sql developer. (This is not hard I guess coz I know we can use oracle client)
    4) Take backup using this command:
    exp RAMNIVAS_CI/RAMNIVAS_CI@ORCLWEX3 file=CI.dmp log=CI.log direct=y compress=y buffer=1000000 grants=n statistics=none
    Is there anything I cna do to execute SQL PLUS commands using c#?

    Hi,
    You can execute OS commands via the SHELL function provided in .NET. See the MSDN for more info.
    Some of the things you can do directly from .NET via ODP and PLSQL, some not.
    1) Dropping the user objects can be done via a plsql procedure where you open a cursor for "select 'drop '||object_type||' '||object_name||';' ..." and then use EXECUTE IMMEDIATE to execute the resulting commands. You can invoke the procedure via ODP.
    2) IMP is an exe, not a sqlplus command, so you're not actually using sqlplus there. You can still use the SHELL command though to invoke that.
    3) Executing SQL Scripts via ODP.NET is not something you can do very easily. If you search the threads here you should be able to find some solutions others have come up with to parse the file and execute the statements one by one, but there's nothing built in to ODP to execute a script file.
    You may want to just shell out to sqlplus user/pwd@db @scriptfile.sql but you may have issues trying to track down errors if any occurred, as I'm not sure where they go in that case.
    4) just as with IMP, EXP is an exe, so you could shell out to that.
    Corrections/comments welcome.
    Greg

  • Running a SQL*Plus command from Java

    I have a requirement to run SQL* Plus commands from Java. The results as they would appear in SQL*Plus window or spool file should be captured and stored in a table.
    For example,
    SQL> select * from dual;
    D
    X
    1 row selected;
    SQL>
    All the lines above should be stored for later use.
    Could any one give pointers?
    Thanks,
    Ravi

    <p>
    Hi,
    </p>
    <p>
    <strong><font face="Courier New">
    public class RuntimeExecApp {
     public static void main(String args[]) throws IOException
      Runtime r = Runtime.getRuntime();
      r.exec(&quot;C:\\Oracle\\sqlplus.exe&quot;);
    }</font></strong>
    </p>
    <p>
    Kuba 
    </p>
    Message was edited by:
    KUBA

  • Oracle SQL Select query takes long time than expected.

    Hi,
    I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
    The query is as follows.
    select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
    This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
    The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
    Kindly advice what is going wrong??
    Regards,
    Purushotham

    SQL> @/alcatel/omc1/data/query.sql
    2 ;
    9 rows selected.
    Execution Plan
    Plan hash value: 3745571015
    | Id | Operation | Name |
    | 0 | SELECT STATEMENT | |
    | 1 | SORT ORDER BY | |
    | 2 | NESTED LOOPS | |
    | 3 | NESTED LOOPS | |
    | 4 | TABLE ACCESS FULL | PARAMETERTABLE |
    |* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
    |* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    |* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
    |* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
    Predicate Information (identified by operation id):
    5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
    6 - access("P1"."ID"="F1"."ID")
    7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
    8 - access("F1"."ID"="ID")
    Note
    - rule based optimizer used (consider using cbo)
    Statistics
    0 recursive calls
    0 db block gets
    0 consistent gets
    0 physical reads
    0 redo size
    0 bytes sent via SQL*Net to client
    0 bytes received via SQL*Net from client
    0 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    9 rows processed
    SQL>

Maybe you are looking for

  • Driver issue after Downgradin​g to Windows 7 (Pavilion 17-f081no)

    So,i went to downgrade yesterday,and have had this problem ever since. Nothing works except one USB port at the right side of the laptop (when looked at front),no usb connections,no wireless or wired connection,nothing. They are all dead,including SD

  • Scalability ADF-BC vs ADF-JPA

    anyone do you have material that can compare the scalabitlity between ADF-BC vs ADF-JPA (Toplink). my opinion still the direct JDBC is the fastest one. F

  • Linking Source and Target language PDFs with ref. points

    Dear adobe folks, I am new to this forum, so my excuses if such a topic has already been discussed. I could not find anything: In my department, we are often handling English source and language-specific target pdfs, for example to do a review of a t

  • Confusion about moving my iphoto library to another hard drive.

    My startup drive is nearly full and I'd like to my my iPhoto library (I still have iphoto 4) and photos to another internal drive to free up some space. I've found brief help pages on how to do this, but I find them vague and unclear. Do I make an ex

  • Sending Java Objects to Flex

    Hi All ,    I have a Flex+Java Application , which is running fine , and i am sending the List of employess to Flex from my Java(Struts) like :(In flex i am using HTTPService)(Employee is a java bean) XStream xstream = new XStream(); EmpDAO dao=new E