Servlet sql delete record

Hi, thanking you in advance for your help. I want to delete a record, but the following code:
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
HttpSession session = request.getSession();
String userID = (String)session.getAttribute("edituserID");
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println("userID is " +userID+ "<br>");
String connectionURL = "jdbc:mysql://localhost/cms_college";
Connection connection=null;
try{
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection(connectionURL, "root", "");
Statement st = connection.createStatement();
st.executeUpdate("DELETE *from users WHERE userID="+"'"+userID+"'" );*
*catch (Exception e){*
*pw.println(e);*
*pw.println("<a href='ListUserServlet.jsp'><br>Deleted</a>");*
gives an error:
userID is 16
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' from users WHERE userID='16'' at line 1
Deleted

Thanks matey. You were right. I put a * in where it wasn't needed. It's obvious now, but I just couldn't see it.

Similar Messages

  • Sql delete record where duplicate in part of raw

    in sql table  i need to delete all record where the time between it  1 or 2 minute or the same and must be the same id but keep the firest record
        ID             Time                            SN   SD   WE   
    FW
        10    2014-06-30 19:17:37.000    I    0    100    0
        10    2014-06-30 19:17:42.000    I    0    100    0
        10    2014-06-30 19:17:46.000    I    0    100    0
        10    2014-06-30 19:17:58.000    I    0    100    0
        10    2014-06-30 20:37:46.000    I    0    100    0
    or
         ID             Time                            SN   SD   WE   
    FW
        10    2014-07-01 21:10:33.000    I    0    100    0
        10    2014-07-01 21:11:06.000    O    0    100    0
        10    2014-07-02 20:53:36.000    I    0    100    0
        10    2014-07-02 20:53:38.000    I    0    100    0
        10    2014-07-02 20:54:33.000    O    0    100    0
        10    2014-07-02 20:54:41.000    O    0    100    0
        10    2014-07-02 20:55:22.000    o    0    100    0
    to be
        ID             Time                            SN   SD   WE   
    FW
        10    2014-06-30 19:17:37.000    I    0    100    0
        10    2014-06-30 20:37:46.000    I    0    100    0
    and
        ID             Time                            SN   SD   WE   
    FW
        10    2014-07-01 21:10:33.000    I    0    100    0
        10    2014-07-02 20:53:36.000    I    0    100    0

    i think this
    SELECT *
    --DELETE t
    FROM NEWFP.dbo.CHECKINOUT t
    WHERE EXISTS (
    SELECT 1
    FROM NEWFP.dbo.CHECKINOUT
    WHERE USERID = t.USERID
    AND CHECKTIME < t.CHECKTIME
    AND CHECKTIME >= DATEADD(minute,-5,t.CHECKTIME)
    Once you're happy that it gives you the required records just comment the SELECT *, uncomment the DELETE part and execute
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Does a SQL Server record delete (row or multiple related rows) stand up to the official definition of record destruction for a system that needs to meet DOD 5015.2 requirements?

    I am being asked by our records manager about whether or not when a delete occurs from SQL Server that it can stand up in court as true if we declare that the record has been destroyed and is no longer available.  In other words, are there ways in
    which forensic experts could analyse the disk and actually recover records that have been deleted from a table or tables?  If so, then we would be in error if we declare that the records have been deleted.
    Steve

    Agree with Erland here deleted records can be read from transaction log and there are tools in market which can do it unless all Virtual log file( you can consider this as small log files) which were part of that transaction has been underwritten by new
    information.  If they are still there and VLF is not reutalized it can be read. I an not exactly sure about the mechanism how it does it
    Here you gently point out a not-so-small error in my post. I said that the data would be zeroed out after the log has been truncated. But that is not the case. As you say, the data will be there until the log has run around. Which can take a long time with
    a large log file.
    Erland I dont agree to fact that Ghost cleanup task would take minutes to just clean up things in case_large chunk data_ is deleted there are of factors involved and it can take more than couple of hour(in my case it did). Actually time frame is not definite
    Yes, you are correct. I wanted to diminsh the issue with the ghost records, since they may be the smallest issue in this case. The log file, and most of all the backups are a lot more significant.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Error in html  Page while deleting record.

    Hi all
    Can any one help me out in solving this problem
    Actually i am getting some error while deleting record in html page created usin OAF.
    Error.
    Exception Details.
    oracle.apps.fnd.framework.OAException: oracle.jbo.DMLException: JBO-26080: Error while selecting entity for xxPersonDetailsEOP
         at oracle.apps.fnd.framework.OAException.wrapperInvocationTargetException(Unknown Source)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
         at xxt.oracle.apps.ak.webui.xxPersonMainCO.processFormRequest(xxPersonMainCO.java:54)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at OA.jspService(_OA.java:71)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    ## Detail 0 ##
    java.sql.SQLException: ORA-00911: invalid character
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:282)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:639)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:185)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:503)
         at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:1029)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:535)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1126)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3001)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
         at oracle.jbo.server.OracleSQLBuilderImpl.doEntitySelect(OracleSQLBuilderImpl.java:730)
         at oracle.jbo.server.EntityImpl.doSelect(EntityImpl.java:5594)
         at oracle.apps.fnd.framework.server.OAEntityImpl.doSelect(Unknown Source)
         at oracle.jbo.server.EntityImpl.lock(EntityImpl.java:3847)
         at oracle.apps.fnd.framework.server.OAEntityImpl.lock(Unknown Source)
         at oracle.jbo.server.EntityImpl.beforePost(EntityImpl.java:4328)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:4472)
         at oracle.apps.fnd.framework.server.OAEntityImpl.postChanges(Unknown Source)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:2996)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:2807)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:1971)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2173)
         at oracle.apps.fnd.framework.server.OADBTransactionImpl.commit(Unknown Source)
         at xxt.oracle.apps.ak.server.xxPersonAMImpl.deletePersonMethod(xxPersonAMImpl.java:49)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
         at xxt.oracle.apps.ak.webui.xxPersonMainCO.processFormRequest(xxPersonMainCO.java:54)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at OA.jspService(_OA.java:71)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    java.sql.SQLException: ORA-00911: invalid character
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:282)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:639)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:185)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:503)
         at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:1029)
         at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:535)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1126)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3001)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3043)
         at oracle.jbo.server.OracleSQLBuilderImpl.doEntitySelect(OracleSQLBuilderImpl.java:730)
         at oracle.jbo.server.EntityImpl.doSelect(EntityImpl.java:5594)
         at oracle.apps.fnd.framework.server.OAEntityImpl.doSelect(Unknown Source)
         at oracle.jbo.server.EntityImpl.lock(EntityImpl.java:3847)
         at oracle.apps.fnd.framework.server.OAEntityImpl.lock(Unknown Source)
         at oracle.jbo.server.EntityImpl.beforePost(EntityImpl.java:4328)
         at oracle.jbo.server.EntityImpl.postChanges(EntityImpl.java:4472)
         at oracle.apps.fnd.framework.server.OAEntityImpl.postChanges(Unknown Source)
         at oracle.jbo.server.DBTransactionImpl.doPostTransactionListeners(DBTransactionImpl.java:2996)
         at oracle.jbo.server.DBTransactionImpl.postChanges(DBTransactionImpl.java:2807)
         at oracle.jbo.server.DBTransactionImpl.commitInternal(DBTransactionImpl.java:1971)
         at oracle.jbo.server.DBTransactionImpl.commit(DBTransactionImpl.java:2173)
         at oracle.apps.fnd.framework.server.OADBTransactionImpl.commit(Unknown Source)
         at xxt.oracle.apps.ak.server.xxPersonAMImpl.deletePersonMethod(xxPersonAMImpl.java:49)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
         at oracle.apps.fnd.framework.server.OAUtility.invokeMethod(Unknown Source)
         at oracle.apps.fnd.framework.server.OAApplicationModuleImpl.invokeMethod(Unknown Source)
         at xxt.oracle.apps.ak.webui.xxPersonMainCO.processFormRequest(xxPersonMainCO.java:54)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
         at OA.jspService(_OA.java:71)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
         at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
         at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)

    Paste your code.
    -Anand

  • Delete records in a table and at the same time print out for reference

    I am working on a req to delete some records from a table and at the same time, record/print the deleted records in the outstream (DBMS_OUTPUT.PUT_LINE)
    DECLARE
    v_rec_po hst_po%ROWTYPE;
    BEGIN
    DELETE FROM hst_po po
    WHERE abbrpoid = '&opportunity_code'
    AND updatedby = (SELECT employeeid
    FROM tes_employee
    WHERE name = &emp_name)
    AND audittimestamp BETWEEN TO_DATE ('&start_timestamp',
    'DD-MON-YYYY HH24:MI'
    AND TO_DATE ('&end_timestamp',
    'DD-MON-YYYY HH24:MI'
    END;
    I was thinking of using returning into and then using DBMS_output to pull out the delted records, but there will be multiple rows deleted fro this statements. I am stuck here..Can anyone help

    How about:
    SQL> create table t
      2  (x int)
      3  /
    Table created.
    SQL> insert into t
      2  select rownum
      3    from all_objects
      4   where rownum <= 10
      5  /
    10 rows created.
    SQL> declare
      2     cnt pls_integer;
      3  begin
      4     delete from t;
      5     cnt := sql%rowcount;
      6     dbms_output.put_line ('Removed: '||to_Char (cnt));
      7  end;
      8  /
    Removed: 10
    PL/SQL procedure successfully completed.Edited by: Alex Nuijten on Jun 4, 2009 8:58 AM

  • What is the best approach to track deleted records

    Dear all,
    We have build a CMS platform which is based on SQL server 2012 tables structure hosted in Azure.
    We have build on top of this some REST API method in order to access data from any type of client application.
    The issues we need to solved now is what his the best way to track deleted records in order that client application gets informed through web service about deleted data from our CMS.
    We were thinking of 2 path actually :
    - having a kind of Ghost table for each of our real table where deleted records will be inserted into ( physical delete ). This would mean adding as many Ghost tables as we have production tables
    - Adding a IsDeleted flag to each of our table which will be set to true when a record is deleted from our CMS ( logical delete ). This would means adding an IsDelete field to each of our tables, create and update all our store procedure and web services
    in order to taken in account that new filter criteria to fetch our records. Quite huge job
    Will there be any other approach ?
    We are looking the best solution with minimum impact on our current solution
    reagards
    Your knowledge is enhanced by that of others.

    Hello,
    @Tom, based on your question
    "The question would be what do you need to do with the deleted records and how long do you need to keep them?"
    When records is deleted, then I simply want to delete them and informed any client application about deleted items in order to get data in Sync. I will not have any reporting on deleted data !
    The only reason of tracking delete tables items, is simply to informed client application through web service sync about the data to be ignored. Client application have a caching database records for performance reason and is is require to not used data
    from that local storage which has been reported as deleted by the SQL server on Aure.
    Does this make sense ?
    regards
    Your knowledge is enhanced by that of others.

  • I need the code to delete record in the database not in the form???

    I need the code to delete record in the database not in the form...
    because when i execute a form always insert the datas in the data base but i want insert value on a text file and delete in the data base the record whith this value of text file.
    i'm spanish an my english is bad sorry.
    thank, javier

    Well, I fail to understand why you want to complicate easy things, but anyway you can do that by using TEXT_IO within Forms to create text file (see Forms builder help), and UTL_FILE package to read it within Pl/Sql : you could create a stored procedure, and call it from Forms passing the file name as parameter. See UTL_FILE documentation

  • Deleting record on basis of master table ID

    Hello,
    SQL> desc news
    Name                                      Null?    Type
    NEWS_ID                                   NOT NULL NUMBER(14)
    NEWS_DATE                                          TIMESTAMP(0)
    SL_ID                                              NUMBER(2)
    HEADING                                            VARCHAR2(3120)
    DESCRIPTION                                        VARCHAR2(3900)
    SQL> desc news_location
    Name                                      Null?    Type
    NEWS_ID                                            NUMBER(14)
    COUNTRY                                            VARCHAR2(32)
    REGION                                             NUMBER(2)
    SQL> desc news_product
    Name                                      Null?    Type
    NEWS_ID                                            NUMBER(14)
    PRODUCT_CATEGORY_ID                       NOT NULL NUMBER(14)
    PRODUCT                                            VARCHAR2(27)
    SQL> desc news_service
    Name                                      Null?    Type
    NEWS_ID                                            NUMBER(14)
    SERVICE_ID                                NOT NULL NUMBER(14)
    SRVIS                                              VARCHAR2(16)
    SQL> desc news_info
    Name                                      Null?    Type
    NEWS_ID                                            NUMBER(14)
    SOURCE                                             VARCHAR2(203)
    ORIGIONAL_NEWS                                     VARCHAR2(3900)
    HEADING                                            VARCHAR2(3110)
    SQL> select count(*) from news where TO_CHAR(news_date,'YYYY') <  2012;
      COUNT(*)
          8759I am trying to delete news that are published before 2012 but detail tables consists child record on basis of news_id. Certainly simple delete query will not work
    Please advise and thanks in anticipation

    Thanks again for favorable replies
    SQL> alter table news_info drop constraint NEWS_INFO_FK;
    Table altered.
    SQL> alter table news_info add constraint NEWS_INFO_FK FOREIGN KEY (news_id) REF
    ERENCES   news(news_id) on delete cascade enable novalidate ;
    Table altered.
    SQL> alter table news_info modify constraint NEWS_INFO_FK validate ;
    Table altered.
    SQL> alter table news_location drop constraint NEWS_LOCATION_FK;
    Table altered.
    SQL> alter table news_location add constraint NEWS_LOCATION_FK FOREIGN KEY (news
    _id) REFERENCES   news(news_id) on delete cascade enable novalidate ;
    Table altered.
    SQL> alter table news_location modify constraint NEWS_LOCATION_FK validate ;
    Table altered.
    SQL> alter table news_PRODUCT drop constraint NEWS_PRODUCT_FK;
    Table altered.
    SQL> alter table news_PRODUCT add constraint NEWS_PRODUCT_FK FOREIGN KEY (news_i
    d) REFERENCES   news(news_id) on delete cascade enable novalidate ;
    Table altered.
    SQL> alter table news_PRODUCT modify constraint NEWS_PRODUCT_FK validate ;
    Table altered.
    SQL> alter table news_SERVICE drop constraint NEWS_SERVICE_FK;
    Table altered.
    SQL> alter table news_SERVICE add constraint NEWS_SERVICE_FK FOREIGN KEY (news_i
    d) REFERENCES   news(news_id) on delete cascade enable novalidate ;
    Table altered.
    SQL> alter table news_SERVICE modify constraint NEWS_SERVICE_FK validate ;
    Table altered.
    SQL> delete from news where TO_CHAR(news_date,'YYYY') <  2008 ON DELETE CASCADE;
    delete from news where TO_CHAR(news_date,'YYYY') <  2008 ON DELETE CASCADE
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    SQL> select constraint_name, constraint_type, table_name, delete_rule
      2    from user_constraints
      3   where constraint_name= 'NEWS_SERVICE_FK';
    CONSTRAINT_NAME                C TABLE_NAME                     DELETE_RU
    NEWS_SERVICE_FK                R NEWS_SERVICE                   CASCADE
    SQL> select constraint_name, constraint_type, table_name, delete_rule
      2    from user_constraints
      3   where constraint_name= 'NEWS_PRODUCT_FK';
    CONSTRAINT_NAME                C TABLE_NAME                     DELETE_RU
    NEWS_PRODUCT_FK                R NEWS_PRODUCT                   CASCADE
    SQL> select constraint_name, constraint_type, table_name, delete_rule
      2    from user_constraints
      3   where constraint_name= 'NEWS_LOCATION_FK';
    CONSTRAINT_NAME                C TABLE_NAME                     DELETE_RU
    NEWS_LOCATION_FK               R NEWS_LOCATION                  CASCADE
    SQL> select constraint_name, constraint_type, table_name, delete_rule
      2    from user_constraints
      3   where constraint_name= 'NEWS_INFO_FK';
    CONSTRAINT_NAME                C TABLE_NAME                     DELETE_RU
    NEWS_INFO_FK                   R NEWS_INFO                      CASCADE
    SQL> delete from news where TO_CHAR(news_date,'YYYY') <  2008 ON DELETE CASCADE;
    delete from news where TO_CHAR(news_date,'YYYY') <  2008 ON DELETE CASCADE
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    SQL>Edited by: Christy H. on Jan 17, 2013 1:58 AM
    I removed ON DELETE CASCADE and ran again delete from news where TO_CHAR(news_date,'YYYY') <  2008; Wow deleted!!
    This forum is miracle to learn oracle. Thanks from the bottom of my heart

  • Deleted records are not captured in 2lis_02_itm

    Hi SDN,
    I am extracting Purchase order records(more specifically Outline agreements ME23K) from 2LIS_02_ITM.
    When I delete a PO with Purchase Order History in ME23K and save it I am able to see the change recorded in LBWQ and now i run the collective run in LBWE I can see the total coloum in RSA7 filling with value 1.
    Now when i try to see the record in in RSA7 it is showing nothing and also when the delta infopackage is run zero records are being pulled.
    In a nutshell I am missing the deleted records with Extractor.
    Is there any way I can see the actual delta record sitting in LBWQ after the deletion is posted.
    Please help me out folks

    Hi,
    check this notes:
    FAQ: Business Warehouse (BW) in Purchasing
    SAP Note Number: [459517|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes/sdn_oss_bw_bct/~form/handler%7b5f4150503d3030323030363832353030303030303031393732265f4556454e543d444953504c4159265f4e4e554d3d343539353137%7d]
    Note [527490|https://websmp130.sap-ag.de/sap(bD1kZSZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=527490] - BW: Deletion indicator not set correctly - Part 2
    Regards
    Andreas

  • Deleting records in a table based a collection

    I wanna delete records in a table which do not match the records in the collection.
    Since the collection is a pl/sql collection I cannot do it like
    v_t v_type;
    DELETE FROM sample WHERE flex_name NOT IN (SELECT * FROM TABLE(v_type(SELECT * FROM v_t)));
    is there any other alternative to do the same ?

    Hi
    please use this code it is working
    DATA :
       BEGIN OF fs_itab,
          first(2) TYPE c,
          second TYPE c,
          third TYPE c,
          fourth(2) TYPE c,
       END OF fs_itab.
    DATA :
    t_itab LIKE STANDARD TABLE OF fs_itab.
    CLEAR fs_itab.
    fs_itab-first = 'AA'.
    fs_itab-second = 'Z'.
    fs_itab-third = 'Y'.
    fs_itab-fourth = 'AA'.
    APPEND fs_itab TO t_itab.
    CLEAR fs_itab.
    fs_itab-first = 'AA'.
    fs_itab-second = 'Z'.
    fs_itab-third = 'Y'.
    fs_itab-fourth = 'AA'.
    APPEND fs_itab TO t_itab.
    CLEAR fs_itab.
    fs_itab-first = 'AA'.
    fs_itab-second = 'Z'.
    fs_itab-third = 'Y'.
    fs_itab-fourth = 'CC'.
    APPEND fs_itab TO t_itab.
    CLEAR fs_itab.
    fs_itab-first = 'BB'.
    fs_itab-second = 'P'.
    fs_itab-third = 'Q'.
    fs_itab-fourth = 'DD'.
    APPEND fs_itab TO t_itab.
    CLEAR fs_itab.
    fs_itab-first = 'BB'.
    fs_itab-second = 'P'.
    fs_itab-third = 'Q'.
    fs_itab-fourth = 'BB'.
    APPEND fs_itab TO t_itab.
    LOOP AT t_itab INTO fs_itab.
      IF fs_itab-first NE fs_itab-fourth.
        DELETE TABLE t_itab FROM fs_itab.
      ENDIF.
    ENDLOOP.
    LOOP AT t_itab INTO fs_itab.
      WRITE :
         / fs_itab-first,
           fs_itab-second,
           fs_itab-third,
           fs_itab-fourth.
    ENDLOOP.
    Regards
    Pavan

  • [DW MX 2004] DELETE RECORD

    Hi,
    I can't DELETE RECORD in LOCAL SERVER (MySQL Server 5.0)
    and REMOTE SERVER , but INSERT AND UPDATE WORKS.
    Page code is
    <?php require_once('../Connections/connpuntofermo.php');
    ?>
    <?php
    session_start();
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";
    // *** Restrict Access To Page: Grant or deny access to this
    page
    function isAuthorized($strUsers, $strGroups, $UserName,
    $UserGroup) {
    // For security, start by assuming the visitor is NOT
    authorized.
    $isValid = False;
    // When a visitor has logged into this site, the Session
    variable
    MM_Username set equal to their username.
    // Therefore, we know that a user is NOT logged in if that
    Session
    variable is blank.
    if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only
    certain
    users based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
    $isValid = true;
    // Or, you may restrict access to only certain users based
    on their
    username.
    if (in_array($UserGroup, $arrGroups)) {
    $isValid = true;
    if (($strUsers == "") && true) {
    $isValid = true;
    return $isValid;
    $MM_restrictGoTo = "index.php";
    if (!((isset($_SESSION['MM_Username'])) &&
    (isAuthorized("",$MM_authorizedUsers,
    $_SESSION['MM_Username'],
    $_SESSION['MM_UserGroup'])))) {
    $MM_qsChar = "?";
    $MM_referrer = $_SERVER['PHP_SELF'];
    if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
    if (isset($QUERY_STRING) && strlen($QUERY_STRING)
    > 0)
    $MM_referrer .= "?" . $QUERY_STRING;
    $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar .
    "accesscheck=" .
    urlencode($MM_referrer);
    header("Location: ". $MM_restrictGoTo);
    exit;
    ?>
    <?php
    function GetSQLValueString($theValue, $theType,
    $theDefinedValue = "",
    $theNotDefinedValue = "")
    $theValue = (!get_magic_quotes_gpc()) ?
    addslashes($theValue) : $theValue;
    switch ($theType) {
    case "text":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" :
    "NULL";
    break;
    case "long":
    case "int":
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
    break;
    case "double":
    $theValue = ($theValue != "") ? "'" . doubleval($theValue) .
    "NULL";
    break;
    case "date":
    $theValue = ($theValue != "") ? "'" . $theValue . "'" :
    "NULL";
    break;
    case "defined":
    $theValue = ($theValue != "") ? $theDefinedValue :
    $theNotDefinedValue;
    break;
    return $theValue;
    if ((isset($_GET['ID'])) && ($_GET['ID'] != "")) {
    $deleteSQL = sprintf("DELETE FROM news WHERE ID=%s",
    GetSQLValueString($_GET['ID'], "int"));
    mysql_select_db($database_connpuntofermo, $connpuntofermo);
    $Result1 = mysql_query($deleteSQL, $connpuntofermo) or
    die(mysql_error());
    $deleteGoTo = "ok-cancella.php";
    if (isset($_SERVER['QUERY_STRING'])) {
    $deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
    $deleteGoTo .= $_SERVER['QUERY_STRING'];
    header(sprintf("Location: %s", $deleteGoTo));
    mysql_select_db($database_connpuntofermo, $connpuntofermo);
    $query_rs_elenco = "SELECT ID, `data`, titolo FROM news ORDER
    BY ID DESC";
    $rs_elenco = mysql_query($query_rs_elenco, $connpuntofermo)
    or
    die(mysql_error());
    $row_rs_elenco = mysql_fetch_assoc($rs_elenco);
    $totalRows_rs_elenco = mysql_num_rows($rs_elenco);
    ?>
    <html><!-- InstanceBegin
    template="/Templates/template-adm.dwt"
    codeOutsideHTMLIsLocked="false" -->
    <head>
    <!-- InstanceBeginEditable name="doctitle" -->
    <title>amministrazione Piadineria Punto
    Fermo</title>
    <!-- InstanceEndEditable --><meta
    http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1"><style
    type="text/css">
    <!--
    body {
    background-color: #CCD57B;
    margin-bottom: 0px;
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    -->
    </style>
    <link href="../css/style.css" rel="stylesheet"
    type="text/css">
    <style type="text/css">
    @import "news/domnews.css";
    </style>
    <script type="text/javascript"
    src="news/domnews.js"></script>
    <!-- InstanceBeginEditable name="head" --><!--
    InstanceEndEditable -->
    </head>
    <body>
    <table width="100%" height="100%" border="0"
    align="center" cellpadding="0"
    cellspacing="0">
    <tr>
    <td align="center" valign="middle"><table
    width="760" height="430"
    border="0" align="center" cellpadding="0" cellspacing="1"
    bgcolor="#A7B339">
    <tr>
    <td width="779" align="left" valign="middle"
    bgcolor="#FFFFCC"><table width="760" height="334"
    border="0" cellpadding="0"
    cellspacing="0">
    <tr>
    <td align="center"
    class="body"><strong>AMMINISTRAZIONE SITO
    PUNTO FERMO </strong></td>
    </tr>
    <tr>
    <!-- InstanceBeginEditable name="header" --><td
    height="42"
    align="center" valign="top" class="body"><a
    href="menu.php"
    class="body">torna
    a men&ugrave; principale </a></td>
    <!-- InstanceEndEditable --> </tr>
    <tr>
    <!-- InstanceBeginEditable name="body" -->
    <td align="center" valign="top"
    class="body"><p>ELENCO NEWS
    INSERITE</p>
    <table width="505" border="0" cellpadding="5"
    cellspacing="1"
    bgcolor="#999999" class="body">
    <tr bgcolor="#FFFFA8">
    <td>ID</td>
    <td width="104">DATA</td>
    <td width="134">TITOLO</td>
    <td width="110"> </td>
    <td width="112"> </td>
    </tr>
    <?php do { ?>
    <tr align="left" valign="top" bgcolor="#FFFFCC">
    <td><?php echo $row_rs_elenco['ID'];
    ?></td>
    <td><?php echo $row_rs_elenco['data'];
    ?></td>
    <td><?php echo $row_rs_elenco['titolo'];
    ?></td>
    <td><a href="mod-news.php?ID=<?php echo
    $row_rs_elenco['ID']; ?>"
    class="body">MODIFICA</a></td>
    <td><form name="elimina1" method="post"
    action="">
    <input type="submit" name="Submit" value="ELIMINA">
    </form></td>
    </tr>
    <?php } while ($row_rs_elenco =
    mysql_fetch_assoc($rs_elenco)); ?>
    </table>
    <p>  </p></td>
    <!-- InstanceEndEditable --> </tr>
    <tr>
    <td> </td>
    </tr>
    </table></td>
    </tr>
    </table> </td>
    </tr>
    </table>
    </body>
    <!-- InstanceEnd --></html>
    <?php
    mysql_free_result($rs_elenco);
    ?>
    Where is error?
    Thanks.

    MX 2004 was always a bit "gummy" on this.  Instead of using the DW wizard, I downloaded a free version of Microsoft SQL Server Express Edition.  I use that for all table Inserts, Updates,etc.   This accesses the tables directly on the server.  Nothing needs to be synced, put, gotten or whatever.  Use DW for Form and UI creation and making prebuilt queries.
    Hope that helps
    Jerry H

  • Delete records from multiple table

    Hi,
    I need to delete records from multiple tables using a single delete statement. Is it possible ? If so please let me know the procedure.
    Kindly Help.
    Thanks,
    Alexander.

    Hi Tim,
    Syntax of DELETE statement does not allow for multiple tables to be specified in this way. Infact, none of the DMLs allow you to specify table names like this.
    Technically, there are other ways of deleting from multiple tables with one statement.
    1. "Use a trigger":
    What was probably meant by this is that you have a driving-table on which you create a on-delete trigger. In this trigger, you write the logic for deleting from other tables that you want to delete from.
    This does mean a one-time effort of writing the trigger. But the actual DML operation of deleting from all the tables would be simply triggered by a delete on driving-table.
    2. Dynamic SQL:
    Write a PL/SQL code to open a cursor with table-names from which you want the data to be deleted from. In the cursor-for loop, write a dynamic SQL using the table-name to delete from that table.
    3. Using Foreign-Key constraint with Cascade-Delete:
    This I feel is a more 'cleaner' way of doing this.
    Having to delete data from multiple tables means that there is some kind of parent-child relationship between your tables. These relationships can be implemented in database using foreign-key constraints. While creating foreign-key constraint give the 'on delete cascade' clause to ensure that whenever data is deleted from parent-table, its dependent data is deleted from child-table.
    Using foreign-key constraint you can create a heirarchy of parent-child relationships and still your DELETE would be simple as you would only have to delete from parent-table.
    IMPORTANT: Implementing foreign-key constraints would also impact other DML operations that you should keep in mind.

  • Need help in archiveing and deleting records

    Hi frnds
    I wrote a procedure to archive the records and delete the archived one but after inserting and deleting the tot counter is not working and its showing 1 record inserted and i didnt tried the deletion part,pls find my code and how to get the correct no of records inserted as out put and same for deletion.One more thing,before deletion i want to confirm all the records which i going to delete is already inserted eg,if i could'nt able to do insert the specific no of rows the program shud exit without doing the deletion,How to accomplish that
    Declare
    cnt NUMBER := 0;
    tot number :=0;
    CURSOR ins IS
    select count(*) from Cal_log
    where trunc(c_date) ='11-Aug-2008';
    BEGIN
    FOR rec IN ins LOOP
    insert into Calls_arc
    select * from Cal_log
    where trunc(c_date) ='11-Aug-2008';
    tot :=tot + 1
    cnt := cnt + 1;
    IF (cnt >= 100) THEN
    COMMIT;
    cnt := 0;
    END IF;
    END LOOP;
    DBMS_OUTPUT.PUT_LINE('inserted ' || tot|| ' records in call_arch.');
    FOR rec IN ins LOOP
    delete from Cal_log
    where trunc(c_date) ='11-Aug-2008';
    tot := tot + 1;
    cnt := cnt + 1;
    IF (cnt >= 100) THEN
    COMMIT;
    cnt := 0;
    END IF;
    COMMIT;
    DBMS_OUTPUT.PUT_LINE('Deleted ' || tot || ' records from Cal_log');
    END;

    Since
    CURSOR ins IS
    select count(*) from Cal_log
    where trunc(c_date) ='11-Aug-2008';always returns one row, your loop
    FOR rec IN ins LOOPdoes not make much sense. But it does not hurt. The real issue with your code is you increment tot by one while insert processes more than one row (all rows for Aug 11). You should use %ROWCOUNT. And one more thing, never rely on implicit date conversions since default date format is client session sependent. Anyway, all you need is:
    BEGIN
        insert
          into Calls_arc
          select  count(*)
            from  Cal_log
            where c_date >= to_date('11-Aug-2008','dd-mon-yyyy')
              and c_date <  to_date('12-Aug-2008','dd-mon-yyyy');
        DBMS_OUTPUT.PUT_LINE('inserted ' || SQL%ROWCOUNT || ' records in call_arch.');
        delete
          from Cal_log
          where c_date >= to_date('11-Aug-2008','dd-mon-yyyy')
            and c_date <  to_date('12-Aug-2008','dd-mon-yyyy');
        COMMIT;
        DBMS_OUTPUT.PUT_LINE('Deleted ' || SQL%ROWCOUNT || ' records from Cal_log');
    END;
    /SY.

  • Unable to find the deleted record in the child table

    Hi,
    I have two tables and a trigger:
    CREATE TABLE parent (a INTEGER, b CHAR(10));
    CREATE TABLE child (c CHAR(10), d INTEGER);
    CREATE TRIGGER parent_trigger
    AFTER INSERT OR DELETE OR UPDATE ON parent
    REFERENCING NEW AS newRow
    FOR EACH ROW
    BEGIN
    INSERT INTO child VALUES(:newRow.b, :newRow.a);
    END parent_trigger;
    Now my point is , after insertion or updation of the records in the parent table, the records are created successfully in child table...
    BUT.. on deleting a record the record is deleted successfully from parent table..but the record is not displayed in the child table.
    SQL> delete from parent where A=2;
    1 row deleted.
    SQL> select * from parent;
    no rows selected
    SQL> set feedback on
    SQL> select * from child;
    C D
    a 1
    a 2
    3 rows selected.
    Please help.

    What's the value of :NEW variables after deletion? NULL! What gets inserted into your child table? You guess it... :)

  • Can we  change datatype  without deleting records ?

    Hi all ;
    Without deleting records in a table  , can we  change datatype in oracle 10g and 11g ?
    SQL> desc emp
    Name                                      Null?    Type
    NO                                                 NUMBER
    NAME                                            VARCHAR2(10)
    CITY                                               VARCHAR2(15)
    DEP_ID                                          NUMBER
    SQL> select * from emp;
            NO NAME       CITY                DEP_ID
            1   madhir   calcutta                10
    SQL> alter table emp modify(dep_id  varchar2(5));
    alter table emp modify(dep_id varchar2(5))
    ERROR at line 1:
    ORA-01439: column to be modified must be empty to change datatype
    SQL>  select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0      Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production

    See 'Modifying an Existing Column Definition' in the DBA Guide
    http://docs.oracle.com/cd/B28359_01/server.111/b28310/tables006.htm#i1006645
    Use the ALTER TABLE...MODIFY statement to modify an existing column definition. You can modify column datatype, default value, column constraint, column expression (for virtual columns) and column encryption.
    You can increase the length of an existing column, or decrease it, if all existing data satisfies the new length. You can change a column from byte semantics to CHAR semantics or vice versa. You must set the initialization parameter BLANK_TRIMMING=TRUE to decrease the length of a non-empty CHAR column.
    If you are modifying a table to increase the length of a column of datatype CHAR, realize that this can be a time consuming operation and can require substantial additional storage, especially if the table contains many rows. This is because the CHAR value in each row must be blank-padded to satisfy the new column length.
    And the ALTER TABLE statement in the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_3001.htm#SQLRF01001
    modify_col_properties
    Use this clause to modify the properties of the column. Any of the optional parts of the column definition (datatype, default value, or constraint) that you omit from this clause remain unchanged.
    datatype You can change the datatype of any column if all rows of the column contain nulls. However, if you change the datatype of a column in a materialized view container table, then Oracle Database invalidates the corresponding materialized view.
    You can omit the datatype only if the statement also designates the column as part of the foreign key of a referential integrity constraint. The database automatically assigns the column the same datatype as the corresponding column of the referenced key of the referential integrity constraint.
    You can always increase the size of a character or raw column or the precision of a numeric column, whether or not all the rows contain nulls. You can reduce the size of a datatype of a column as long as the change does not require data to be modified.The database scans existing data and returns an error if data exists that exceeds the new length limit.

Maybe you are looking for

  • BPEL 11g 1.1.6 -.7 XML document looses attribute names on enqueue

    We are in the process of migrating BPEL processes from 10.1.2.3 to 11.1.1.6 We're using an AQ adapter to write inbound XML messages into an Oracle queue. Our developer has ran into an odd situation - When the message is written into the queue, the XM

  • How can i do to make the iPod play the next album when the albums that it's playing finish?

    How can i do to make the ipod play the next album when the album that is playing finish? because when tha album that i'm listening to is over ihave to select another, and i want to listen all the albums continuously Thanks

  • JSF Calendar / Schedule component

    Hi Folks, I have to work on jsf project based on a scheduling application : one user may connect to the service and schedule tasks using a visual calendar, where events can be dragged and dropped. Has someone ever heard about a jsf component like thi

  • Help! I can't sync my phone with new iPhoto library

    I recently split my iPhoto library into two separate libraries to save space on my hard drive. One is now on an external drive and the one that I want to sync with my iPhone is on my hard drive. Now when I try to save the iPhone and asks me to choose

  • Rights needed to manage and create print queues

    On a Netware 5.1 install with eDir 8733, what rights would I need to give a user so that this person would be able to create new print queues, print servers, and print objects? This person is not an admin and I prefer not making him an admin equivale