add at the same time delete

  • what i want is that everytime i add something to my sell table the stocks table deletes

    here is the file i want that everytime i buy something the stocks would lessen..

    http://rapidshare.com/files/85111869/add_at_the_same_time_delete.zip.html

  • Going to another site for your files is a PITA... it would be much better if you'd just attach the files to your post.

    The files are JSP files... I'm a data troll and "don't know beans about Java". 😛 My question would be, what does this have to do with SQL? You would get much better answers if, instead of having to read through your Java code, if you would describe the problem in terms of SQL and tables. Please read the following URL for how to get better answers on these forums...

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • As Jeff mentioned, we're more than happy to help. However take the time to describe what you want, include relevant code, but we're not going to dig through your code. Also, take the time to capitalize and write real sentences so we can understand.

  • okay my table's name is astock (available stocks)

    table's name is stock(stocks i have bought)

    here is the code for my buy this page shows a table of available stock and it is here where you make your transaction of buying stocks

    what i want is that everytime i buy the table(stocks) would decrease then the table(buy) would increase

    <!-- Copyright 2002 Bontrager Connection, LLC

    function getCalendarDate()

    {

    var months = new Array(13);

    months[0] = "January";

    months[1] = "February";

    months[2] = "March";

    months[3] = "April";

    months[4] = "May";

    months[5] = "June";

    months[6] = "July";

    months[7] = "August";

    months[8] = "September";

    months[9] = "October";

    months[10] = "November";

    months[11] = "December";

    var now = new Date();

    var monthnumber = now.getMonth();

    var monthname = months[monthnumber];

    var monthday = now.getDate();

    var year = now.getYear();

    if(year < 2000) { year = year + 1900; }

    var dateString = monthname +

    ' ' +

    monthday +

    ', ' +

    year;

    return dateString;

    } // function getCalendarDate()

    function getClockTime()

    {

    var now = new Date();

    var hour = now.getHours();

    var minute = now.getMinutes();

    var second = now.getSeconds();

    var ap = "AM";

    if (hour > 11) { ap = "PM"; }

    if (hour > 12) { hour = hour - 12; }

    if (hour == 0) { hour = 12; }

    if (hour < 10) { hour = "0" + hour; }

    if (minute < 10) { minute = "0" + minute; }

    if (second < 10) { second = "0" + second; }

    var timeString = hour +

    ':' +

    minute +

    ':' +

    second +

    " " +

    ap;

    return timeString;

    } // function getClockTime()

    //-->

    <!--

    #Layer1 {

    position:absolute;

    width:155px;

    height:51px;

    z-index:1;

    left: 41px;

    top: 534px;

    }

    #Layer2 {

    position:absolute;

    width:155px;

    height:51px;

    z-index:2;

    left: 322px;

    top: 67px;

    }

    #Layer3 {

    position:absolute;

    width:195px;

    height:66px;

    z-index:3;

    left: 769px;

    top: 535px;

    }

    #Layer4 {

    position:absolute;

    width:159px;

    height:50px;

    z-index:4;

    left: 586px;

    top: 136px;

    }

    body {

    background-image: url(wallpaper.jpg);

    }

    #Layer5 {

    position:absolute;

    width:996px;

    height:60px;

    z-index:5;

    left: 7px;

    top: 30px;

    }

    .style1 {

    font-family: "Times New Roman", Times, serif;

    font-size: 36px;

    font-weight: bold;

    }

    #Layer6 {

    position:absolute;

    width:979px;

    height:109px;

    z-index:6;

    left: 19px;

    top: 168px;

    }

    #Layer8 {

    position:absolute;

    width:902px;

    height:116px;

    z-index:8;

    left: 16px;

    top: 287px;

    }

    #Layer9 {

    position:absolute;

    width:706px;

    height:66px;

    z-index:9;

    left: 30px;

    top: 142px;

    }

    .style2 {

    font-size: 18px;

    font-weight: bold;

    }

    #Layer10 {

    position:absolute;

    width:153px;

    height:56px;

    z-index:10;

    left: 782px;

    top: 152px;

    }

    #Layer11 {

    position:absolute;

    width:200px;

    height:115px;

    z-index:11;

    left: 777px;

    top: 27px;

    }

    #Layer7 {

    position:absolute;

    width:200px;

    height:115px;

    z-index:12;

    left: 260px;

    top: 482px;

    }

    -->

    <%

    try {

    Connection con;

    Statement stmt;

    ResultSet rs;

    String URL,query;

    String year = request.getParameter("select5");

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    con = DriverManager.getConnection("jdbc:odbc:sherwin","","");

    stmt = con.createStatement();

    query = "SELECT brokers FROM sell";

    rs = stmt.executeQuery(query);

    con.close();

    } catch (Exception e){

    System.out.println("SQL Exception : " + e.getMessage());

    }

    %>

    <%

    String strgetcode = request.getParameter("viewcode");

    %>

    <%

    try { String URL,query; Connection con; Statement stmt;

    ResultSet rs;

    URL = "jdbc:odbc:sherwin";

    query = "SELECT * FROM astocks";

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

    con = DriverManager.getConnection(URL,"","");

    stmt = con.createStatement();

    rs = stmt.executeQuery(query);

    while(rs.next())

    {%>

    <%}con.close();

    } catch (Exception e)

    {

    out.println("SQL Exception : " + e.getMessage());

    }%>

    Broker name:

    Stock code:

    Quantity:

    Date bought : Month

    Day:

    Year:

    <!--

    var calendarDate = getCalendarDate();

    var clockTime = getClockTime();

    document.write('Date is ' + calendarDate);

    document.write('

    ');

    document.write('Time is ' + clockTime);

    //-->

  • It appears to me that there's no data manipulation code in there at all. When Jeff/Steve said they wanted SQL code, they meant SQL code, not a dump of your JSP with html and CSS sprinkled through it...

    Anyhow...

    I cannot see any database code apart from a couple of select * statements.

    I suggest that you write a stored procedure that takes as a parameter the itemID. Then have this procedure do the increment and decrement for you.

    How much MS SQL do you know? If you let us know that then we know how much to write

  • it is actually a sql codes its just most of the codes is more on the gui..

    im only starting with sql..

    i didnt attached my sql database file

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply