Select a single row from a billion row table
This is a fictitious scenario, how would you write a select statement on a table with a billion rows. It never returns anything,right? Somebody was suggesting a stored procedure.
As an example : Assuming a Table with columns Account(int), TransDate(DateTime), TransNum(int) and few other columns. I need a transaction that happened on 03-05-2014 8:15PM. Clustered index on Account. Non- clustered on TransDate.
I was suggested to create a stored procedure, inside the SP you have 3 parameters: min_date, max_date, avg= min_date+max_date/2. You create a loop and feed the avg value to the max_date or min_date depending on where the row is. This is a suggestion
that I am not clear my-self but wanted to see if you guys can help me develop this idea.
Also please suggest how you would do it in your world. You guys could have much better ideas probably much simpler one's. Thanks in advance.
svk
I basically just need transaction for one particular datetime. Not any span. One of our senior developers suggested that a simple select statement takes for ever to return a single row from a billion rows and suggested a vague idea as above.
Either there is a suitable index on the column, and the SELECT will be fast.
Or there is no index on the column, and in that case it will take quite some time to find the row. The only reason to loop is that you don't want to take out a table lock, but in that case you would do something like looping one account at a time. Looping
over different time values will only mean that you will scan the table multiple times.
Erland Sommarskog, SQL Server MVP, [email protected]
Similar Messages
-
ORA-22905: cannot access rows from a non-nested table item in Table func
I am using a table function in Oracle 8.1.7.4.0. I did declare an object type and a collection type like this:
CREATE TYPE t_obj AS OBJECT ...
CREATE TYPE t_tab AS TABLE OF t_obj;
My table function returns t_tab and is called like this:
SELECT ... FROM TABLE (CAST (my_pkg.table_fnc AS t_tab)) ...
This works pretty well as long as I run it in the same schema that owns the function and the 2 types. As soon as I run this query from another schema, I get an ORA-22905: cannot access rows from a non-nested table item error, even though I granted execute on both the types and the function to the other user and I created public synonyms for all 3 objects.
As soon as I specify the schema name of t_tab in the cast, the query runs fine:
SELECT ... FROM TABLE (CAST (my_pkg.table_fnc AS owner.t_tab)) ...
I don't like to have a schema hard coded in a query, therefore I'd like to do this without the schema. Any ideas of how to get around this error?Richard,
your 3 statements are correct. I'll go ahead and log a TAR.
Both DESCs return the same output when run as the other user. And, running the table function directly in SQL*Plus (SELECT my_pkg.table_fnc FROM dual;) also returns a result and no errors. The problem has to be in the CAST function.
Thanks for your help. -
ORA-22905: cannot access rows from a non-nested table item
Hi All,
This is the overview of the query used in the package.
select ename,empno,sal,deptno from
(select deptno from dept) a,
(select ename,empno,sal from emp1) b
where empno in (select * from table (pkg1.fun1('empno')))
and a.deptno=b.deptno
union
select ename,empno,sal,deptno from
(select deptno from dept) c,
(select ename,empno,sal from emp2) d
where empno in (select * from table (pkg1.fun1('empno')))
and c.deptno=d.deptno
Here the pkg1.fun1 will convert the string ('empno') into table form. ('empno') is the input parameter to the package and is a string of emp numbers.
compilation is successful. when this is executed the below error pops up
"ORA-22905: cannot access rows from a non-nested table item"
Is there any problem with the table function which i am using in this query
could anyone guide me to the solution.
Thanks AllI have used
CREATE OR REPLACE
type tab_num as table of number;
select * from table (cast(pkg1.fun1('empno')) as tab_num))
This throws an error during compilation itself
"PL/SQL: ORA-00932: inconsistent datatypes:expected number got varchar2 -
Oracle error ORA-22905: cannot access rows from a non-nested table item
Oracle error ORA-22905: cannot access rows from a non-nested table item
Creating a report using oracle plsql code .
Getting error ;
Oracle error ORA-22905: cannot access rows from a non-nested table item
when I am trying to pass data in clause in pl sql proc
basically I have a proc which takes 2 parameters(a and b)
proc (
P_a varchar2,
p_b varchar2,
OUT SYS_REFCURSOR
culprit code which is giving me the error and on google they say cast it but I dont know how to do it in my context
--where id in (
-- SELECT * FROM THE (SELECT p_cd_common.get_table_from_string(P_a) FROM dual)
-- union
-- SELECT * FROM THE (SELECT p_cd_common.get_table_from_string(P_b) FROM dual)
data sample returned from this :SELECT * FROM THE (SELECT p_cd_common.get_table_from_string(P_a) FROM dual)
'Abc','def',
data sample returned from this;SELECT * FROM THE (SELECT p_cd_common.get_table_from_string(P_b) FROM dual)
'fgd','fth',
Any answers ?
How to pass data in clause in a better wayWhy are you creating a duplicate post? I already asked you to post p_cd_common.get_table_from_string. In particular what is function return type and where it is declared. As I already mentioned, most likely function return type is declared in the package and therefore is PL/SQL type. And TABLE operator can only work with SQL types.
SY. -
SP which returns error cannot access rows from a non-nested table item.
Dear Experts
I have an SP which gives error " cannot access rows from a non-nested table item ". But here the strange thing is, it works fine with one query. But I write union query with another table, only then it gives error.
CREATE OR REPLACE PROCEDURE SP_MONTHLYSALESUMMARY (
P_TRANSACTIONMONTH VARCHAR2,
P_LEDGERID VARCHAR2,
O_RESULTSET OUT TYPES.CURSORTYPE)
AS
BEGIN
OPEN O_RESULTSET FOR
-- POINT OF SALE
SELECT
L.DESCRIPTION LEDGERNAME,
LS.DESCRIPTION LEDGERSUBGROUPNAME,
C.CORPORATENO
|| E.EMPLOYEENO
|| AF.AFFILIATEMEMBERNO
|| M.MEMBERNO
AS ID,
C.NAME || E.NAME || AF.NAME || M.NAME AS NAME,
SUM(CASE
WHEN PB.EMPLOYEE_ID IS NOT NULL
AND T.ISCREDITTRANSACTIONMODE = 2
THEN
PB.TAXAMOUNT
ELSE
0
END)
EMPLOYEEDEBITCARDTAXAMOUNT,
L.PRINTNO
FROM POINTOFSALEBILL PB
INNER JOIN POINTOFSALEBILLDETAIL PD
ON PB.POINTOFSALEBILL_ID = PD.POINTOFSALEBILL_ID
INNER JOIN TRANSACTIONTYPE TY
ON TY.TRANSACTIONTYPE_ID = PB.TRANSACTIONTYPE_ID
INNER JOIN TRANSACTIONMODE T
ON T.TRANSACTIONMODE_ID = PB.TRANSACTIONMODE_ID
INNER JOIN LEDGER L
ON L.LEDGER_ID = PD.LEDGER_ID
INNER JOIN LEDGERSUBGROUP LS
ON LS.LEDGERSUBGROUP_ID = L.LEDGERSUBGROUP_ID
LEFT JOIN CORPORATE C
ON C.CORPORATE_ID = PB.CORPORATE_ID
LEFT JOIN EMPLOYEE E
ON E.EMPLOYEE_ID = PB.EMPLOYEE_ID
LEFT JOIN AFFILIATEMEMBER AF
ON AF.AFFILIATEMEMBER_ID = PB.AFFILIATEMEMBER_ID
LEFT JOIN MEMBER M
ON M.MEMBER_ID = PB.MEMBER_ID
WHERE TY.ISDEBIT = 1 AND PB.FLAG = 0 AND T.ISROOMNO = 2
AND (P_TRANSACTIONMONTH IS NULL
OR P_TRANSACTIONMONTH =
TO_CHAR (PB.BILLDATE, 'fmMONTH-YYYY'))
AND (P_LEDGERID IS NULL
OR L.LEDGER_ID IN
( (SELECT COLUMN_VALUE
FROM TABLE(GET_ROWS_FROM_LIST1 (
P_LEDGERID,
GROUP BY L.DESCRIPTION,
LS.DESCRIPTION,
C.CORPORATENO
|| E.EMPLOYEENO
|| AF.AFFILIATEMEMBERNO
|| M.MEMBERNO,
C.NAME || E.NAME || AF.NAME || M.NAME,
L.PRINTNO;
END SP_MONTHLYSALESUMMARY;
GET_ROWS_FROM_LIST1 is a function, which i am using to pass " IN " to oracle. There is no problem with this, since it works fine with one query
REATE OR REPLACE FUNCTION BCLUB1868.GET_ROWS_FROM_LIST1
(L IN LONG DEFAULT NULL, SEP IN VARCHAR2 DEFAULT ',')
RETURN MYVARCHARTABLE1 PIPELINED
AS
L_POS INT := 1;
L_NEXT INT;
L_PART VARCHAR(500);
BEGIN
SELECT INSTR( L, SEP, L_POS) INTO L_NEXT FROM DUAL;
WHILE (L_NEXT>0)
LOOP
SELECT SUBSTR(L, L_POS, L_NEXT - L_POS) INTO L_PART FROM DUAL;
PIPE ROW(L_PART);
SELECT L_NEXT + 1, INSTR( L, SEP, L_POS)
INTO L_POS, L_NEXT FROM DUAL;
END LOOP;
SELECT SUBSTR(L, L_POS) INTO L_PART FROM DUAL;
PIPE ROW(L_PART);
RETURN;
END;
Request help from you all experts in the forumHere it is
CREATE OR REPLACE PROCEDURE SP_GRCS (
P_TRANSACTIONMONTH VARCHAR2,
P_LEDGERID VARCHAR2,
O_RESULTSET OUT TYPES.CURSORTYPE)
AS
BEGIN
OPEN O_RESULTSET FOR
-- Point of sale
SELECT *
FROM ( SELECT L.DESCRIPTION LEDGERNAME,
LS.DESCRIPTION LEDGERSUBGROUPNAME,
C.CORPORATENO
|| E.EMPLOYEENO
|| AF.AFFILIATEMEMBERNO
|| M.MEMBERNO
AS ID,
C.NAME || E.NAME || AF.NAME || M.NAME AS NAME,
SUM(CASE
WHEN PB.EMPLOYEE_ID IS NULL
AND T.ISCREDITTRANSACTIONMODE = 1
THEN
PB.BILLAMOUNT
ELSE
0
END)
MEMBERDEBITAMOUNT,
L.PRINTNO
FROM POINTOFSALEBILL PB
INNER JOIN POINTOFSALEBILLDETAIL PD
ON PB.POINTOFSALEBILL_ID = PD.POINTOFSALEBILL_ID
INNER JOIN TRANSACTIONTYPE TY
ON TY.TRANSACTIONTYPE_ID = PB.TRANSACTIONTYPE_ID
INNER JOIN TRANSACTIONMODE T
ON T.TRANSACTIONMODE_ID = PB.TRANSACTIONMODE_ID
INNER JOIN LEDGER L
ON L.LEDGER_ID = PD.LEDGER_ID
INNER JOIN LEDGERSUBGROUP LS
ON LS.LEDGERSUBGROUP_ID = L.LEDGERSUBGROUP_ID
LEFT JOIN CORPORATE C
ON C.CORPORATE_ID = PB.CORPORATE_ID
LEFT JOIN EMPLOYEE E
ON E.EMPLOYEE_ID = PB.EMPLOYEE_ID
LEFT JOIN AFFILIATEMEMBER AF
ON AF.AFFILIATEMEMBER_ID = PB.AFFILIATEMEMBER_ID
LEFT JOIN MEMBER M
ON M.MEMBER_ID = PB.MEMBER_ID
WHERE TY.ISDEBIT = 1 AND PB.FLAG = 0 AND T.ISROOMNO = 2
AND (P_TRANSACTIONMONTH IS NULL
OR P_TRANSACTIONMONTH =
TO_CHAR (PB.BILLDATE, 'fmMONTH-YYYY'))
AND (P_LEDGERID IS NULL
OR L.LEDGER_ID IN
( (SELECT COLUMN_VALUE
FROM TABLE(GET_ROWS_FROM_LIST1 (
P_LEDGERID,
GROUP BY L.DESCRIPTION,
LS.DESCRIPTION,
C.CORPORATENO
|| E.EMPLOYEENO
|| AF.AFFILIATEMEMBERNO
|| M.MEMBERNO,
C.NAME || E.NAME || AF.NAME || M.NAME,
L.PRINTNO
UNION ALL
-- Guest Registration
SELECT L.DESCRIPTION LEDGERNAME,
LS.DESCRIPTION LEDGERSUBGROUPNAME,
C.CORPORATENO
|| E.EMPLOYEENO
|| AF.AFFILIATEMEMBERNO
|| M.MEMBERNO
AS ID,
C.NAME || E.NAME || AF.NAME || M.NAME AS NAME,
SUM(CASE
WHEN PB.EMPLOYEE_ID IS NULL
AND T.ISCREDITTRANSACTIONMODE = 1
THEN
PB.BILLAMOUNT
ELSE
0
END)
MEMBERDEBITAMOUNT,
L.PRINTNO
FROM GUESTREGISTRATION PB
INNER JOIN GUESTREGISTRATIONDETAIL PD
ON PB.GUESTREGISTRATION_ID = PD.GUESTREGISTRATION_ID
INNER JOIN TRANSACTIONTYPE TY
ON TY.TRANSACTIONTYPE_ID = PB.TRANSACTIONTYPE_ID
INNER JOIN TRANSACTIONMODE T
ON T.TRANSACTIONMODE_ID = PB.TRANSACTIONMODE_ID
INNER JOIN LEDGER L
ON L.LEDGER_ID = PD.LEDGER_ID
INNER JOIN LEDGERSUBGROUP LS
ON LS.LEDGERSUBGROUP_ID = L.LEDGERSUBGROUP_ID
LEFT JOIN CORPORATE C
ON C.CORPORATE_ID = PB.CORPORATE_ID
LEFT JOIN EMPLOYEE E
ON E.EMPLOYEE_ID = PB.EMPLOYEE_ID
LEFT JOIN AFFILIATEMEMBER AF
ON AF.AFFILIATEMEMBER_ID = PB.AFFILIATEMEMBER_ID
LEFT JOIN MEMBER M
ON M.MEMBER_ID = PB.MEMBER_ID
WHERE TY.ISDEBIT = 1 AND PB.FLAG = 0 AND T.ISROOMNO = 2
AND (P_TRANSACTIONMONTH IS NULL
OR P_TRANSACTIONMONTH =
TO_CHAR (PB.BILLDATE, 'fmMONTH-YYYY'))
AND (P_LEDGERID IS NULL
OR L.LEDGER_ID IN
( (SELECT COLUMN_VALUE
FROM TABLE(GET_ROWS_FROM_LIST1 (
P_LEDGERID,
GROUP BY L.DESCRIPTION,
LS.DESCRIPTION,
C.CORPORATENO
|| E.EMPLOYEENO
|| AF.AFFILIATEMEMBERNO
|| M.MEMBERNO,
C.NAME || E.NAME || AF.NAME || M.NAME,
L.PRINTNO)
ORDER BY PRINTNO;
END SP_GRCS;
I have even tried adding L.Ledger_ID in select statement. -
How to select a single day from month view
From my ipad on IOS7 I can not select a single day from the month view? From the old versions all I had to do was double click a single date even if it had multiple appointments in it to view it. Was this feature removed? Please help
It appears to me as though it has indeed been removed. You can tap and hold down on a day while in month view to create or view an event, but you cannot tap on the day to open the whole day's events.
-
Generating multiple rows from one physical row
I was wondering if anyone has done or knows how to generate multiple rows for one physical row. In my query "SELECT Cust_No, Amount from Balances" if the amount is > 99,999.99 I want 2 rows returned, one with an amount of 90,000.00 and the other with an amount of 9,999.99. I'm thinking I need to use a view or function to return a result set but I'm not sure how.
Thanks in advance,
Allen Davis
[email protected]James,
Well your right in that you need a function, but also 3 views to accomplish that. I just wrote up the sql below and tested it. Basically you want the first view to return all records less than your cap of 99,999, thoes that exceed that will always return as 90,000 (see example on record PK 774177177). The second view returns money that remains AFTER the cap (in your case 9,999). The second view though also has to excude the ones less than the CAP.
DATA and TABLE layout
1) Table is called T1, columns are PK : primary key value, and N2 : some number column holding the MONEY amount
2) data is below fromtable called t1 (10 records) ...
select pk,n2 from t1 order by pk
PK N2
117165529 100
274000876 200000
350682010 9999
737652242 90000
774177177 99999
1369893126 1000
1663704428 100000
1720465556 8888
1793125955 0
1972069382 1000000
Now see the records with money at 99,999 (just like in your example). You want 2 records, so the VIEWS now come into play. The view itself CALLS the function, this occurs when you select from the view. The function will either return 90,000 (your defined cap) or the remained after subtracting the money from 90,000. The 3 views are defined below (the FUNCTION which is shown after will have to be compiled first) ...
--[VIEWS START]
CREATE OR REPLACE VIEW VIEW1
(PK,SHOW_MONEY)
AS SELECT PK,FN_TRIM_MONEY(N2,1) FROM T1;
CREATE OR REPLACE VIEW VIEW2
(PK,SHOW_MONEY)
AS SELECT PK,FN_TRIM_MONEY(N2,2) FROM T1 WHERE N2 >= 99999;
CREATE OR REPLACE VIEW VIEW_ALL
(PK,SHOW_MONEY)
AS
SELECT * FROM VIEW1
UNION ALL
SELECT * FROM VIEW2;
--[VIEWS END]
OK now for the actual function ...
--[FUNCTION START]
CREATE OR REPLACE FUNCTION
FN_TRIM_MONEY
PI_MONEY NUMBER,
PI_VIEW_ID NUMBER
RETURN NUMBER AS
LS_TEMP VARCHAR2(2000);
LI_TEMP NUMBER;
LD_TEMP DATE;
LI_CON_MONEY_MAX CONSTANT NUMBER := 90000;
LS_RETURN VARCHAR2(2000);
BEGIN
IF (PI_MONEY > LI_CON_MONEY_MAX) THEN
IF PI_VIEW_ID = 1 THEN
LI_TEMP := LI_CON_MONEY_MAX;
ELSIF PI_VIEW_ID = 2 THEN
LI_TEMP := (PI_MONEY - LI_CON_MONEY_MAX);
END IF;
ELSE
LI_TEMP := PI_MONEY;
END IF;
IF LI_TEMP < 0 THEN
LI_TEMP := 0;
END IF;
LS_RETURN := LI_TEMP;
RETURN LS_RETURN;
END;
SHOW ERRORS;
--[FUNCTION END]
I compiled the function and views with no errors. This is what I get when I query the 3 views ...
--[VIEW 1]
PK SHOW_MONEY
117165529 100
274000876 90000
350682010 9999
737652242 90000
774177177 90000
1369893126 1000
1663704428 90000
1720465556 8888
1793125955 0
1972069382 90000
--[VIEW 2]
PK SHOW_MONEY
274000876 110000
774177177 9999
1663704428 10000
1972069382 910000
--[VIEW ALL]
PK SHOW_MONEY
117165529 100
274000876 90000
274000876 110000
350682010 9999
737652242 90000
774177177 90000
774177177 9999
1369893126 1000
1663704428 90000
1663704428 10000
1720465556 8888
1793125955 0
1972069382 90000
1972069382 910000
So notice the PK entry 774177177 listed twice, once with 90,000 and other with 9,999. Also notice we now have 14 records from the original 10, meaning 4 records qualified for the split (all data from VIEW 2).
This is why Oracle kicks ass, views and functions are very powerful when used together and can return pretty much anything.
Thanks,
Tyler D.
[email protected] -
SQL - Retriving Last 6 rows from Join of 2 Tables
Hi All
I want to retrive the last 6 rows from a query which has join of 2 tables
Thanks in adv.
JunuHi,
Check this.
SELECT e.empno, e.deptno, e.sal,e.rn
FROM (
SELECT ROWNUM rn, a.empno, b. deptno, a.sal,
( SELECT COUNT(1) FROM scott.emp c, scott.dept d
WHERE c.deptno = d.deptno ) max_rn
FROM scott.emp a, scott.dept b
WHERE a.deptno = b.deptno
) e
WHERE rn BETWEEN max_rn -6 AND max_rn
ORDER BY rn
Regards
K.Rajkumar -
Pick only one row from the repeated rows
Oracle 10g r2 (10.2.0.5)
I have a query/view, which returns the the reords as follows
set colsep ||
Name || Address || Zip
abc123 || Ln1 || 123456
bcd123 || Ln2 || NULL
bcd123 || Null || 45678
efg123 || Ln0 || 96345
efg123 || Ln0123 || Null
efg123 || adr || null
the result set I need from the above is
set colsep ||
Name || Address || Zip
abc123 || Ln1 || 123456
bcd123 || Ln2 || NULL
efg123 || Ln0 || 96345
As you see that the first record on each repeated row sets are required
Thanks,Hi,
Using the aggregate FIRST (or LAST) function like that, there's no guarantee that all of the output values on the same row will come from the same row in the original table. To do that, you can use the analytic ROW_NUMBER function, like this:
WITH got_r_num AS
SELECT name, address, zip, ...
, ROW_NUMBER () OVER ( PARTITION BY name
ORDER BY address
, zip
) AS r_num
FROM table_x
SELECT name, address, zip, ...
FROM got_r_num
WHERE r_num = 1
;This assumes the "first" row is the one with the first address (in alphabetic order), and, in the event of a tie, the one with the lowest zip (however "lowest" is defined for zip). You can specify any order you want in the analytic ORDER BY clause.
I hope that answers your question.
If not, what is your question? Use words other than those you've already used to describe what you want to do.
Explain exactly what "first" means in this problem.Point out where the query above (or the one posted by Claytonian, if that seems closer) is getting the wrong results, and explain how you'd get the right results in those places.
If necessary, post new sample data (either CREATE TABLE and INSERT statements, or a WITH clause, as Claytonian did) and the results you want from that data. -
Delete a Row from a Nested Data Table
Hi... Good day...
I have a dataTable nested within another DataTable.
I want to delete a Row from the nested DataTable on clicking a remove Button at the Last column of the Nested DataTable, Jus in the browser.
How to accomplish this using JavaScript?
Here is my Code Snippet..
<h:dataTable value="#{myListBean.rpts}" binding="#{myListBean.parent}" var="item" headerClass ="header" rowClasses = "whiteRow,grayRow" cellspacing="0" cellpadding="4" border = "0" id = "dataTable">
<h:column>
<h:graphicImage id="expand" value="static/images/plus.gif" onclick="showNested(this);" rendered="#{item.schedImgurl=='static/images/scheduled.gif'}"/>
<div id="#{item.rptId}">
<h:dataTable id="orderLines" binding="#{myListBean.child}" value="#{item.scheduleList}" var="schedItem" style="display: none;">
<h:column>
<h:outputText value="#{schedItem.scheduleID}" style="display:none;" />
<f:facet name="header" >
<h:outputText value="Scheduled Criteria"/>
</f:facet>
<h:outputText value="#{schedItem.scheduleCriteriaName}" />
<span onMouseOver="JavaScript:showScheduleTooltip(event,'#{schedItem.toolTipCriteraia}')" onMouseOut="JavaScript:hideTooltip()">...</span>
</h:column>
<h:column>
<f:facet name="header" >
<h:outputText value="Frequency"/>
</f:facet>
<h:outputText value="#{schedItem.scheduleFrequency}" />
</h:column>
<h:column>
<f:facet name="header" >
<h:outputText value="On"/>
</f:facet>
<h:outputText value="#{schedItem.scheduleStartDate}" />
</h:column>
<h:column>
<input type="button" value="Remove"onclick=" Remove();"/>
</h:column>
</h:dataTable>
</div>
</h:column>
</h:dataTable>Whatz that I need to do inside the Remove() JavaScript Function ?Ram_J2EE_JSF wrote:
How to accomplish this using JavaScript?Using Javascript? Well, you know, Javascript runs at the client side and intercepts on the HTML DOM tree only. The JSF code is completely irrelevant. Open your JSF page in your favourite webbrowser and view the generated HTML source. Finally just base your Javascript function on it. -
Want to add rows from database in custom table model
Hello all,
I have written custom table model which has single blank row intially.
Once user clicks on button, i want to add more rows in custom table model and display them in JTable.
I have created JTable object as shown below.
Jtable patientTable = new JTable( new DiagnosticTableModel());
My custom tabel model is as shown below.
import javax.swing.table.AbstractTableModel;
public class DiagnosticTableModel extends AbstractTableModel
private String[] columnNames = {
"Date",
"Diagnosis",
"Severity",
"Medications"};
private String[][] data = {
public int getColumnCount()
return columnNames.length;
public int getRowCount()
return data.length;
public String getColumnName(int col)
return columnNames[col];
public Class getColumnClass(int col)
return getValueAt(0, col).getClass();
public Object getValueAt(int row, int col)
return data[row][col];
public boolean isCellEditable(int row, int col)
return true;
public void setValueAt(Object value, int row, int col)
data[row][col] = value.toString();
fireTableCellUpdated(row, col);
}Thanx a lot in advance.I have written custom table model which has single blank row intially.Why did you write a custom TableModel? The DefaultTableModel will work fine and it has methods that allow you to dynamically add rows to the table.
-
Hi Folks,
I hope someone out there can help me out with this one. It has me stumped:
Basically we have an XML document stored in an XMLType which we need to process relationally.
I have the following cursor definition:
CURSOR c_section13h(cp_jsatfa_xml_id IN NUMBER) IS
SELECT
jx.JSATFA_ID
,to_number(jx.jsatfa_xml_id)
,extractvalue( value(t), '/Email ') as "EMAIL"
FROM jsatfa_xml jx
,table ( xmlsequence (extract (jx.xml_doc, '/document/Section13/Accommodation/Row/Email'))) t
WHERE jx.jsatfa_xml_id = cp_jsatfa_xml_id;This returns:
jx.jsatfa_id, jx.jsatfa_xml_id, Email1
jx.jsatfa_id, jx.jsatfa_xml_id, Email2
jx.jsatfa_id, jx.jsatfa_xml_id, Email3
jx.jsatfa_id, jx.jsatfa_xml_id, Email4
This in itself works. However I would like to pull out a second item (e.g. Telephone) from the xml_document in the form:
jx.jsatfa_id, jx.jsatfa_xml_id, Email1, Telephone1
jx.jsatfa_id, jx.jsatfa_xml_id, Email2, Telephone2
jx.jsatfa_id, jx.jsatfa_xml_id, Email3, Telephone3
jx.jsatfa_id, jx.jsatfa_xml_id, Email4, Telephone4
At present I have to use a second cursor to process the second entry. This is because is is not possible to have more than one table() definition in the from clause as Cartesian products result. I.E the following causes a cartesian:
CURSOR c_section13h(cp_jsatfa_xml_id IN NUMBER) IS
SELECT
jx.JSATFA_ID
,to_number(jx.jsatfa_xml_id)
,extractvalue( value(t), '/Email ') as "EMAIL"
,extractvalue( value(t1), '/Telephone') as "TELEPHONE"
FROM jsatfa_xml jx
,table ( xmlsequence (extract (jx.xml_doc, '/document/Section13/Accommodation/Row/Email'))) t
,table ( xmlsequence (extract (jx.xml_doc, '/document/Section13/Accommodation/Row/Telephone'))) t1
WHERE jx.jsatfa_xml_id = cp_jsatfa_xml_id;The specific XML data is tabular data (i.e. its square). Currently I am processing each column (e.g. email, telephone) with a separate cursors.
Ideally I'd like to be able to place the jsatfa_id and jsatfa_xml_id within the table( ) clause so that they can be joined without creating Cartesian products. These IDs are not in the xml.
Does anyone have any ideas
I hope this makes sense, if it doesn't please let me know.
- Kris
http://kristianjones.blogspot.com
Message was edited by:
Kris Jones
Message was edited by:
Kris JonesHere is one way to do that:
michaels> WITH jsatfa_xml AS
(SELECT 1 jsatfa_xml_id, XMLTYPE
<document>
<Section13>
<Accommodation>
<Row>
<TelephoneNumber>telnum</TelephoneNumber>
<TelephoneNumber>telnum2</TelephoneNumber>
<TelephoneNumber />
<TelephoneNumber />
<TelephoneNumber />
</Row>
<Row>
<Email>[email protected]</Email>
<Email />
<Email />
<Email />
<Email />
</Row>
<Row>
<Comments>no comment</Comments>
<Comments />
<Comments />
<Comments />
<Comments />
</Row>
</Accommodation>
<Row>
</Row>
<Row>
</Row>
</Section13>
</document>'
) xml_doc
FROM DUAL)
--- End Test XML
SELECT jsatfa_xml_id, email, phone
FROM jsatfa_xml t,
XMLTable('Email' PASSING EXTRACT(xml_doc,'/document/Section13/Accommodation/Row/Email')
COLUMNS POS FOR ORDINALITY,
EMAIL VARCHAR2(30) PATH 'node()'
) t2,
XMLTable('TelephoneNumber' PASSING EXTRACT(xml_doc,'/document/Section13/Accommodation/Row/TelephoneNumber')
COLUMNS POS FOR ORDINALITY,
PHONE VARCHAR2(30) PATH 'node()'
) t3
WHERE t2.pos = t3.pos
AND jsatfa_xml_id = 1
JSATFA_XML_ID EMAIL PHONE
1 [email protected] telnum
1 telnum2
1
1
1
5 rows selected. -
ADF 11g can not select and copy data from cell of readonly table in IE
hi,
In ADF 11g, when render view object as readonly table with Single RowsSelection, using IE browser can not select and copy data from the cell, but it work in firefox.
is it a bug?
Edited by: kent2066 on 2009-5-18 上午8:46Hi Timo,
Sorry forgot to mention versions.
We are using 11.1.1.7 and IE 9.
I tried in Google but could not get the solution.
Kindly let me know solution for this.
PavanKumar -
Display columns as rows from non-unique key table
Hi OTN/Users, I hope you can assist me
Given a table:
create table t (a varchar2(30), b int, c date );
with this data within:
insert into t values ( a1, 40, to_date( '01-Dec-2012'));
insert into t values ( a1, 50, to_date( '01-Dec-2012'));
insert into t values ( a1, 60, to_date( '01-Dec-2012'));
insert into t values ( b1, 10, to_date( '01-Dec-2012'));
insert into t values ( b1, 20, to_date( '01-Dec-2012'));
insert into t values ( b1, 30, to_date( '01-Dec-2012'));
insert into t values ( c1, 60, to_date( '01-Dec-2012'));
insert into t values ( c1, 70, to_date( '01-Dec-2012'));
insert into t values ( c1, 80, to_date( '01-Dec-2012'));
- I want to output the columns for each of 'a' as a single row e.g:
a1 40 50 60 01-Dec-2012
b1 10 20 30 01-Dec-2012
I've almost got it right, but the 'a' col repeats 4 times for each row of output:
a1 40
a1 50
a1 60
a1 01-Dec-2012
-I want to supress repeat output of the first column 'a' but display the rest in a straight line.
I've tried various things (Pivot, Rollup etc), but the fact i'm keying on a table with non unique rows has complicated things perhaps.
Any help would be much appreciatedHi,
Pre-11g this is how you would do it :[11.2] Pri @ Bepripd1 > !cat t.sql
with t(a,b,c) as (
select 'a1', 40, to_date( '01-Dec-2012') from dual union all
select 'a1', 50, to_date( '01-Dec-2012') from dual union all
select 'a1', 60, to_date( '01-Dec-2012') from dual union all
select 'b1', 10, to_date( '01-Dec-2012') from dual union all
select 'b1', 20, to_date( '01-Dec-2012') from dual union all
select 'b1', 30, to_date( '01-Dec-2012') from dual union all
select 'c1', 60, to_date( '01-Dec-2012') from dual union all
select 'c1', 70, to_date( '01-Dec-2012') from dual union all
select 'c1', 80, to_date( '01-Dec-2012') from dual
------ end of sample data ------
select
a
,max(decode(n,1,b,null)) q1
,max(decode(n,2,b,null)) q2
,max(decode(n,3,b,null)) q3
,c
from (
select a, b, c, row_number() over (partition by a order by b) n
from t
group by a,c
order by a,c
[11.2] Pri @ Bepripd1 > @t
A Q1 Q2 Q3 C
a1 40 50 60 01/12/2012 00:00:00
b1 10 20 30 01/12/2012 00:00:00
c1 60 70 80 01/12/2012 00:00:00------
From 11g onward, you would :[11.2] Pri @ Bepripd1 > !cat t.sql
with t(a,b,c) as (
select 'a1', 40, to_date( '01-Dec-2012') from dual union all
select 'a1', 50, to_date( '01-Dec-2012') from dual union all
select 'a1', 60, to_date( '01-Dec-2012') from dual union all
select 'b1', 10, to_date( '01-Dec-2012') from dual union all
select 'b1', 20, to_date( '01-Dec-2012') from dual union all
select 'b1', 30, to_date( '01-Dec-2012') from dual union all
select 'c1', 60, to_date( '01-Dec-2012') from dual union all
select 'c1', 70, to_date( '01-Dec-2012') from dual union all
select 'c1', 80, to_date( '01-Dec-2012') from dual
------ end of sample data ------
select a,q1,q2,q3,c
from (
select a, b, c, row_number() over (partition by a order by b) n
from t
pivot (
max(b)
for n in (
1 as q1
,2 as q2
,3 as q3
order by a,c
[11.2] Pri @ Bepripd1 > @t
A Q1 Q2 Q3 C
a1 40 50 60 01/12/2012 00:00:00
b1 10 20 30 01/12/2012 00:00:00
c1 60 70 80 01/12/2012 00:00:00Edited by: Nicosa on Nov 9, 2012 2:42 PM -
ERROR:-22905:ORA-22905: cannot access rows from a non-nested table item
Hi. I have some code running on oracle 9i that gives me above error.
Following are my type declarations.
drop type_obj_tea_icore_glr;
drop type_tbl_tea_icore_glr;
create or replace type type_obj_tea_icore_glr as object (
ns_comp_id_parent number,
ns_comp_id_child number,
serv_item_id number,
glr_display_order number,
exchange_carrier_circuit_id varchar2(53)
show err
create or replace type type_tbl_tea_icore_glr as table of type_obj_tea_icore_glr;
show err
I have a function in an oracle package tea_icore_pkg with following signature.
FUNCTION sortpvcdesign (
p_document_number serv_req_si.document_number%TYPE,
p_pvc_serv_item_id serv_item.serv_item_id%TYPE,
p_orig_port_serv_item_id serv_item.serv_item_id%TYPE
RETURN type_tbl_tea_icore_glr
If I run following from SQL prompt, it works fine.
SELECT * FROM TABLE (tea_icore_pkg.sortpvcdesign(255082,2782636,2723752) );
But when I use that within another procedure of the same packge, as follows:
FOR glr_rec IN
(SELECT *
FROM TABLE
(CAST
(sortpvcdesign (c_pvcs.order_nbr,
c_pvcs.pvc_serv_item_id,
c_pvcs.orig_port_serv_item_id
) AS type_tbl_tea_icore_glr
LOOP
At the runtime, I got the above error message ( as referred to in subject ). I took all of the suggestions on CAST without much success. The user/schema is only one schema here. I mean, no permissions issue. I granted all on above types to public.
Can someone help?Bil,
I tried both with CAST and without CAST with specifying the colums. The same error.
OR glr_rec IN
(SELECT ns_comp_id_parent, ns_comp_id_child, serv_item_id,
glr_display_order, exchange_carrier_circuit_id
FROM TABLE
(CAST
(sortpvcdesign (c_pvcs.order_nbr,
c_pvcs.pvc_serv_item_id,
c_pvcs.orig_port_serv_item_id
) AS type_tbl_tea_icore_glr
LOOP
Maybe you are looking for
-
Problem Install NetWeaver CE 7.1,SP1 , Java Trial
I had installed NetWeaver CE 7.1 SP1 J2EE with following error message: Jan 10, 2008 2:48:37 PM [Info]: handleStdout: c:/sapdb/programs/bin/x_server.exe update Jan 10, 2008 2:48:37 PM [Info]: handleStdout: 18433 ERROR: Could not open application even
-
When I try to open a PDF, I get an error: 130:11, which has to do with a licensing problem. I have re-downloaded and install Adobe Reader three times and a Creative Cloud customer. I want to be able to open the PDFs and print them. Help.
-
Bad link for Oracke 9i OLEDB Provider Readme file
The following link leads to what looks like a blank page: http://otn.oracle.com/software/tech/windows/ole_db/htdocs/readme9i.txt The link is on this page: http://otn.oracle.com/software/tech/windows/ole_db/content.html I'm using IE6
-
New ARB Issue: Button navigation and Declarative States
<[email protected]il.forums.adobe.com> Message-ID: <C6277898.7F37%[email protected]> Thread-Topic: New ARB Issue: Button navigation and Declarative States Thread-Index: AcnOqlv/oTWkTNjMukqDP18VFO76uA== Mime-version: 1.0 Content-type: multipart/alter
-
I think i have an escaping problem, could someone please help me out: <script> function deleteConfirm(ID, thema){ var theText = "" + thema; if( confirm("Weet u zeker dat u " + theText + " wilt verwijderen?")) { document.locati