One row with checkboxes in ALV
Hi All,
I woud like to create an ALV which consists of a row with checkboxes.
Eg.:
Doc - Mat - Unit - Date
1 -1234 - pc - 010109
2 - 545 - pc - 050208
3 - X - X - X
4 - 466 - pc - 251208
You can see that the 3. row has 3 checkboxes.
Is this possible?
Thanks in advance,
Gabor
Edited by: Gabor Peter Kocsis on Jan 15, 2009 9:14 PM
Hi,
No, you can't take a single row with checkboxes and other rows for other fields.
But instead you can add a checkbox for each row in ALV.
Regards,
Tarun Gambhir
Similar Messages
-
Condition that takes only one row with the maximum cost of the maximum date
I have to the following query
SELECT distinct b.segment1 ||'.'|| b.segment2 as ITEM,
so.vendor_site_id as SUPPLIER,
'VE' as ORIGIN_COUNTRY_ID,
replace(round(l.mto_costo_neto/l.can_unidades_empaque,2),',','.') as UNIT_COST,
5 as lead_time,
null as pickup_lead_time,
l.can_unidades_empaque as supp_pack_size,
1 as inner_pack_size,
'C' as round_lvl,
50 as ROUND_TO_INNER_PCT,
50 as ROUND_TO_CASE_PCT,
50 as ROUND_TO_LAYER_PCT,
50 as ROUND_TO_PALLET_PCT,
null as MIN_ORDER_QTY,
null as MAX_ORDER_QTY,
'FLAT' as PACKING_METHOD,
'N' as PRIMARY_SUPP_IND,
'Y' as PRIMARY_COUNTRY_IND,
case when b.primary_unit_of_measure like '%KG%' then 'KG'
when b.primary_unit_of_measure like '%Kg%' then 'KG'
when b.primary_unit_of_measure like '%UND%' then 'EA'
when b.primary_unit_of_measure = 'Kilogramo' then 'KG'
when b.primary_unit_of_measure = 'Litro' then 'L'
when b.primary_unit_of_measure = 'Unidad' then 'EA'
else null
end as DEFAULT_UOP,
1 as TI,
1 as HI,
null as SUPP_HIER_TYPE_1,
null as SUPP_HIER_LVL_1,
null as SUPP_HIER_TYPE_2,
null as SUPP_HIER_LVL_2,
null as SUPP_HIER_TYPE_3,
null as SUPP_HIER_LVL_3,
null as CREATE_DATETIME,
null as LAST_UPDATE_DATETIME,
null as LAST_UPDATE_ID,
case when b.primary_unit_of_measure like '%KG%' then 'KG'
when b.primary_unit_of_measure like '%Kg%' then 'KG'
when b.primary_unit_of_measure like '%UND%' then 'EA'
when b.primary_unit_of_measure = 'Kilogramo' then 'KG'
when b.primary_unit_of_measure = 'Litro' then 'L'
when b.primary_unit_of_measure = 'Unidad' then 'EA'
else null
end as COST_UOM,
null as TOLERANCE_TYPE,
null as MAX_TOLERANCE,
null as MIN_TOLERANCE
FROM mrp.mrp_sr_assignments sr , MRP.MRP_SR_RECEIPT_ORG ro , MRP.MRP_SR_SOURCE_ORG so,
inv.mtl_system_items_b b, lcm.cmp_lineas_cotizacion l
WHERE sr.SOURCING_RULE_ID = ro.SOURCING_RULE_ID
and ro.SR_RECEIPT_ID = so.SR_RECEIPT_ID
and sr.inventory_item_id in ((select inventory_item_id from TMP.VIVERES_VEGETALES)
UNION ALL
(select inventory_item_id from TMP.GENERICOS)
UNION ALL
(select inventory_item_id from TMP.HIJOS_GENERICOS))
and sr.inventory_item_id = b.inventory_item_id
and b.organization_id = 136
and sr.inventory_item_id = l.cod_producto_idI need to agregate the following condition
For example, The following query
SELECT l2.fec_ini_vigencia_costo, l2.mto_costo_neto, l2.can_unidades_empaque, l2.cod_producto,
REPLACE(ROUND(l2.mto_costo_neto/l2.can_unidades_empaque,2),',','.') costo_unidad
from cmp_lineas_cotizacion l2
order by cod_producto, fec_ini_vigencia_costo desc, mto_costo_neto descgenerate
FEC_INI_VIGENCIA_COSTO MTO_COSTO_NETO CAN_UNIDADES_EMPAQUE COD_PRODUCTO COSTO_UNIDAD
17/06/2010 382.56 12 1.1000008 31.88 -- THIS ONE
17/06/2010 382.56 12 1.1000008 31.88
17/06/2010 371.0832 12 1.1000008 30.92
17/06/2010 371.0832 12 1.1000008 30.92
18/05/2009 382.56 12 1.1000008 31.88
04/05/2009 245.82 12 1.1000008 20.49
13/04/2009 382.56 12 1.1000008 31.88
23/03/2009 373.2072 12 1.1000008 31.1
23/03/2009 373.2072 12 1.1000008 31.1I need to take only one row with the maximum FEC_INI_VIGENCIA with the maximum COSTO_UNIDAD of the table lcm.cmp_lineas_cotizacion l, which is calculated with the formula ROUND(l2.mto_costo_neto/l2.can_unidades_empaque,2)A better example
I need only one row the maximum COSTO_UNIDAD for the maximum FEC_INI_VIGENCIA for every cod_producto_id in the table lcm.cmp_lineas_cotizacion
I need to take these values
FEC_INI_VIGENCIA_COSTO MTO_COSTO_NETO CAN_UNIDADES_EMPAQUE COD_PRODUCTO_ID COSTO_UNIDAD
17/06/2010 382.56 12 1.1000008 31.88 -- THIS!
17/06/2010 382.56 12 1.1000008 31.88
17/06/2010 371.0832 12 1.1000008 30.92
17/06/2010 371.0832 12 1.1000008 30.92
18/05/2009 382.56 12 1.1000008 31.88
04/05/2009 245.82 12 1.1000008 20.49
13/04/2009 382.56 12 1.1000008 31.88
17/06/2010 382.56 12 1.1000008 31.88
17/06/2010 382.56 12 1.1000008 31.88
17/06/2010 371.0832 12 1.1000008 30.92
17/06/2010 371.0832 12 1.1000008 30.92
18/05/2009 382.56 12 1.1000008 31.88
04/05/2009 245.82 12 1.1000008 20.49
13/04/2009 382.56 12 1.1000008 31.88
27/10/2010 1171.549344 12 1.1000009 97.63 -- THIS!
13/10/2010 1171.549344 12 1.1000009 97.63
06/09/2010 1171.549344 12 1.1000009 97.63
02/08/2010 1048.825056 12 1.1000009 87.4
28/07/2010 754.8 12 1.1000009 62.9
27/07/2010 614.04 12 1.1000009 51.17
21/06/2010 954.84 12 1.1000009 79.57
27/05/2010 614.04 12 1.1000009 51.17
07/07/2009 1143.17 12 1.1000010 95.26
28/03/2009 1143.17 12 1.1000010 95.26
27/10/2008 1744.644672 12 1.1000010 145.39
01/07/2008 1690.12224 12 1.1000010 140.84
07/07/2009 1143.17 12 1.1000010 95.26 --THIS!
28/03/2009 1143.17 12 1.1000010 95.26
27/10/2008 1744.644672 12 1.1000010 145.39
01/07/2008 1690.12224 12 1.1000010 140.84
07/07/2009 1143.17 12 1.1000010 95.26
28/03/2009 1143.17 12 1.1000010 95.26
27/10/2008 1744.644672 12 1.1000010 145.39
01/07/2008 1690.12224 12 1.1000010 140.84 -
More than one Row Field headings in ALV
Hello Everyone,
i have one requirement wher i need to give more than one row of field heading. one main heading and sub field headings. Following is structure which will give an idea.
Current PIR Quantities| -> Main heading
Qty1|Date1Qty2|Date2| -> Sub headings
| | | | -> report values will come here
| | | | -> -
do----
Can you please let me know how can we get this lay out in field catalogue for field headings??
Thanks in Advance
Siva
Message was edited by:
Siva VelamaHi Atish,
Thanks for your reply. i dont have data in two levels for Hierarchial-sequential ALV. Data is just one row. But field headings(fieldcatalogue in alv) will have two rows. That means one row of main headings and second row with detailed fields. One main heading may have more than one subheading. ultimately we display values for Subheading fields.
hope you have understood the requirement.
Thanks
Siva -
How to return one ROW with Multiple value seperated by Colon in a SQL Query
Hi,
I have a SQL query as mentioned.
select deptno
from deptI want to mofidfy this query, so that this should return me department list with colon delimeted in one ROW.
10:20:30:40.......Thanks,
DeepakIn 10g:
select rtrim(xmlagg(xmlparse(content deptno || ':')).getstringval(), ':') data
from dept;
DATA
10:20:30:40with apologies for the abuse of XML... -
Problems with checkbox in ALV-GRID OO
Hi,
i have Problems by listing an editable checkbox
in ALV GRID OO and handle the itab with
the marked fields.
Here my Code extract. Has anybody an idea or a short example.
TYPES: BEGIN OF ALV_TAB,
SGTXT LIKE RK23B-SGTXT,
CHECK(1),
END OF ALV_TAB.
DATA: ITAB TYPE TABLE OF ALV_TAB.
Is this Declaration correct??
<b> GS_FIELDCAT-FIELDNAME = 'CHECK'.
GS_FIELDCAT-CHECKBOX = 'X'.
APPEND GS_FIELDCAT TO GT_FIELDCAT.
GS_LAYOUT-EDIT = 'X'.
GS_LAYOUT-BOX_FNAME = 'CHECK'.</b>
CALL METHOD GR_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IT_TOOLBAR_EXCLUDING = PT_EXCLUDE
IS_LAYOUT = GS_LAYOUT
CHANGING
IT_FIELDCATALOG = GT_FIELDCAT
IT_OUTTAB = ITAB.
FORM HANDLE_USER_COMMAND USING E_UCOMM.
CASE E_UCOMM.
WHEN 'REFR'.
<b> Here i will have the itab with the marked checkbox.
how can i refresh?</b>*
WHEN 'EXCEL'.
MESSAGE I010 WITH E_UCOMM.
ENDCASE.
ENDFORM. "HANDLE_USER_COMMAND
Regards, DieterHi, in reference to....
ASE E_UCOMM.
WHEN 'REFR'.
Here i will have the itab with the marked checkbox.
how can i refresh?*
Do you want to get rid of the checks in any checkbox?
If so, just loop at modify.
ASE E_UCOMM.
WHEN 'REFR'.
<b> Loop at itab where check = 'X'.
itab-check = space.
modify itab.
endloop.</b>
Regards,
Rich Heilman -
List out on the one row with all variables from db
from DB
namn
namnID namn
166 -----------------------
167 pierre lemon
170 Lena Jakobsson
171 adas
172 Lena M Jakobsson
175 Per Olofsson
Inmata
id namnID startdate slutdate vc fargkod
50 167 2006-04-20 2006-04-27 Uddevalla Re
54 167 2006-05-20 2006-07-20 Vänersborg A
58 167 2006-08-21 2006-09-01 Uddevalla O
61 170 2006-04-24 2006-05-03 ----- P
<cfquery name="row_stsl" datasource="at">
SELECT DISTINCT count(namnID) as sum_namnID
FROM inmata
group by namnID
</cfquery>
<cfset sum_namnIDa = row_stsl.sum_namnID>
<cfoutput query="row_stsl">
<table border="1">
<tr><td>#sum_namnID#</td></tr>
</cfoutput>
<cfscript>
for (i=1; i lt sum_namnIDa; i=i+1)
writeoutput ( "<td>" & startdate & slutdate
& "</td>");
</cfscript>
<cfoutput>
</table>
</cfoutput>
My idea is to count number of nameID and build one row using
<td> within startdate and slutdate </td>
if there is 3 namnID so create three startdate and slutdate
but don't know exact how to code.
Any suggestion?
I tried to get out startdate and slutdate in ordinal on the
one row.
Name:
eg.
Pierre Lemon 1. 2006-04-24 2006-06-02 2. 2006-06-03
2006-07-25 3. etc startdate and slutdate on the row.<cfquery name="row_stsl" datasource="at">
SELECT Count(inmata.namnID) AS sum_namnID,
First(inmata.startdate) AS Förstaförstartdate,
Last(inmata.slutdate) AS Sistaförslutdate
FROM inmata
WHERE ((inmata.startdate) AND (inmata.slutdate))
GROUP BY inmata.namnID;
</cfquery>
<cfloop query="row_stsl">
<table border="1">
<tr>
<cfscript>
for (i=1; i lte sum_namnID; i=i+1)
writeoutput ("<td>" & #dateformat
(Förstaförstartdate,"yyyy-mm-dd")# & " "
& #dateformat (Sistaförslutdate,"yyyy-mm-dd")# &
"</td>");
</cfscript>
</tr>
</table>
</cfloop>
Resultat:
2006-04-20 2006-09-01 2006-04-20 2006-09-01 2006-04-20
2006-09-01
2006-04-24 2006-05-03
In DB
id namnID startdate slutdate
50 167 2006-04-20 2006-04-27
54 167 2006-05-20 2006-07-20
58 167 2006-08-21 2006-09-01
61 170 2006-04-24 2006-05-03
yes, startdate and slutdate is date as datatype
Is it SQL statement or cfscript I will change on?
Have tried with other sql question but it will not take
effect to get out answer.
SELECT inmata.namnID, Count(inmata.namnID) AS Antal,
inmata.startdate AS start_datum, inmata.slutdate AS slut_datum
FROM inmata
GROUP BY inmata.namnID, inmata.startdate, inmata.slutdate
HAVING (((inmata.startdate) Is Not Null) AND
((inmata.slutdate) Is Not Null));
Because the result is :
2006-04-20 2006-05-03
2006-04-20 2006-04-27
2006-05-20 2006-07-20
2006-08-21 2006-09-01
2006-04-24 2006-05-03
2006-04-20 2006-04-27
2006-08-21 2007-05-03
Any idea?! -
Keeping only one row with information from several rows?
Hi,
I have a table with companies. The companies appearing more then once in the table, with different information in different columns. How do I keep one row from each company with all information..?
Example:
Company State City Country
CompA WA Seattle null
CompA null null USA
CompB null null USA
CompB TX null null
...and so on.
And I want out of this:
CompA WA Seattle USA
CompB TX null USA
Any tips?declare @temp table
company char(6),
state char(10),
city char(20),
country char(10))
insert into @temp values ('CompA','WA','Seattle',null),('CompA',null,null,'USA')
,('CompB','Tx',null,null),('CompB',null,null,'USA')
select max(company),MAX(state),MAX(city),MAX(country) from @temp
group by company
--Prashanth -
Dear all,
I have a input that looks like this:
HeaderKeySomeHeaderInformationItemKeySomeItemInformationItemKeySomeItemInformation...
Here's the actual input
TEHGMESS0026000000288S0001TEI2____026200006112410400000000 18010000000000 00126000000000126000120600000000002000000000 000WESTMONOBERTBE2014052309422408120003 000000000000000000000000000000JTEI2____026200006112410400000000 19010000000000 00126000000000126000120600000000002000000000 000WESTMONOBERTBE2014052309422408120003 000000000000000000000000000000J
HeaderKey = TEHGMESS
ItemKey = TEI2____
Is it possible to process this via MessageTransformBean (my actual scenario is JMS to IDoc)? I already tried but I only succeeded when having new lines in my input to separate between Header and (multiple) Items.
So when the input and my configuration looks like below it works, but when I only have a single row input it doesn't work, even when specifying xml.recordHeader.endSeparator = '0' / xml.recordItem.endSeparator = '0'. I even tried xml.endSeparator = '0' but no luck.
Input that works
TEHGMESS0026000000288S0001
TEI2____026200006112410400000000 18010000000000 00126000000000126000120600000000002000000000 000WESTMONOBERTBE2014052309422408120003 000000000000000000000000000000J
TEI2____026200006112410400000000 19010000000000 00126000000000126000120600000000002000000000 000WESTMONOBERTBE2014052309422408120003 000000000000000000000000000000J
Matching configuration that works for input which structures are delimited by new line.
Paramentername
Parametervalue
Transform.Class
com.sap.aii.messaging.adapter.Conversion
Transform.ContentType
text/xml;charset=utf-8
xml.conversionType
StructPlain2XML
xml.documentName
MT_TEI2Split
xml.documentNamespace
http://hansgrohe.com/pi/MQ/TEI2/10
xml.keyFieldName
SATZARTKey
xml.keyFieldType
CaseSensitiveString
xml.processFieldNames
fromConfiguration
xml.recordHeader.fieldFixedLengths
8,4,9,1,4
xml.recordHeader.fieldNames
SATZARTKey,SATZLENHG,NUTZLEN,MESSAE,MESSNR
xml.recordHeader.keyFieldValue
TEHGMESS
xml.recordItem.fieldFixedLengths
8,4,2,10,8,19,3,3,2,10,6,2,10,6,2,10,6,6,6,6,6,11,9,2,10,6,2,10,6,3,4,3,7,14,8,1,31
xml.recordItem.fieldNames
SATZARTKey,SATZLEN,BUCHART,TRNR,ANDGNR,MITEM,TEIVARI,BSTSTATU,REFTYP,ORNO,POS,REFTYP1,ORNO1,POS1,CHATYP,CHARGE,CHAPOS,ABBVONL,ABBNACH,ZUBVONL,ZUBNACH,I2MENG,I2BUNR,REFTYPN,ORNON,POSN,REFTYP1N,ORNO1N,POS1N,BSTSTATN,ABUSERAB,ABUSERFN,ABUSERNA,I2TIME,I2LIDNR,I2FMCODE,FILLER
xml.recordItem.keyFieldValue
TEI2____
xml.recordsetName
records
xml.recordsetStructure
recordHeader,1,recordItem,*
Any clues on this? Is it even possible to have multiple structures in one row? Many thanks in advance
JensSAP came back to me with this answer:
First, I would like to point the documentation for Message Transform
Bean (MTB) in 7.4:
http://help.sap.com/saphelp_nw74/helpdata/en/57/0b2c4142aef623e10000000a155106/content.htm?frameset=/en/57/0b2c4142aef623e10000000a155106/frameset.htm¤t_toc=/en/45/0ea2de423c2d6be10000000a11466f/plain.htm&node_id=18
As it is written at the beginning of this document, MTB is used to
call classes written for the Plain Adapter Engine. So you may find
additional documentation about the parameters for convertion in the
documentation of the Plain Adapter Engine
(http://help.sap.com/saphelp_nw74/helpdata/en/0d/00453c91f37151e10000000a11402f/content.htm?frameset=/en/1b/d5ef3b1ad56d4fe10000000a114084/frameset.htm¤t_toc=/en/75/246b3de666930fe10000000a114084/plain.htm&node_id=11).There it is written that the structures by default are
arranged line-by-line. The endSeparator just adds additional character
string as a separator after the last column in a row.
I hope that this answers your question. MTB expects the data to be
structured line by line.
You may add a custom module, which transforms the message in the
expected format.
If you have a look at the second link there's even a more precise wording that multiple structures within one line are not supported:
xml.NameA.endSeparator
Even if no specification is made here, a line break must follow since substructures are always expected as a line of the document.
Bottom line is that it's not supported by now and verfied by me with PI 7.4 SP5
Many thanks to Ambrish, Amit and Hareesh for the valuable input. Will probably try to work things out for now following Ambrish's / Hareesh's suggestion as this seems easier to implement. Amit's proposal with a dedicated module however would probably be the more polished solution.
Cheers
Jens -
Insert one row with FileInputStream bigger than 30M always OutOfMemoryError
Hi,somebody can help me to solve my problem as follow:
The following file 'insertTest.jsp' run with Tomcat-5.0.18 and MySQL-4.0.17.
If I insert a row with a file bigger then 30M,I always get OutOfMemoryError messages shown as next.
In fact , I have adjusted variables as:
set-variable = max_allowed_packet=100M
set-variable = max_heap_table_size=100M
set-variable = tmp_table_size=100M
set-variable = key_buffer_size=100M
set-variable = innodb_buffer_pool_size=100M
set-variable = max_connections=200
set-variable = bulk_insert_buffer_size=100M
set-variable = sort_buffer_size=100M
set-variable = myisam_sort_buffer_size=100M
'insertTest.jsp' :
<%@ page language="java" contentType="text/html;charset=Big5" errorPage="" %>
<%@ page import="java.sql.*,java.io.*" %>
<%
Connection conn = null;
java.sql.Statement stmt = null;
String tableName="goodtable";
boolean tableNameExist=false;
String createtable = "Create table "+tableName+" (sn INT AUTO_INCREMENT NOT NULL PRIMARY KEY ,fileImage longblob)";
Class.forName("com.mysql.jdbc.Driver");
conn =DriverManager.getConnection("jdbc:mysql://thisIpAddress/thisDatabaseName?user=thisUser&password=thisPsw");
try {
DatabaseMetaData dbmd = conn.getMetaData();
String[] types = {"TABLE"};
ResultSet resultSet = dbmd.getTables(null, null, "%", types);
while (resultSet.next()) {
String tName = resultSet.getString(3);
if(tName.equals(tableName)){
tableNameExist=true;
break;
String tableCatalog = resultSet.getString(1);
String tableSchema = resultSet.getString(2);
catch (SQLException e) {}
out.print("<html><body bgcolor='#669999'>");
if(!tableNameExist){
stmt = conn.createStatement();
stmt.execute(createtable);
out.print("<p> <p><center>CreateTable="+tableName+" Ok!<hr>");
else
out.print("<p> <p><center>' "+tableName+" ' already exist!<hr>");
//The test file(at C:\fileSize30M.zip) is put here.
File file = new File("C:\\fileSize30M.zip");
FileInputStream fis = new FileInputStream(file);
String qry="Insert into "+tableName+"(fileImage) values(?)";
java.sql.PreparedStatement pstmt=conn.prepareStatement(qry);
pstmt.setBinaryStream(1,fis,fis.available());
out.print("'before pstmt.executeUpdate()' is ok<p>");
System.out.println("'before pstmt.executeUpdate()' is ok<p>");
int ok=pstmt.executeUpdate();
if(ok==1){
out.print("'after pstmt.executeUpdate()' is ok");
System.out.println("'after pstmt.executeUpdate()' is ok<p>");
fis.close();
pstmt.close();
conn.close();
out.print("</body></html>");
%>
type: Exception report
description: The server encountered an internal error () that prevented it from fulfilling this request.
exception :
javax.servlet.ServletException
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.insertTest_jsp._jspService(insertTest_jsp.java:101)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
root cause :
java.lang.OutOfMemoryErrorIncrease you heap size on Tomcat startup. I haven't used Tomcat in some years but I think you can just set a JAVA_OPTS environment variable with the text Xmx128M and your problems will go away. I'm thinking this is an issue because I'm assuming you are running Tomcat on a Windows box where the default heap for Java is relatively small like 32M or 64M or something like that.
Cliff -
How to turn many rows into one row with many coloums
When I have a table for example
NR DATA
1 abc
2 dfg
3 hijI must convert this into a view that would look like:
1 2 3
abc dfg hijThe number of rows is dynamic. So I cannot make a static view.
I cannot use pivot because I use Oracle 10g.
Can anyoune help me?
Edited by: WoMo on 25.04.2013 07:23Hi,
WoMo wrote:
My NR values and DATA values are not known!You can use String Aggregation for that. See {message:id=10963258}
For more options, see {message:id=3527823}
I hope this answers your question.
If not, post your best attempt, along with a little sample data (CREATE TABLE and INSERT statements), and also post the results you want from that data.
See the forum FAQ {message:id=9360002} -
Interchange values from one row with another row
Dear Oracle Guru's
While Migrating data from legacy system, there was a confusion and data in two columns got jumbled
Ex The data should be like this
Custcode leaseno
1034 A234
1035 A235
1036 A236
whereas the table has data like this
Custcode leaseno
1034 A235
1035 A234
1036 A237
1037 A236
How do we swap values between two rows
Kindly guide me on this
With Warm Regards
ssr>
Ex The data should be like this
Custcode leaseno
1034 A234
1035 A235
1036 A236
whereas the table has data like this
Custcode leaseno
1034 A235
1035 A234
1036 A237
1037 A236
How do we swap values between two rows And now, time for yet another guess... ;)
My guess is that your migration program interchanged "leaseno" value in pairs from the top - the top being the least value of "custcode".
So, the "leaseno" values of Row 1 and Row 2 were swapped.
The "leaseno" values of Row 3 and Row 4 were swapped.
And so on.
Which also means that if the total number of rows in your table is even, then the swap would be "complete". Otherwise, the last row would be left out. I don't know what you want to do with that.
test@XE>
test@XE> select * from t;
CUSTCODE LEAS
1034 A235
1035 A234 <= you want to swap A235 and A234
1036 A237
1037 A236 <= you want to swap A237 and A236
1038 A238 <= let's leave it hanging there...
5 rows selected.
test@XE>
test@XE> And of course, swapping from "top to bottom" means swapping from the least to highest value of "custcode".
Here's the SELECT statement for that -
test@XE>
test@XE> -- show the records in the table t
test@XE>
test@XE> select * from t;
CUSTCODE LEASENO
1034 A235
1035 A234
1036 A237
1037 A236
1038 A238
5 rows selected.
test@XE>
test@XE> -- the SELECT statement for swapping leaseno values
test@XE>
test@XE> @test7a
test@XE> --
test@XE> select custcode,
2 leaseno,
3 case
4 when mod(row_number() over (order by custcode),2) = 1 and
5 lead(leaseno) over (order by custcode) is null
6 then leaseno
7 when mod(row_number() over (order by custcode),2) = 1
8 then lead(leaseno) over (order by custcode)
9 else lag(leaseno) over (order by custcode)
10 end as new_leaseno
11 from t;
CUSTCODE LEASENO NEW_LEASENO
1034 A235 A234
1035 A234 A235
1036 A237 A236
1037 A236 A237
1038 A238 A238
5 rows selected.
test@XE>
test@XE> And here's the update statement -
test@XE>
test@XE> -- the UPDATE statement for updating leaseno values in pairs from the top
test@XE>
test@XE> @test7b
test@XE> --
test@XE> update t t1
2 set t1.leaseno = (
3 select new_leaseno
4 from (
5 select custcode,
6 leaseno,
7 case
8 when mod(row_number() over (order by custcode),2) = 1 and
9 lead(leaseno) over (order by custcode) is null
10 then leaseno
11 when mod(row_number() over (order by custcode),2) = 1
12 then lead(leaseno) over (order by custcode)
13 else lag(leaseno) over (order by custcode)
14 end as new_leaseno
15 from t
16 ) t2
17 where t2.custcode = t1.custcode
18 );
5 rows updated.
test@XE>
test@XE>
test@XE> select * from t;
CUSTCODE LEASENO
1034 A234
1035 A235
1036 A236
1037 A237
1038 A238
5 rows selected.
test@XE>
test@XE> HTH,
isotope -
Splitting multiple rows onto one row with different fields
Hi all,
I have a table. One Course_Code have multiple section_codes i.e. ("NUM" column does not relate to sectype its just an order!)
Code--------num----Sec_code---Sectype---DESC----------------WEIGHT
1603--------1-------7427-----------C------------Coursework-------- 50
1603--------2-------7428-----------E------------ Exam---------------- 50
When I query this table i want to be able to see the coursework, exam split on the same row. i.e.
Code-----Coursework---------Exam
1603-----C=50------------------E=50
any help would be greatHi,
"Splitting" means taking an item (such s a string like 'C=50') and diviiding it into smal;ler items (such as the sub-strings 'C' and '50'). Are you really trying to split something, or are you trying to do just the opposite (e.g., combine smaller strings into a bigger string)?
I think what you're looking for is a Pivot . Like so many other things, exactly how to do it depends on your version of Oracle and your requirements.
Here's one way:
SELECT code
, MIN (CASE WHEN descr = 'Coursework' THEN sectype END)
|| '='
MIN (CASE WHEN descr = 'Coursework' THEN weight END) AS coursework
, MIN (CASE WHEN descr = 'Exam' THEN sectype END)
|| '='
MIN (CASE WHEN descr = 'Exam' THEN weight END) AS exam
FROM table_x
GROUP BY code
;This will work in Oracle 8.1 and higher. Starting in Oracle 11.1, you could also use the SELECT ... PIVOT feature.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using. -
Convert multiple rows to one row with multiple columns
Hi
i have a table Match_1 with 2 columns 'Source' and 'target'.One source can have multiple targets and that number could be anything
CREATE TABLE Match_1
Source CHAR(1),
Target CHAR(1)
INSERT INTO Match_1 VALUES ('A', 'B');
INSERT INTO Match_1 VALUES ('A', 'C');
INSERT INTO Match_1 VALUES ('A', 'D');
INSERT INTO Match_1 VALUES ('A', 'E');
INSERT INTO Match_1 VALUES ('V', 'X');
INSERT INTO Match_1 VALUES ('V', 'Y');
INSERT INTO Match_1 VALUES ('V', 'X');
INSERT INTO Match_1 VALUES ('V', 'W');
COMMIT;
i need to get my output in the below format
Source target 1 target 2 target 3 target 4 target n
A B C D
V X Y Z W
Could you please provide me the required SQL.
REgards
-LearnsequelWhat is your database version (4 digit) ? also my example won't be generate columns for your information:
it will produce a result like that :
select source, listagg(target,',') within group (order by target)
from match_1
group by source;
A B,C,D,E
V W,X,X,Yps: in previos post, I wrote "with" word wrong in sql. -
BUG? ViewObject contains more than one Row with equal Key objects
JDeveloper 10.1.2.1 build 1913
JClient app
aView
----bView
--------cView
------------dView
BEFORE:
cView's detail row set contains two dViewRowImpl rows, as expected:
row 0: key = 100
row 1: key = 101
ACTION:
An attribute, X, in dView is modified by the user, which results in a call to setX in dViewRowImpl.
In setX we have:
1) setAttributeInternal for X
2) transaction.postChanges
3) a call to a procedure in the database to update dependent fields in the same row
4) clearEntityCache on the primary entity of dView
5) setAttributeInternal on a calculated attribute
AFTER:
cView's detail row set contains three dViewRowImpl rows, two of which have the same primary key:
actual:
row 0: key = 100
row 1: key = 101
row 2: key = 101
expected (no change, and unique primary keys):
row 0: key = 100
row 1: key = 101
Any clues appreciated.If your procedure modifies only the current row, or predetermined rows, you can
// see Row.refresh
transaction.postChanges();
// refresh current row
refresh(REFRESH_WITH_DB_FORGET_CHANGES);
// or iterate over procedure-modified rows and refresh eachas an alternative to clearEntityCache. This alternative has the major benefit of not resetting currency in all ViewObjects touched by the cleared Entity. Luckily, this alternative has avoided the problem for us. If your code cannot predict which rows will be updated by your procedure, then you're still in trouble since JBO is apparently more than willing to insert duplicate Row objects into a ViewObject's RowSet after a clearEntityCache. -
How to select one row with such sql
hi , everyone
I got a headache about this sql:
select * from E_VPN_pbxlink where ((SPILOTNUM ='1234' ) or (SPILOTNUM ='123')) order by SPILOTNUM desc ;
it retruns 2 records.
I need to get the record with SPILOTNUM ='1234' , how can I reform this sql
tksHi,
I think I see:
You want the longest spilotnum that starts with the same charachters as the parameter.
You can do a Top-N Query like this:
WITH got_rnum AS
select e.*
, RANK () OVER (ORDER BY LENGTH (spilotnum DESC) AS rnum
from E_VPN_pbxlink
where '123456' LIKE SPILOTNUM || '%'
SELECT * -- or list all columns except rnum
FROM got_rnum
WHERE rnum = 1
;There is a slightly simplerr way, using the ROWNUM pseudo-column, but its only slightly easier, and it won't help if, say, you want to pass two or more targets such as '123456' in the same query.
Maybe you are looking for
-
Use of MPSS on Solaris 9 and Java 141_03 - not getting 4M pagesizes
Hi all, Anyone know how to get MPSS actually using large page sizes in 1.4 / SunOS 5.9 ?? I have a 1.4.1_03-b02 JVM that is using the -XX:+UseMPSS option and using the LD_PRELOAD=/usr/lib/mpss.so.1 and MPSSHEAP=4M but when I use pmap -Fxs <PID> I alw
-
I have ios 8.1 on my iphone 5s and I cannot connect to my bluetooth in my 2013 honda accord
I have ios 8.1 on my 5s Iphone but cannot connect to Bluetooth on my 2013 Honda accord
-
Illegal override error in latest CairngormNavigationLib
Hello, I'm implementing the latest Cairngorm 3 libraries into my parsley application (which uses modules) and I'm getting the following error: VerifyError: Error #1053: Illegal override of createReceiver in com.adobe.cairngorm.navigation.landmark.Abs
-
Hello, I would like conduct interviews using Facetime on my iMac, iPad or iPhone. When I'm done with the interview I will need to ad music and a voiceover for intros and outros. Does anyone have exerperience doing this with Apple product? I have trie
-
Hi there I am installing PT850 on my laptop and I am having problems to create the system database on Oracle 11gR1. If I do not create a database on installation time, I can not use sql developer or any other tool like sql+. If I create the database,