How can i update multiple row in a advance table
Dear all,
hope you are well enough.
suppose i have a table in a OA page where there are several transactions.
i would like to add a check box in front of every row.
when i check the transactions(rows of OA pages) and submit then one column of a table will be updated in database.
how can i implement that.
Please explain
Regards,
Mofizur
Hi,
Refer below code for iteration:
OAViewObject appVO = (OAViewObject)am.findViewObject("ApprovalsWVO1");
OARow row = (OARow)appVO.first();
for(int i=0;i<appVO.getRowCount();i++)
String appStatus=appVO.getCurrentRow().getAttribute("ApprovalStatus").toString();
if(appStatus.equalsIgnoreCase("NEW"))
newRow.setAttribute("appTrans",Boolean.FALSE);
else
newRow.setAttribute("appTrans",Boolean.TRUE);
System.out.println(appStatus);
row = (OARow)appVO.next();
Regards
Meher Irk
Similar Messages
-
How can I update multiple rows?
Hi all,
How can I realize an Update on multiple rows? An Update statement would look like this
UPDATE table SET value = oldvalue + x WHERE condition_field > y;My problem is: How can I execute such a statement with BC4J? I don't linke to step through the complete result set row by row.
Thanks,
AxelGet your application module object and issue this statement:
am.getTransaction().executeCommand(<string>);This should be what you're looking for. -
How can I update multiple rows in table using a single form button and checkboxes
I have a project where the visitors can select multiple productos and once the click on the PURCHAS button it updates the selected records.
You have not mentioned the programming language that you are using, but here's a link that could help you if you are using ASP.
http://csharpdotnetfreak.blogspot.com/2009/05/edit-multiple-records-gridview-checkbox.html
Also, have a look at this discussion thread
http://forums.asp.net/t/1470882.aspx -
How can I update multiple rows based on comparison of fields table1 and 2
I create the following SQL to test what I thought was a method to update those records where the fields below match, but what ends up happening is that the update functions works the first time, and then basically updates everything to null. I am not understanding what I am doing wrong. New at this.
UPDATE SLS_HDR B
SET ( B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT,B.UPDATED_DT )
= (SELECT
A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2,A.PLAN_DEL_DT, A.TXTA, A.TXTB,
A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT,A.PAY_CONTACT, A.ORD_AMT, SYSDATE
FROM
SLS_HDR_TEMP A
WHERE
A.FIN_COMP = B.FIN_COMP AND
A.LOG_COMP = B.LOG_COMP AND
A.ORD_NO = B.ORD_NO AND
A.TRANS_DT = B.TRANS_DT AND
A.BP_TYPE = B.BP_TYPE AND
A.STATUS <> B.STATUS);
Can anyone advise?
Thank you,
Edited by: 903292 on Dec 19, 2011 1:15 PMyou donot have where clause in your update so un-matched rows will be updated with null values
UPDATE SLS_HDR B
SET ( B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT,B.UPDATED_DT )
= (
SELECT
A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2,A.PLAN_DEL_DT, A.TXTA, A.TXTB,
A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT,A.PAY_CONTACT, A.ORD_AMT, SYSDATE
FROM
SLS_HDR_TEMP A
WHERE
A.FIN_COMP = B.FIN_COMP AND
A.LOG_COMP = B.LOG_COMP AND
A.ORD_NO = B.ORD_NO AND
A.TRANS_DT = B.TRANS_DT AND
A.BP_TYPE = B.BP_TYPE AND
A.STATUS= B.STATUS
WHERE EXISTS
select null from SLS_HDR_TEMP A
WHERE
A.FIN_COMP = B.FIN_COMP AND
A.LOG_COMP = B.LOG_COMP AND
A.ORD_NO = B.ORD_NO AND
A.TRANS_DT = B.TRANS_DT AND
A.BP_TYPE = B.BP_TYPE AND
A.STATUS= B.STATUS
)OR using Merge
Merge into SLS_HDR B
using SLS_HDR_TEMP A
on (A.FIN_COMP = B.FIN_COMP AND
A.LOG_COMP = B.LOG_COMP AND
A.ORD_NO = B.ORD_NO AND
A.TRANS_DT = B.TRANS_DT AND
A.BP_TYPE = B.BP_TYPE AND
A.STATUS= B.STATUS)
when matched then update set (B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT,B.UPDATED_DT ) = (A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2,A.PLAN_DEL_DT, A.TXTA, A.TXTB,
A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT,A.PAY_CONTACT, A.ORD_AMT, SYSDATE)HTH...
Thanks -
How can I use multiple row insert or update into DB in JSP?
Hi all,
pls help for my question.
"How can I use multiple rows insert or update into DB in JSP?"
I mean I will insert or update the multiple records like grid component. All the data I enter will go into the DB.
With thanks,That isn't true. Different SQL databases have
different capabilities and use different syntax, That's true - every database has its own quirks and extensions. No disagreement there. But they all follow ANSI SQL for CRUD operations. Since the OP said they wanted to do INSERTs and UPDATEs in batches, I assumed that ANSI SQL was sufficient.
I'd argue that it's best to use ANSI SQL as much as possible, especially if you want your JDBC code to be portable between databases.
and there are also a lot of different ways of talking to
SQL databases that are possible in JSP, from using
plain old java.sql.* in scriptlets to using the
jstlsql taglib. I've done maintenance on both, and
they are as different as night and day.Right, because you don't maintain JSP and Java classes the same way. No news there. Both java.sql and JSTL sql taglib are both based on SQL and JDBC. Same difference, except that one uses tags and the other doesn't. Both are Java JDBC code in the end.
Well, sure. As long as you only want to update rows
with the same value in column 2. I had the impression
he wanted to update a whole table. If he only meant
update all rows with the same value in a given column
with the same value, that's trivial. All updates do
that. But as far as I know there's know way to update
more than one row where the values are different.I used this as an example to demonstrate that it's possible to UPDATE more than one row at a time. If I have 1,000 rows, and each one is a separate UPDATE statement that's unique from all the others, I guess I'd have to write 1,000 UPDATE statements. It's possible to have them all either succeed or fail as a single unit of work. I'm pointing out transaction, because they weren't coming up in the discussion.
Unless you're using MySQL, for instance. I only have
experience with MySQL and M$ SQL Server, so I don't
know what PostgreSQL, Oracle, Sybase, DB2 and all the
rest are capable of, but I know for sure that MySQL
can insert multiple rows while SQL Server can't (or at
least I've never seen the syntax for doing it if it
does).Right, but this syntax seems to be specific to MySQL The moment you use it, you're locked into MySQL. There are other ways to accomplish the same thing with ANSI SQL.
Don't assume that all SQL databases are the same.
They're not, and it can really screw you up badly if
you assume you can deploy a project you've developed
with one database in an environment where you have to
use a different one. Even different versions of the
same database can have huge differences. I recommend
you get a copy of the O'Reilly book, SQL in a
Nutshell. It covers the most common DBMSes and does a
good job of pointing out the differences.Yes, I understand that.
It's funny that you're telling me not to assume that all SQL databases are the same. You're the one who's proposing that the OP use a MySQL-specific extension.
I haven't looked at the MySQL docs to find out how the syntax you're suggesting works. What if one value set INSERT succeeds and the next one fails? Does MySQL roll back the successful INSERT? Is the unit of work under the JDBC driver's control with autoCommit?
The OP is free to follow your suggestion. I'm pointing out that there are transactions for units of work and ANSI SQL ways to accomplish the same thing. -
How can i update data in okc_k_items and csi_item_instances tables?
by EBS .
Thanks.For csi_item_instances table, you can use the following API:
CSI_ITEM_INSTANCE_PUB.UPDATE_ITEM_INSTANCE
For okc_k_items, try using the following API:
OKC_CONTRACT_ITEM_PUB.UPDATE_CONTRACT_ITEM
Hope this helps! -
Update multiple rows in a dynamic table Dreamweaver CS5.5
hello there
i want to update multiple rows which comes from a dynamic table in Dreamweaver CS5 (a loop in php) here is my Mysql table :
sql code
CREATE TABLE `register`.`s_lessons` (
`lid` int( 5 ) NOT NULL ,
`sid` int( 9 ) NOT NULL ,
`term` int( 5 ) NOT NULL ,
`tid` int( 5 ) NOT NULL ,
`point` double NOT NULL DEFAULT '0',
PRIMARY KEY ( `lid` , `sid` , `term` ) ,
KEY `tid` ( `tid` ) ,
KEY `point` ( `point` )
) ENGINE = MYISAM DEFAULT CHARSET = utf8 COLLATE = utf8_persian_ci;
and this is my page source code:
php file
<?php require_once('../Connections/register.php'); ?>
<?php
session_start();
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
$colname1_rs1 = "-1";
if (isset($_GET['term'])) {
$colname1_rs1 = $_GET['term'];
$colname_rs1 = "-1";
if (isset($_GET['lid'])) {
$colname_rs1 = $_GET['lid'];
$colname2_rs1 = "-1";
if (isset($_SESSION['tid'])) {
$colname2_rs1 = $_SESSION['tid'];
mysql_select_db($database_register, $register);
$query_rs1 = sprintf("SELECT s_lessons.sid, s_lessons.lid, s_lessons.term, s_lessons.tid, s_lessons.point FROM s_lessons WHERE s_lessons.lid = %s AND s_lessons.term = %s AND s_lessons.tid = %s", GetSQLValueString($colname_rs1, "int"),GetSQLValueString($colname1_rs1, "int"),GetSQLValueString($colname2_rs1, "int"));
$rs1 = mysql_query($query_rs1, $register) or die(mysql_error());
$row_rs1 = mysql_fetch_assoc($rs1);
$totalRows_rs1 = mysql_num_rows($rs1);
$count=mysql_num_rows($rs1);
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
for ($j = 0, $len = count($_POST['lid']); $j < $len; $j++) {
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
$updateSQL = sprintf("UPDATE s_lessons SET point=%s WHERE tid=%s, lid=%s, sid=%s, term=%s",
GetSQLValueString($_POST['point'] [$j], "double"),
GetSQLValueString($_SESSION['tid'], "int"),
GetSQLValueString($_POST['lid'] [$j], "int"),
GetSQLValueString($_POST['sid'] [$j], "int"),
GetSQLValueString($_POST['term'] [$j], "int"));
mysql_select_db($database_register, $register);
$Result1 = mysql_query($updateSQL, $register) or die(mysql_error());
$updateGoTo = "student_lists.php";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $updateGoTo));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>r</title>
<link href="styles/style.css" rel="stylesheet" type="text/css" media="screen" />
<link href="styles/in_styles.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="header-wrapper">
</div>
<!-- end #header -->
<div id="page">
<div id="page-bgtop">
<div id="page-bgbtm">
<div id="content">
<div class="post">
<div style="clear: both;">
<form name="form1" id="form1" method="post" action="<?php echo $editFormAction; ?>">
<table border="1" align="center">
<tr>
<th>Student ID</th>
<th>Lesson ID</th>
<th>Semester</th>
<th>Point</th>
</tr>
<?php do { ?>
<tr>
<td class="data"><label for="sid[]"></label>
<input name="sid[]" type="text" id="sid[]" value="<?php echo $row_rs1['sid']; ?>" size="9" readonly="readonly" /></td>
<td class="data"><label for="lid[]"></label>
<input name="lid[]" type="text" id="lid[]" value="<?php echo $row_rs1['lid']; ?>" size="5" readonly="readonly" /></td>
<td class="data"><label for="term[]"></label>
<input name="term[]" type="text" id="term[]" value="<?php echo $row_rs1['term']; ?>" size="4" readonly="readonly" /></td>
<td><label for="point[]"></label>
<input name="point[]" type="text" id="point[]" value="<?php echo $row_rs1['point']; ?>" size="4" />
</tr>
<?php } while ($row_rs1 = mysql_fetch_assoc($rs1)); ?>
</table>
<p>
<input type="submit" name="Submit" id="Submit" value="Submit" />
<input type="hidden" name="MM_update" value="form1" />
</p>
</form>
</div>
</div>
<div style="clear: both;">
</div>
</div>
<!-- end #content -->
<!-- end #sidebar -->
<div style="clear: both;"> </div>
</div>
</div>
</div>
<!-- end #page -->
</div>
<!-- end #footer -->
</body>
</html>
<?php
mysql_free_result($rs1);
?>
All i want is that when users click on SUBMIT button values of point column in s_lessons(database table) be updated by new entries from user.
i did my best and result with that code is :
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 ' lid=888, sid=860935422, term=902' at line 1
I would appreciate any idea.
with prior thanksGo to the Row Properties, and in the Visibility tab, you have "Show or hide based on an expression". You can use this to write an expression that resolves to true if the row should be hidden, false otherwise.
Additionally, in the Matrix properties you should take a look at the filters section, perhaps you can achieve what you wish to achieve through there by removing the unnecessary rows instead of just hiding them.
It's only so much I can help you with the limited information. If you require further help, please provide us with more information such as what data are you displaying, what's the criteria to hiding rows, etc...
Regards
Andrew Borg Cardona -
Multiple Rows Selection In Advance Table
Hi All,
I have a requirement to select multiple rows in advance table.After selection these rows they get added to the record list of another page on click of seeded submit button.This is my custom region.And this functionality is working for seeded region.
I have added multiple selection component in advance table component.
How should I make this functionality work for my custom region using the seeded submit button.
Regards,SHDHi,
After selection these rows they get added to the record list of another page on click of seeded submit buttonon the click of submit button save the data to the table from where u are getting the data for the other page....Once this data get saved to the table, will definitely shows up in next page.
Regards,
Gyan -
How can i use multiple row subquery in update statement
Hai All
I using group function in my update statement.. and i need to update more rows so i need to use multiple row
subquery pls tell me how to use multiple row subquery in update statement
For example
while i am using this like this i got an error
update dail_att set outtime in (select max(r2.ptime) from temp_att where empcode=r2.enpno and
barcode=r2.cardn and attend_date=r2.pdate group by enpno,pdate,cardn);
Pls tell me how to use with example
Thanks & regards
Srikkanth.MHai Man
Thanks for ur response Let me clear what i need
First step Fetch the records as text file and stores into table T1
and the next step is i have seperated the text using substring and stores in different columns of a table
There are two shifts 0815 to 1645 and 1200 and 2000
Here I rep IN and O rep OUT
Empno date time inout
001 01-01-10 0815 I
002 01-01-10 0815 I
003 01-01-10 0818 I
001 01-01-10 1100 0
001 01-01-10 1130 I
002 01-01-10 1145 0
002 01-01-10 1215 I
004 01-01-10 1200 I
005 01-01-10 1215 I
004 01-01-10 1315 O
004 01-01-10 1345 I
001 01-01-10 1645 0
002 01-01-10 1715 0
003 01-01-10 1718 0
004 01-01-10 2010 0
005 01-01-10 2015 0
This is my T1 table i have taken data from text file and stored in this table from this table i need to move data to another table T2
T2 contains like this
Empno Intime Intrin Introut Outtime Date
001 0815 1100 1130 1645 01-01-10
002 0815 1145 1215 1715 01-01-10
003 0818 1718 01-01-10
004 1200 1315 1345 2010 01-01-10
005 1215 2015 01-01-10
This what i am trying to do man but i have little bit problems Pls give some solution with good example
And my coding is
declare
emp_code varchar2(25);
in_time varchar2(25);
out_time varchar2(25);
Cursor P1 is
Select REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
From temp_att
group by REASON,ECODE,READMODE,EMPD,ENPNO,FILL,PDATE,PTIME,INOUT,CARDN,READERN
ORDER BY enpno,pdate,ptime;
begin
for r2 in p1 loop
declare
bar_code varchar2(25);
begin
select barcode into bar_code from dail_att where empcode=r2.enpno and attend_date=r2.pdate;
For r3 in (select empcode,empname,barcode,intime,intrin,introut,addin,addout,outtime,attend_date from dail_att)loop
if r2.inout ='O' then
update dail_att set outtime =(select max(r2.ptime) from temp_att where empcode=r2.enpno and barcode=r2.cardn and attend_date=r2.pdate group by r2.cardn,r2.enpno,r2.pdate );
end if;
end loop;
exception
when no_data_found then
if r2.inout ='I' then
insert into dail_att(barcode,empcode,intime,attend_date)(select r2.cardn,r2.enpno,min(r2.ptime),r2.pdate from temp_att group by r2.cardn,r2.enpno,r2.pdate );
end if;
end;
end loop;
commit;
end;
Pls tell me what correction i need to do i the update statement i have used a subquery with group function but when i used it will return only one row but my need is to return many rows and i need to use multiple row subquery
and how can i use it in the update statement
Thanks In Advance
Srikkanth.M -
I have many bookmarks that I like to have readily available on the toolbar. With the older versions of Firefox, I was able to have multiple rows of icons that I grouped by topic. I have now wasted a lot of time trying to find a way to have multiple rows in version 4.0. I do not want to use the down arrow on the right.
This can be done by adding a userstyle with the Stylish add-on.
# First install the Stylish add-on - https://addons.mozilla.org/en-US/firefox/addon/stylish
# Go to http://userstyles.org/styles/29428 and click on "Install with Stylish"
# Restart Firefox and you should then have a multi-row bookmarks toolbar. -
How can i count no rows in my database table
plz tell me how can i count no of rows in my database table with[b] ResultSet object
Hi ! hope this code helps you .
We can use the count(*) to get the total no of records in the table ad then access it through the getString method .
import java.sql.*;
public class JdbcTest
public static void main(String [] args ) throws Exception
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String DBURL = "jdbc:odbc:mydsn" ;
Connection conn = DriverManager.getConnection(DBURL);
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select count(*) from table1");
rs.next();
System.out.println("total rec = " + rs.getString(1));
Cheers ! -
How can i edit perticular row in dynamically created table
Hi to All,
Here my requirement is create table dynamically from existing XML and first column with radio buttons,column data and row wise data there on XML but i'm able to create table and displaying data then whenever i click on first column radio button that row editable and remaining rows in disable mode then i edit that row and click on save button that particular row data will be inserted to XML.Please tell me how can i achieve this requirement.
Thanks and Regards,
surya.Hi surya
- Use RadioButtonGroupByIndex for the first column.
- Disable automatic change of table's lead selection: selectionChangeBehaviour = manual, selectionMode = none.
- In onSelect event handler of the RadioButtonGroupByIndex set new table's lead selection from the code to the row where the button is clicked.
- Add calculated read-only attribute isRowEditable (boolean) to the table's node. Getter shall be like this:
return (element.index() == element.node().getLeadSelection());
- Bind the cell editors' enabled property to isRowEditable attribute.
BR, Siarhei
PS: this is my message #666 - do not trust it
Edited by: Siarhei Pisarenka on Feb 23, 2010 2:29 PM -
How can i select the rows from the 3 tables by particular column name?
Vehicle Passing Summary table structure
PsngSmry_ID(Number),Vehicle_iD(Number),PsngSmryTime(datetime)
Vehicle table structure
Vehicle_iD(Number),VehicleName(VarChar2),VehicleType(VarChar2)
Here Vehicle_iD is the Primary Key
Equipment Table Structure
Eqpmt_id(Number),Vehicle_iD(Number),EqpmtName(VarChar2),EqpmtType(VarChar2)
Here Eqpmt_id is the Primary Key and Vehicle_iD is the foreign Key
Equipment Component Table Structure
Eqpmt_Cmpnt_id(Number) ,Eqpmt_id(Number),EqpmtCmpntName(VarChar2),EqpmtCmpntName(VarChar2),Parent_Eqpmnt_ID(Number)
Here Eqpmt_Cmpnt_id is the Primary Key and Eqpmt_id is the foreign Key
The rows in the Vehicle Passing Summary table
PsngSmry_ID Vehicle_ID PsngSmryTime
111111 80986246 2010/10/11
111112 80986247 2010/10/12
111113 80986248 2010/10/10
The rows in the Vehicle Table
Vehicle_iD VehicleName VehicleType
80986246 Lorry Four Wheeler
80986247 Van Four Wheeler
80986248 Bus Four Wheeler
The rows in the Equipment Table:
Eqpmt_id Vehicle_iD EqpmtName EqpmtType
109846 80986246 2 Axle Lorry CAR
109821 80986246 4 Axle Lorry CAR
109825 80986246 4 Axle Lorry CAR
109562 80986247 2 Axle VAn CAR
109555 80986247 3 Axle VAn CAR
109777 80986247 3 Axle VAn CAR
109587 80986248 2 Axle Bus CAR
The rows in the Equipment Component Table :
Eqpmt_Cmpnt_id Eqpmt_id EqpmtCmpntName Parent_Eqpmnt_ID
20904146 109846 Truck
20904147 109846 Truck
20904148 109846 Axle 20904146
20904159 109846 Axle 20904146
20904167 109846 Wheel 20904148
20904177 109846 Wheel 20904148
20904185 109846 Wheel 20904159
20904325 109846 Wheel 20904159
20904188 109846 Axle 20904147
20904189 109846 Axle 20904147
20904195 109846 Wheel 20904188
20904196 109846 Wheel 20904188
20904197 109846 Wheel 20904189
20904398 109846 Wheel 20904189
10904146 109562 Truck
10904147 109562 Truck
10904148 109562 Axle 10904146
10904159 109562 Axle 10904146
10904167 109562 Wheel 10904148
10904177 109562 Wheel 10904148
10904185 109562 Wheel 10904159
10904325 109562 Wheel 10904159
10904188 109562 Axle 10904147
10904189 109562 Axle 10904147
10904195 109562 Wheel 10904188
10904196 109562 Wheel 10904188
10904197 109562 Wheel 10904189
10904398 109562 Wheel 10904189
Note : In Equipment Component Table,the hierarchy will be Truck-->Axle-->Wheel.So
1.the Parent_Eqpmnt_ID of Axle is Truck's Eqpmt_Cmpnt_id.
2.the Parent_Eqpmnt_ID of Wheel is Axle's Eqpmt_Cmpnt_id.
Now I want to write the store procedure which will take "PsngSmry_ID(Number)" as input and the o/p will be in the format :
Eqpmt_Cmpnt_id Eqpmt_id EqpmtCmpntName Parent_Eqpmnt_ID
20904146 109846 Truck
20904148 109846 Axle 20904146
20904167 109846 Wheel 20904148
20904177 109846 Wheel 20904148
20904159 109846 Axle 20904146
20904185 109846 Wheel 20904159
20904325 109846 Wheel 20904159
20904147 109846 Truck
20904188 109846 Axle 20904147
20904195 109846 Wheel 20904188
20904196 109846 Wheel 20904188
20904189 109846 Axle 20904147
20904197 109846 Wheel 20904189
20904398 109846 Wheel 20904189
10904146 109562 Truck
10904148 109562 Axle 10904146
10904167 109562 Wheel 10904148
10904177 109562 Wheel 10904148
10904159 109562 Axle 10904146
10904185 109562 Wheel 10904159
10904325 109562 Wheel 10904159
10904147 109562 Truck
10904188 109562 Axle 10904147
10904195 109562 Wheel 10904188
10904196 109562 Wheel 10904188
10904189 109562 Axle 10904147
10904197 109562 Wheel 10904189
10904398 109562 Wheel 10904189
**Please add these columns in the o/p **
1.EqpmtName and EqpmtType from Eqpmt table
2.VehicleName and Vehicle Type from Vehicle table
3.PsngSmryTime from PassingSummary table **
Can anyone tell me the solution?
Edited by: 865216 on Jun 22, 2011 2:14 AMHi,
I am new to this technology;But, just wanted to help you.
Please refer the code it might be atleast helpful for you.
But am facing PL/SQL: ORA-00933: error and unable to resolve it.could anyone please correct this code.
sorry if my code is totally wrong.
Thank you,
Rupa
create or replace procedure Equipment_proc
is
begin
DECLARE
TYPE EQP_record IS RECORD (
Vehicle_iD Vehicle.Vehicle_iD%TYPE,
Eqpmt_Cmpnt_id Equipment_Component.Eqpmt_Cmpnt_id%type,
EqpmtCmpntName Equipment_Component.EqpmtCmpntName%type,
Parent_Eqpmnt_ID Equipment_Component.Parent_Eqpmnt_ID%type,
Eqpmt_id Equipment.Eqpmt_id%type,
vehicleId NUMBER);
EQP_rec EQP_record;
CURSOR EQP_cursor IS
select a.Vehicle_iD,c.Eqpmt_Cmpnt_id,b.Eqpmt_id,c.EqpmtCmpntName,c.Parent_Eqpmnt_ID
from Vehicle a,Equipment b,Equipment_Component c
where a.Vehicle_iD=b.Vehicle_iD
and b.Eqpmt_id=c.Eqpmt_id
and a.vehicle_id=&EQP_rec.vehicleId;
BEGIN
OPEN EQP_cursor;
FETCH EQP_cursor INTO EQP_rec;
dbms_output.put_line(EQP_rec.Vehicle_iD,EQP_rec.Eqpmt_Cmpnt_id||','||EQP_rec.Eqpmt_id||','||EQP_rec.EqpmtCmpntName||','||EQP_rec.Parent_Eqpmnt_ID);
CLOSE EQP_cursor;
END;
END; -
How to update multiple row using procedure in table
Hi,
create or replace procedure TESTLEDGER1(var_date varchar2)
as
var_date1 date;
CURSOR C1 IS
select DISTINCT ta.accountid,day PROCESSDATE,
(NVL(payment,0))PAYMENT,NVL(TOTALDUE,0)TOTALDUE,NVL(currentbillamount,0)CURBILL,NVL(srf,0)SRF,NVL(sbpnt,0)sbpnt,
NVL(srv,0)SRV,NVL(sbf,0)SBF,NVL(SBV,0)SBV,NVL(EF,0)EF,NVL(EV,0)EV,NVL(TSRV,0)TSRV,
NVL(tsub,0)TSUB,NVL(teqe,0)TEQE,NVL(DT,0)DT,
NVL(A.dep,0)RDEP,NVL(B.DEP,0)PDEP,
NVL(pnt,0)PNT,NVL(eqp,0)EQP,NVL(dtr,0)DTR,NVL(drf,0)DRF,NVL(unadj,0)UNADJ
from
(select DISTINCT day ,accountid
from
syntblmaccount, tblmtime where yyyy =2010)ta,
(SELECT accountid,
SUM(srfee)srf,
SUM(srvat)srv,
SUM(subfee)sbf,
SUM(subvat)sbv,
SUM(eqefee)ef,
SUM(eqevat)ev,
SUM(ttlsrv)tsrv,
SUM(ttlsub)tsub,
SUM(ttleqe)teqe,
SUM(dep)dep,
SUM(dt)dt,trunc(fromdate)fromdate
FROM VWDT_v2
GROUP BY accountid,trunc(fromdate)
)a,
(SELECT accountid,
SUM(pnt)pnt,
SUM(subpnt)sbpnt,
SUM(eqpnt)eqp,
SUM(dep)dep,
SUM(DEPTRANSFER)dtr,
SUM(DEPREFUNDED)drf,
SUM(unadj)unadj,trunc(paymentdate)paymentdate
FROM vwkt_v4
GROUP BY accountid,trunc(paymentdate)
)b,
(SELECT ACCOUNTID,REFUND,trunc(createdate) createdate FROM vwrefund)F,
( SELECT ACCOUNTID,
TRUNC(CREATEDATE)CREATEDATE,
sum(TOTALDUE)/100 TOTALDUE,sum(currentbillamount)currentbillamount
FROM SYNTBLTDEBITDOCUMENT
group by ACCOUNTID, TRUNC(createdate))debit,
(SELECT ACCOUNTID accountid,TRUNC(createdate)CREATEDATE, SUM(totalamount)PAYMENT
from syntbltcreditdocument
where CREDITDOCUMENTTYPEID IN ('CDT01','CDT04')
-- AND ACCOUNTID='ACC000003014'
group by accountid,TRUNC(createdate))credit
where ta.accountid=a.accountid(+)
and ta.accountid=b.accountid(+)
--and ta.accountid=pay.accountid(+)
and ta.accountid=debit.accountid(+)
and ta.accountid=credit.accountid(+)
and ta.accountid=f.accountid(+)
and ta.day=a.fromdate(+)
--and ta.day=pay.createdate(+)
and ta.day=debit.createdate(+)
and ta.day=credit.createdate(+)
and ta.day=b.paymentdate(+)
and ta.day=f.createdate(+)
and trunc(ta.day)=to_date(var_date,'DD-MON-YY');
begin
select distinct processdate into var_date1 from ledgerdetail;
FOR V1 IN C1 LOOP
UPDATE LEDGERDETAILtest
SET PAYMENT=v1.payment,
TOTALDUE=v1.TOTALDUE,
CURBILL=v1.curbill,
SRF=v1.srf,
SBPNT=v1.sbpnt,
SRV=v1.srv,
SBF=v1.sbf,
SBV=v1.sbv,
EF=v1.ef,
EV=v1.ev,
TSRV=v1.tsrv,
TSUB=v1.tsub,
TEQE=v1.teqe,
DT=v1.dt,
PDEP=v1.rdep,
PNT=v1.pnt,
EQP=v1.eqp,
DTR=v1.dtr,
DRF=v1.drf,
UNADJ=v1.unadj
where accountid=v1.accountid
and processdate=v1.processdate;
--DBMS_OUTPUT.PUT_LINE('INSERTED ROW');
commit;
end loop;
end;
I have created above procedure to update table column....but i am getting run time error....
Error report:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "CRESTELVIEWSPRD501.TESTLEDGER1", line 70
ORA-06512: at line 1
01422. 00000 - "exact fetch returns more than requested number of rows"
*Cause: The number specified in exact fetch is less than the rows returned.
*Action: Rewrite the query or change number of rows requested
how to resolve this error...
Pl give me solution...
thanks in advance.Hi:
You have to make sure that join condition joins one record to one record not to a group of records.
Saad,
http://saadnayef.blogspot.com/ -
10GR2 - How can I load multiple row values into one field?
Hi
Can anyone please help with a problem I'm having with merging data.
The source table has multiple entries for the same Id e,g,
ID Code
1 123
1 234
2 123
2 567
The output should only have one row per ID e.g.
ID Code_List
1 123;234
2 123;567
Do you know what operator I could use that would allow me to do this? I've looked at unpivot but I think I would need multiple output fields (one for each Code). I have to concatinate the codes and separate with a semi-colon.
Thanks
GBQ) Input data
=============
COL_0,COL_4
1235,"G0123,G124,G25,G6"
1236,"G01,G23,G124,G25,G6"
1237,"G0123,G1,G24,G25,G6"
1238,"G,G0123,G124,G25,G6"
1239,"G0123124,G256"
Output
======
TEST_ID,TEST_VAL
1235,G0123
1235,G124
1235,G25
1235,G6
1236,G01
1236,G23
1236,G124
1236,G25
1236,G6
1237,G0123
1237,G1
1237,G24
1237,G25
1237,G6
1238,G
1238,G0123
1238,G124
1238,G25
1238,G6
1239,G0123124
1239,G256
I wrote this procedure...
declare
rcd_cnt number;
test_id123 number;
junk_1 number;
cd_occurences number;
child_count number;
str_abc varchar2(200);
char_pos number default 0;
cd_temp_str varchar2(50);--:= 'G0123,G124,G25,G6';
begin
select nvl(count(col_4),0) into rcd_cnt from test_ee where col_4 is not null;
for aa in 1 .. rcd_cnt loop
select col_0,rownum rn,nvl(trim(col_4),0) into test_id123,junk_1,cd_temp_str from (select col_0,rownum rn,col_4 from test_ee where col_4 is not null) where rn = aa;
--dbms_output.put_line('...I am in for loop...' || cd_temp_str);
--dbms_output.put_line('===================' || rcd_cnt || '.................' ||aa);
cd_occurences := length(cd_temp_str) - length(replace(cd_temp_str,','));
dbms_output.put_line(cd_temp_str || '...Str Occurences are ...'||cd_occurences ||'**************'||test_id123);
child_count :=0;
for z in 1..length(cd_temp_str)+1 loop
child_count := child_count+1;
if(instr(cd_temp_str,',') > 0) then
char_pos := instr(cd_temp_str,',',1,1);
str_abc := substr(cd_temp_str,1,char_pos-1);
dbms_output.put_line('..Partial String of..'|| z ||'..is.....' || str_abc);
insert into test_xx(test_id,test_val) values(test_id123,str_abc);
end if;
cd_temp_str := substr(cd_temp_str,char_pos+1,length(cd_temp_str));
if(cd_occurences=child_count) then
dbms_output.put_line('..Partial String of..is.....' || cd_temp_str);
insert into test_xx(test_id,test_val) values(test_id123,cd_temp_str);
end if;
end loop; -- close for of z */
--dbms_output.put_line('...I am in end for loop...');
end loop; -- close for of aa
end;
instead of procedure,is there any way from sqlqery.
Maybe you are looking for
-
GRIR Automatic Clearing at the time of GR
Hi Experts In GRIR clearing account system automatically cleared open items when perform following entries: 1. Entry at the time of GR Inventory A/C Dr GRIR A/C Cr 2. Entry at the time of LIV GRIR A/C Dr Ve
-
Slow response when updating files on server
Hey there, I'm trying to pinpoint a problem I'm having with my Mac Pro and MacBook Pro regarding very slow page refreshes when modifying files on my server via browser. I'm using a software package called Photo Cart that is a shopping cart for my web
-
Newbie problem with new objects and tools.
in chapter 4 of the after effects essential training series from Lynda.com in the section about controlling animation with the pick whip. when he applies the null object the red bar immediately populates (correct usage?) the timeline to the right. wh
-
Not showing any disk partition
previously i installed linux on my machine.now i want to install windows8,but the disk partition is not showing...
-
Online Portfolios (that integrate with an existing site?)
Hi All. I'm using mobile me to show work and this both involves a click on an active link and it involves an external vendor (mac) with a readily identifiable site (mobile me). Is there such as thing as a site that will allow me to show albums of pho