Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

insert query problem

 
Vedika Sagare
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
trying to insert the data in tabel st_stocks . In the following code retrieving all the items from Item Master and selecting offices for the item for which entry is not there in stock table. For all such offices trying to insert the data.
strQuery = "select office_id from sy_offices where office_id not in(select purchase_office_id from st_stocks where item_id=" + strItemId + ")";
This query returns the result in isql but in the code it's not entering the loop which retrieves office Id.

Regards and Thanks
Vedika


// select all PO Items from table sy_items
rsItemId = stmt.executeQuery("select item_id, name, code, active_p from sy_items where scrapped_p = 'f' and item_type = 'POI' order by item_id");

while (rsItemId != null && rsItemId.next())
{
strItemId = rsItemId.getString("item_id");
%> <%=strItemId%>
<%


strQuery = "select office_id from sy_offices where office_id not in(select purchase_office_id from st_stocks where item_id=" + strItemId + ")";


rsOfficeId = stmt2.executeQuery(strQuery);

%> <%=rsOfficeId%> <%

while (rsOfficeId != null && rsOfficeId.next())
{
strOfficeId = rsOfficeId.getString("office_id");

%> <%=strOfficeId%> <%
//insert record in table st_stocks for strOfficeId
strQuery1="insert into sy_st_stocks (stock_id, item_id, current_stock, reorder_level, weighted_average_cost, max_order_qty, max_indent_qty, default_vendor_id, purchase_office_id,opening_stock) values (sy_st_stock_id_seq.nextval," + strItemId + ",0,0,0,0,0," + strVendorId + "," + strOfficeId + ",0)";

stmt1.executeQuery(strQuery1);

} //end of while (rsOfficeId != null && rsOfficeId.next())

} // end of while (rsItemId != null && rsItemId.next())

conn.commit();
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65337
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the JDBC forum.
[ June 22, 2004: Message edited by: Bear Bibeault ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic