ROWCOUNT IN THE TABLE
Hi All,
Let us assume, i have 10 tables in a schema "XYZ".
Now i would like to know the 10 tablenames along with the rowcount in the 10 tables.
like,
TABLENAME COUNT OF ROWS
TABLE A 150
TABLE B 1000
TABLE C 3000
TABLE D 20
please help me with the code.
Thanks,
Ravi.
You can also use like this.
DECLARE
c VARCHAR2(32767):=' ';
s sys_refcursor;
t VARCHAR2(100);
col VARCHAR2(100);
BEGIN
dbms_output.put_line('table_name count');
FOR x IN (SELECT DECODE(ROWNUM,1,NULL,' union ')||'select '''||table_name||''' Table_name, count(1) Count from '||table_name q FROM user_tables)
LOOP
c:=c||x.q;
END LOOP;
OPEN s FOR c;
LOOP
FETCH s INTO t,col;
EXIT WHEN s%NOTFOUND;
dbms_output.put_line(t||' '||col);
END LOOP;
END;
It has its limitations.
Similar Messages
-
Rowcount is zero , but the table displays data on the screen
Hi,
I have created an arraylist, which holds objects of a custom class. The custom class contains variables, that holds the data of each row.
I did binding between this arraylist and a table. On the UI, the table is displayed with the data present in the class variables.
But, when I use getrowCount(), it returns zero.
Probably because of this reason, the selected row data is null. (tableselectone component).
Any help is appreciated./**** PatientsHelper Class
private String firstName;
private String lastName;
private String patientId;
private String firstNameCol;
private String lastNameCol;
private String patientIdCol;
private String empType;
private String empTypeCol;
public void setFirstName(String firstName) {
this.firstName = firstName;
public String getFirstName() {
return firstName;
public void setLastName(String lastName) {
this.lastName = lastName;
public String getLastName() {
return lastName;
public void setPatientId(String patientId) {
this.patientId = patientId;
public String getPatientId() {
return patientId;
public void setFirstNameCol(String firstNameCol) {
this.firstNameCol = firstNameCol;
public String getFirstNameCol() {
return firstNameCol;
public void setLastNameCol(String lastNameCol) {
this.lastNameCol = lastNameCol;
public String getLastNameCol() {
return lastNameCol;
public void setPatientIdCol(String patientIdCol) {
this.patientIdCol = patientIdCol;
public String getPatientIdCol() {
return patientIdCol;
public void setEmpType(String empType) {
this.empType = empType;
public String getEmpType() {
return empType;
public void setEmpTypeCol(String empTypeCol) {
this.empTypeCol = empTypeCol;
public String getEmpTypeCol() {
return empTypeCol;
/***ColumnNames are also dynamically generated and are stored in columnNames (PatientHelper type) object**********/
PatientsHelper columnNames = new PatientsHelper();
columnNames.setFirstNameCol("First Name");
columnNames.setLastNameCol("Last Name");
/**********Code where the patientsHelper objects are kept in the arraylist **************/
ArrayList PatientRecords = new ArrayList();
private PatientsHelper patientAttributes;
for(int i=0;i<10;i++){
patientAttributes = new PatientsHelper();
patientAttributes.setFirstName("abcd");
patientAttributes.setLastName("efgh");
patientRecords.add(patientAttributes);
/*******ADF binding code ******************/
<af:table emptyText="No items were found"
value="#{backing_RegisterPatient.patientRecords}"
var="row" rows="25"
banding="row"
bandingInterval="1"
binding="#{backing_RegisterPatient.table2}"
id="table2"
rendered="true">
<af:column sortable="false"
headerText="#{backing_RegisterPatient.columnNames.patientIdCol}"
formatType="text"
binding="#{backing_RegisterPatient.column2}"
id="column2">
<af:outputText value="#{row.patientId}"
binding="#{backing_RegisterPatient.outputText2}"
id="outputText2"/>
</af:column>
<af:column sortable="false"
headerText="#{backing_RegisterPatient.columnNames.empTypeCol}"
formatType="text"
binding="#{backing_RegisterPatient.column3}"
id="column3">
<af:outputText value="#{row.empType}"
binding="#{backing_RegisterPatient.outputText3}"
id="outputText3"/>
</af:column>
<af:column sortable="false"
headerText="#{backing_RegisterPatient.columnNames.firstNameCol}"
formatType="text"
binding="#{backing_RegisterPatient.column4}"
id="column4">
<af:outputText value="#{row.firstName}"
binding="#{backing_RegisterPatient.outputText4}"
id="outputText4"/>
</af:column>
<af:column sortable="false"
headerText="#{backing_RegisterPatient.columnNames.lastNameCol}"
formatType="text"
binding="#{backing_RegisterPatient.column5}"
id="column5">
<af:outputText value="#{row.lastName}"
binding="#{backing_RegisterPatient.outputText5}"
id="outputText5"/>
</af:column>
<f:facet name="selection">
<af:tableSelectOne
binding="#{backing_RegisterPatient.tableSelectOne1}"
id="tableSelectOne1"
autoSubmit="false">
<af:commandButton text="View Documents"
binding="#{backing_RegisterPatient.viewDocsButton}"
id="viewDocsButton"
action="#{backing_RegisterPatient.viewDocuments}"/>
</af:tableSelectOne>
</f:facet>
</af:table> -
Add data to the table in the database with the use of add button
The name of my database is Socrates.
The name of the table in the database is Employees
I want to be able to add data to the database. i am presently working on the add button such that when i enter date into the textfield and press the add button it should automatically register in the table.
The error upon compilation is with this line of code
If (ae.getSource() == jbtnA)// it says that ";" is expected
Below is the entire code
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Mainpage extends JFrame implements ActionListener
JTextField jFirstName = new JTextField(15);
JTextField jSurname = new JTextField(12);
JTextField jCity = new JTextField(10);
JTextField jCountry = new JTextField(12);
JTextField jSSN = new JTextField(8);
JLabel jFirstLab = new JLabel("First Name");
JLabel jSurnameLab = new JLabel("Surname");
JLabel jCityLab = new JLabel("City");
JLabel jCountryLab = new JLabel("Country");
JLabel jSSNLab = new JLabel("Social Security Number (SSN)");
JButton jbtnA = new JButton ("Add");
JButton jbtnPrv = new JButton ("Previous");
JButton jbtnNt = new JButton ("Next");
JButton jbtnDl= new JButton ("Delete");
JButton jbtnSrch = new JButton ("Search");
public Mainpage (String title)
super (title);
Container cont = getContentPane();
JPanel pane1 = new JPanel();
JPanel pane2 = new JPanel();
JPanel pane3 = new JPanel();
pane1.setLayout (new GridLayout (0,1));
pane2.setLayout (new GridLayout(0,1));
pane3.setLayout (new FlowLayout());
pane1.add(jFirstLab);
pane1.add(jSurnameLab);
pane1.add(jCityLab);
pane1.add(jCountryLab);
pane1.add(jSSNLab);
pane2.add(jFirstName);
pane2.add(jSurname);
pane2.add(jCity);
pane2.add(jCountry);
pane2.add(jSSN);
pane3.add(jbtnA);
pane3.add(jbtnPrv);
pane3.add(jbtnNt);
pane3.add(jbtnDl);
pane3.add(jbtnSrch);
cont.add(pane1, BorderLayout.CENTER);
cont.add(pane2, BorderLayout.LINE_END);
cont.add(pane3, BorderLayout.SOUTH);
jFirstName.addActionListener(this);
jSurname.addActionListener(this);
jCity.addActionListener(this);
jCountry.addActionListener(this);
jSSN.addActionListener(this);
jbtnA.addActionListener(this);
jbtnPrv.addActionListener(this);
jbtnNt.addActionListener(this);
jbtnDl.addActionListener(this);
jbtnSrch.addActionListener(this);
validate();
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setResizable(false);
public void actionPerformed(ActionEvent ae)
If (ae.getSource() == jbtnA)
fst = jFirstName.getText();
srn = jSurname.getText();
cty = jCity.getText();
cnty = jCountry.getText();
int sn =
Interger.parseInt(jSSN.getText());
String ad = "Insert into Employees
(Firstname,Surname,City,Country,SSN)" +
"values('"fst"','"srn"','"cty"','"cnty"','"sn"')";
Statement stmt = con.createStatment();
int rowcount = stmt.executeUpdate(ad);
JOptionPane.showMessageDialog("Your
details have been registered");
Statement stmt = con.createStatment();
int rowcount = stmt.executeUpdate(ad);
public static void main (String args[])
Mainpage ObjFr = new Mainpage("Please fill this
registration form");
try
Class.forname("sun.jdbc.odbc.JdbcOdbcDriver");
String plato = "jdbc:odbc:socrates";
Connection con =
DriverManager.getConnection(plato);
catch(SQLException ce)
System.out.println(ce);
}i have restructured the code, but the following line of code is giving error:
String plato = jdbc:odbc:socrates;
the entire code is below:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.sql.*;
public class Mainpage extends JFrame implements ActionListener
JTextField jFirstName = new JTextField(15);
JTextField jSurname = new JTextField(12);
JTextField jCity = new JTextField(10);
JTextField jCountry = new JTextField(12);
JTextField jSSN = new JTextField(8);
JLabel jFirstLab = new JLabel("First Name");
JLabel jSurnameLab = new JLabel("Surname");
JLabel jCityLab = new JLabel("City");
JLabel jCountryLab = new JLabel("Country");
JLabel jSSNLab = new JLabel("Social Security Number (SSN)");
JButton jbtnA = new JButton ("Add");
JButton jbtnPrv = new JButton ("Previous");
JButton jbtnNt = new JButton ("Next");
JButton jbtnDl= new JButton ("Delete");
JButton jbtnSrch = new JButton ("Search");
Statement stmt;
String ad;
public Mainpage (String title)
super (title);
Container cont = getContentPane();
JPanel pane1 = new JPanel();
JPanel pane2 = new JPanel();
JPanel pane3 = new JPanel();
pane1.setLayout (new GridLayout (0,1));
pane2.setLayout (new GridLayout(0,1));
pane3.setLayout (new FlowLayout());
pane1.add(jFirstLab);
pane1.add(jSurnameLab);
pane1.add(jCityLab);
pane1.add(jCountryLab);
pane1.add(jSSNLab);
pane2.add(jFirstName);
pane2.add(jSurname);
pane2.add(jCity);
pane2.add(jCountry);
pane2.add(jSSN);
pane3.add(jbtnA);
pane3.add(jbtnPrv);
pane3.add(jbtnNt);
pane3.add(jbtnDl);
pane3.add(jbtnSrch);
cont.add(pane1, BorderLayout.CENTER);
cont.add(pane2, BorderLayout.LINE_END);
cont.add(pane3, BorderLayout.SOUTH);
jFirstName.addActionListener(this);
jSurname.addActionListener(this);
jCity.addActionListener(this);
jCountry.addActionListener(this);
jSSN.addActionListener(this);
jbtnA.addActionListener(this);
jbtnPrv.addActionListener(this);
jbtnNt.addActionListener(this);
jbtnDl.addActionListener(this);
jbtnSrch.addActionListener(this);
validate();
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setResizable(false);
try
Class.forname(sun.jdbc.odbc.JdbcOdbcDriver);
String plato = jdbc:odbc:socrates;
Connection con = DriverManager.getConnection(plato);
stmt = con.createStatment();
catch(SQLException ce)
System.out.println(ce);
catch(ClassNotFoundException ce)
System.out.println(ce);
public void actionPerformed(ActionEvent ae)
try
if(ae.getSource().equals(jbtnA))
fst = jFirstName.getText();
srn = jSurname.getText();
cty = jCity.getText();
cnty = jCountry.getText();
int sn = Interger.parseInt(jSSN.getText());
ad = "Insert into Employees
values('"+fst+"',"+srn+"','"+cty+"','"+cnty+"','"+sn+"')";
stmt.executeUpdate(ad);
JOptionPane.showMessageDialog(this, "Your details have been
registered");
catch(SQLException ce)
System.out.println(ce);
public static void main(String args[])
Mainpage ObjFr = new Mainpage("Please fill this registration form");
} -
How to write the table content of JSP to a file
Hi there,
i have a JSP which displays data in table format.
i need to copy the data of the table( columns with comma separated and rows with line breaks).
on Mouse click of an hyper link or Button i need to perform the above action.
as i found java script wont support writing files to hard drive, i expecting help from you guys
for the solution.
Thanks and regards
RLoveOpensource wrote:
Hi thanks for your reply
i am using struts
and
i am displaying the table using
<logic:iterate can you please tell me how to implement your method on my code
my complete code for generating the table is
<table id="tbl" border="1" cellspacing="0" cellpadding="0">
<tr>
<td><h4>LPCDealName</h4></td>
<td><h4>IntexDealName</h4></td>
</tr>
<logic:iterate id="rows" property="table" indexId="rowCount" name="LPCIntexActionForm">
<tr >
<logic:iterate id="row" indexId="colCount" name="rows" length="2">
<td><bean:write name="row" /></td>
</logic:iterate>
<td><a href="">Modify the Mapping</a></td>
</tr>
</logic:iterate>
</table>
<% File log = CreateLog(); %>
//this one for calling method
//this one for printing data in log file
<% p.println(LPCDealName);
p.println(IntexDealName); %> -
Update a column for every 2000 records in the table
The table has 50,000 records. I want to update the process_id every 2000 rows. For example, 1 for the 1st 2000 rows, 2 for the next 2000 rows, 3 for the next 2000 rows, and etc. Is there a quick way to do it?
Thanks muchhey <[email protected]>
Two ways of doing this...
First: PL/SQL
By declaring a cursor on the table and using the cursor%rowcount method to update your field..something like this...
Declare
Begin
For rno in MyCursor
Loop
update <tablename> set process_id = lv_pid where rowid = rno.rowid
If mod(MyCur%rowcount,2000) = 0 then
lv_pid = lv_pid + 1;
End If;
End Loop;
End
I am sorry if u already knew this :-) !!
Second: SQL
let u know once (if)i crack it :-( !!
Goodluck...
Vasudev -
The reference to the table, view or sequence is not allowed in this context
Hi,
I'm triying to execute the SP that I describe below and the OS give me an error:
CREATE OR REPLACE PROCEDURE DWARE.P_CSCV_AGR_MONTH_REVENUE
TBL_NAME VARCHAR2,
START_DATE DATE,
RESULT_ OUT NUMBER
) AS
BEGIN
DECLARE
v_tbl_name VARCHAR2(30);
v_start_date DATE;
v_result NUMBER := 0;
v_select_aux VARCHAR2(32767) := ' ';
v_temp_table VARCHAR2(30);
v_exists NUMBER;
BEGIN
v_tbl_name := TBL_NAME;
v_start_date := START_DATE;
v_temp_table := 'temp_' || v_tbl_name;
SELECT count(*) INTO v_exists FROM tab WHERE lower(tname) = lower(v_temp_table);
IF (v_exists = 1) THEN
v_select_aux := '
DROP TABLE ' || v_temp_table || ' CASCADE CONSTRAINTS PURGE
EXECUTE IMMEDIATE (v_select_aux);
COMMIT;
END IF;
v_select_aux := 'CREATE TABLE ' || v_temp_table || ' AS
SELECT ch.date_ month_revenue,
s.date_sub month_sub,
s.codpromoter,
u.OPERATOR,
SUM (ch.total) AS TOTAL_OK
FROM cscv_sub_charges_' || to_char(v_start_date, 'YYYY_MM')|| ' ch
INNER JOIN cscv_subs s
ON ch.id_sub = s.ID
INNER JOIN cscv_users u
ON s.id_user = u.ID
WHERE ch.STATUS = 0
GROUP BY ch.date_, s.date_sub, s.codpromoter, u.OPERATOR';
EXECUTE IMMEDIATE (v_select_aux);
COMMIT;
v_select_aux := '
INSERT INTO ' || v_tbl_name || ' (
month_revenue,
month_sub,
codpromoter,
operator,
TOTAL_0,
TOTAL_1,
TOTAL_2,
TOTAL_3,
TOTAL_4,
TOTAL_5,
TOTAL_6,
TOTAL_7,
TOTAL_8,
TOTAL_9,
TOTAL_10,
TOTAL_11
SELECT
month_revenue,
month_sub,
codpromoter,
operator,
TOTAL_0,
TOTAL_1,
TOTAL_2,
TOTAL_3,
TOTAL_4,
TOTAL_5,
TOTAL_6,
TOTAL_7,
TOTAL_8,
TOTAL_9,
TOTAL_10,
TOTAL_11
FROM
SELECT
month_revenue,
month_sub,
codpromoter,
operator,
sum(total_ok) total_0,
0 total_1,
0 total_2,
0 total_3,
0 total_4,
0 total_5,
0 total_6,
0 total_7,
0 total_8,
0 total_9,
0 total_10,
0 total_11
FROM '|| v_temp_table ||'
WHERE to_char(month_sub,''mm/yyyy'') = to_char(sysdate,''mm/yyyy'')
GROUP BY month_revenue,month_sub,codpromoter, operator
UNION ALL
SELECT
month_revenue,
month_sub,
codpromoter,
operator,
0,
sum(total_ok),
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
FROM '|| v_temp_table ||'
WHERE to_char(month_sub,''mm/yyyy'') = to_char((to_date(sysdate,''dd/mm/yy'') - INTERVAL ''1'' MONTH),''mm/yyyy'')
GROUP BY month_revenue,month_sub,codpromoter, operator
GROUP BY month_revenue,
month_sub,
codpromoter,
operator
EXECUTE IMMEDIATE (v_select_aux);
v_result := v_result + SQL%ROWCOUNT;
COMMIT;
v_select_aux := '
DROP TABLE ' || v_temp_table || ' CASCADE CONSTRAINTS PURGE
EXECUTE IMMEDIATE (v_select_aux);
COMMIT;
RESULT_ := v_result;
END;
END P_CSCV_AGR_MONTH_REVENUE;
BEGIN
DWARE.P_CSCV_AGR_MONTH_REVENUE(CSCV_AGR_MONTH_REVENUE,'01/01/2010');
END;
/and the output is:
Error at line 1
ORA-06550: líne 2, column 32:
PLS-00357: The reference to the table, view or sequence 'CSCV_AGR_MONTH_REVENUE' is not allowed in this context
ORA-06550: líne 2, column 1:
PL/SQL: Statement ignoredwhat could I do to resove the problem??
Thanks in advance...Hi,
Your procedure's signature is
CREATE OR REPLACE PROCEDURE DWARE.P_CSCV_AGR_MONTH_REVENUE
TBL_NAME VARCHAR2,
START_DATE DATE,
RESULT_ OUT NUMBER
) i.e. it is expecting two input parameters, TBL_NAME in VARCHAR2 format and the other START_DATE in DATE format. Also you need a variable with data type as NUMBER to hold the value of OUT parameter RESULT_
Now look at the way you are calling this procedure
BEGIN
DWARE.P_CSCV_AGR_MONTH_REVENUE(CSCV_AGR_MONTH_REVENUE,'01/01/2010');
END;
/first parameter has to be a VARCHAR2, so enclose CSCV_AGR_MONTH_REVENUE into single quotes.
second parameter should be a date, so use to_date() function.
Lastly declare a variable with data type as Number for holding value of out parameter RESULT_
Something like this :
declare
t_num number;
begin
a('CSCV_AGR_MONTH_REVENUE',to_date('01/01/2010','MM/DD/YYYY'),t_num);
dbms_output.put_line(t_num);
end;Vivek L -
How to compare two table and update the table.
I have table A where i have
Table A
select ssn,lname,fname,dob,cadcode,date... from table A
SQL> /
LNAME FNAME DOB SSN Status SOCKETNO
King Jack 11111877 000000000
Sue PAT 01021867 087543217
Smit john 08061897
Table B
SOCKETNO SSN LNAME FNAME DOB CADCODE
C873 000000000 Sue Pat 03021988 C111
C123 Kate Allen 01011999 V111
D009 123987765 King Jack Y123
K897 678987765 Mike Mellon 01111877 V178
I have to compare two table based on the below conditions and update table A With Status =Y and SOCKETNO from table B if a matching record exists in Table B.
condition If SSN from Table A to table B matches OR
if SSN IS NULL OR ALL zeros then compare with FNAME and LNAME and DOB
How can i achive this in a stored procedure?Hi,
You have to make PROCEDURE anyway, you can use CURSOR as per your requirement.
The sample code can look like this:
CREATE OR REPLACE PROCEDURE UPDATE_A (PARAMS.....) IS
CURSOR Cur_SOCKET IS SELECT B.SOCKETNO, B.FNAME, B.LNAME, B.SSN, B.DOB
FROM A, B
WHERE (NVL(A.SSN,0) != 0
AND NVL(B.SSN,0) != 0
AND A.SSN = B.SSN)
OR ( NVL(A.SSN,0) = 0
AND NVL(B.SSN,0) = 0
AND A.FNAME = B.FNAME
AND A.LNAME = B.LNAME
AND A.DOB = B.DOB)
FOR UPDATE OF A.SOCKETNO, A.STATUS;
Var_SOCKET Cur_SOCKET%ROWTYPE;
Old_Var_SOCKET Cur_SOCKET%ROWTYPE;
BEGIN
OPEN Cur_SOCKET ;
LOOP
FETCH Cur_SOCKET INTO Var_SOCKET ;
EXIT WHEN Cur_SOCKET%NOTFOUND ;
IF Cur_SOCKET%ROWCOUNT = 1 THEN
UPDATE A
SET STATUS = 'Y',
SOCKETNO = Var_SOCKET.SOCKETNO
WHERE CURRENTOF Cur_SOCKET ;
ELSIF (NVL(Old_Var_SOCKET.SSN,'X') = NVL(Var_SOCKET.SSN,'X') AND
NVL(Old_Var_SOCKET.FNAME,'X') = NVL(Var_SOCKET.FNAME,'X') AND
NVL(Old_Var_SOCKET.LNAME,'X') = NVL(Var_SOCKET.LNAME,'X') AND
NVL(Old_Var_SOCKET.DOB,'X') = NVL(Var_SOCKET.DOB,'X')) THEN
INSERT INTO A (....FIELDNAMES...) VALUES (.....VALUES....) ;
END IF ;
Old_Var_SOCKET.SSN = NVL(Var_SOCKET.SSN,'X') ;
Old_Var_SOCKET.FNAME = NVL(Var_SOCKET.FNAME,'X') ;
Old_Var_SOCKET.LNAME = NVL(Var_SOCKET.LNAME,'X') ;
Old_Var_SOCKET.DOB = NVL(Var_SOCKET.DOB,'X') ;
END LOOP;
CLOSE Cur_SOCKET;
END ;Regards,
Arpit -
Doing new JTable doesn't "update" the table on the screen
Hello
I am writing a program in java/swing which has several "layers" of panels. In the constructor method of the frame (using JInternalFrame) I create a new instance of JTable, place it inside JScrollPane which is then inside JSplitPane and then place that as the frame content pane.
In this program I run an sql command and the table is the result from that. Every time I execute a query it should update the table with the new results.
What is bothering me now is that when I execute a query I call new JTable() on the variable that held the JTable() object created on startup. When I create a new instance of JTable() and place it in this variable nothing seems to happen. What I need is some kind of "refresh" button. I tried to construct the whole window again but then the program started behaving odd so I gave up that method.
So, does anyone know how to do this?
The code behind this class can be found at http://www.heilabu.net/kari/Session.java (little commented, sorry :/)
You can see the table being constructed in the constructTable() method.
If I am a bit unclear I apologize, don't know all these technical words in english ;)
Thanks in advance!You really need to use a table model. The table you created is great and once that is in you shouldn't mess with it. Instead, when you create the table be sure to create it sort of like this:
DefaultTableMode dtm = new DefaultTableModel(<various constrcutors use the one suited for you>);
JTable table = new JTable(dtm);
To set different data on the table set it in the table model and then refresh the table, also through the table model. This works perfectly every time.
dtm.setDataVector(---) <- 2 methods, one for vectors and one for arrays...
dtm.fireTableChanged();
the folowing code shows exactly how to use it
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
public class RandomTable extends JFrame
GridBagLayout gbl = new GridBagLayout();
JPanel buttonPanel = new JPanel(gbl);
JTable table = null;
DefaultTableModel dtm = null;
JScrollPane tableSP = new JScrollPane();
JButton randomButton = new JButton("Randomize");
Object[] headers = { "a", "b", "c", "d", "e" };
public RandomTable()
this.getContentPane().setLayout(gbl);
randomButton.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent evt)
dtm.setDataVector(randomStrings(), headers);
this.dtm = new DefaultTableModel();
this.table = new JTable(dtm);
this.dtm.setDataVector(randomStrings(), headers);
this.tableSP.getViewport().add(table);
this.buttonPanel.add(randomButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
this.getContentPane().add(buttonPanel, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(3, 6, 6, 6), 0, 0));
this.getContentPane().add(tableSP, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 6, 3, 6), 0, 0));
this.setSize(300, 300);
public Object[][] randomStrings()
Random rand = new Random();
int rowCount = Math.abs(rand.nextInt())%50;
int colCount = headers.length;
Object[][] array = new Object[rowCount][colCount];
for(int row = 0; row < rowCount; row++)
for(int col = 0; col < colCount; col++)
array[row][col] = Long.toString(Math.abs(rand.nextLong())%100);
return array;
public static void main(String[] args)
RandomTable rt = new RandomTable();
rt.setVisible(true);
} -
Comparing rowcounts of two tables
I am trying to write a procedure that will compare the rowcounts in two tables. The situation is we have two sets of tables named 'Txxxx' and 'Hxxxx'. A table such as T153 should have the same number of rows as H153. I want to write a procedure that lists all the tables and their row counts in pairs. I am able to retrieve all the matched pairs but am stuck on how to derive the row count dynamically once I have retrieved the data. For a start I have:
declare
tab1 dba_tables.table_name%type;
tab2 dba_tables.table_name%type;
cursor tab_cursor is
select a.table_name, b.table_name from
dba_tables a, dba_tables b where
substr(a.table_name,1,1) = 'T'
and
substr(b.table_name,1,1) = 'H'
and
substr(a.table_name,2,3) = substr(b.table_name,2,3);
begin
open tab_cursor;
fetch tab_cursor into tab1, tab2;
while tab_cursor%found loop
dbms_output.put_line(tab1 || ' ' ||tab2);
fetch tab_cursor into tab1,tab2;
end loop;
close tab_cursor;
end;
/Try this.
Regards,
Bob.
declare
tab1 dba_tables.table_name%type;
tab2 dba_tables.table_name%type;
sqlcmd varchar2(2000);
t_cnt number;
h_cnt number;
cursor tab_cursor
is
select a.table_name,
b.table_name
from dba_tables a,
dba_tables b
where substr(a.table_name, 1, 1) = 'T'
and substr(b.table_name, 1, 1) = 'H';
and substr(a.table_name, 2, 3) = substr(b.table_name, 2, 3);
begin
open tab_cursor;
fetch tab_cursor
into tab1,
tab2;
while tab_cursor%found loop
dbms_output.put_line(tab1 ||
' ' ||
tab2);
sqlcmd := 'select count(1) from '||tab1;
EXECUTE IMMEDIATE sqlcmd INTO t_cnt;
dbms_output.put_line(tab1 ||' has count = '||t_cnt);
sqlcmd := 'select count(1) from '||tab2;
EXECUTE IMMEDIATE sqlcmd INTO h_cnt;
dbms_output.put_line(tab2 ||' has count = '||h_cnt);
if t_cnt != h_cnt then
--your magic goes here
null;
else
--more magic
null;
end if;
fetch tab_cursor
into tab1,
tab2;
end loop;
close tab_cursor;
end; -
ADF Desktop Integration : How to delete the table in Excel?
Hi,
I am using Jdev 11.1.1.3.0 and Excel 2007 for Oracle ADF DI, I had created an ADF table using pageDef file in the excel. Now I wanted to delete that table and use a different pageDef file.
I could not find a way to delete that table.
I deleted full row of tables and then I used different pageDef file and created a new adf table. But when I am running this version of excel, I am getting runtime exception and excel is getting corrupted.
My question how to delete the table not corrupting the Excel.
Thanks
PavanPavan,,
Welcome to OTN.
You can delete the table by selecting the top left column (of the table) and then select delete from the ADFdi tab.
Refer the documentation for more info.
http://docs.oracle.com/cd/E17904_01/web.1111/e10139/get_start_dev_tools.htm#ADFDI608
-Arun -
How can we remove the scroll bars from the table?
Hi,
I have a dynamic table. Currently the table appears with the scroll bars. But there is a requirement that the scroll bar should not appear and the table should stretch in the entire page. How can this be achieved.
Thanks in advance
NitaThanks Mohammad for the reply.
Was able to remove the scroll bars by using only the styleClass as AFStretchWidth. But there is a default partition in middle of the page still? Can i remove that too by any way. -
Error While Activating the Table
i have created a table name ZEMPLOY11 in ABAP Dictionary containing fields Client [NUM] Carieer [NUM] Firstname [CHAR] and Surname [CHAR] and save it . when i activated this table it shows and error Mesage "Errors occurred during activation". kindly help me out
i have created few more tables and faceing the same problem
Regards
AmmadHi Ammad,
Could you please paste the error what you are getting so that we can help you in a bettre way, I think most probably you haven't assign a key variable while creating the table, so in the screen where you have mentioned the fiels Client NUM Carieer NUM Firstname CHAR and Surname CHAR ,mark client and carrioer as key fields, then try to activate it after setting the technical setting of the table.
Hope now you will able to activate your tables.
Pooja -
Ora-00604,ora-01422 error while dropping the table
Hi gurus,
I am using Oracle 10g R2 on windows 2000 platform,while dropping the table the following error occured.
ORA-00604 : error occurred at recursive sql level 1.
ORA-01422: exact fetch returns more than requested number of rows.
Need urgent help.
Thanks in advanceIs there an AFTER EVENT trigger defined on this database? Can you check that?
Secondly, was this database migrated from earlier version? I remember having seen this problem on 9i (it was 9.2.0.1 or 9.2.0.2; I can't recall exactly). -
What are the tables will update while loading Master data ?
Hello Experts,
What are the tables will update while loading Master data ? And requesting you to provide more information about Master data loading and its related settings in the beginning of creation infoobjects.It depends upon the type of Master data u r loading....
In all the master data loadings, for every new value of master data an SID will be created in the SID table /BI*/S<INFOOBJECT NAME> irrespective of the type of master data.
But the exceptional tables that get updated depending on the type of master data are.....
If it is a time Independent master data then the /BI*/P<INFOOBJECT NAME> table gets updated with the loaded data.
If it is a time dependent master data then the /BI*/Q<INFOOBJECT NAME> table gets updated with the loaded data.
If the master data is of time Independent Navigational attributes then for every data load the SID table will get updated first and then the /BI*/X<INFOOBJECT NAME> table gets updated with the SID's created in the SID table (NOT WITH THE MASTER DATA).
If the master data is of time dependent navigational attributes then for every data load the SID table will get updated first and then the /BI*/Y<INFOOBJECT NAME> table gets updated with the SID's created in the SID table (NOT WITH THE MASTER DATA).
NOTE: As said above, For all the data in P, Q, T, X, Y tables the SID's will be created in the S table /BI*/S<INFOOBJECT NAME>
NOTE: Irrespective of the time dependency or Independency the VIEW /BI*/M<INFOOBJECT NAME> defined on the top of /BI*/P<INFOOBJECT NAME> & /BI*/Q<INFOOBJECT NAME> tables gives the view of entire master data.
NOTE: it is just a View and it is not a Table. So it will not have any physical storage of data.
All the above tables are for ATTRIBUTES
But when it comes to TEXTS, irrespective of the Time dependency or Independency, the /BI*/T<INFOOBJECT NAME> table gets updated (and of course the S table also).
Naming Convention: /BIC/*<InfoObject Name> or /BI0/*<InfoObject Name>
C = Customer Defined Characteristic
0 = Standard or SAP defined Characteristic
* = P, Q, T, X,Y, S (depending on the above said conditions)
Thanks & regards
Sasidhar -
HAI FRIENDS,
I HAVE DISPLAYED THE VALUES IN THE TABLE CONTROL
I HAVE DEFINED 'CHECK' FOR SELECTING THE FIELDS OF TABLE CONTROL
THE ISSUE STARTS HERE
WHEN I CHECK TOP FIELDS OF TABLE CONTROL
THEN SCROLLED VERTICALLY, THE TABLE CONTROL TO SELECT I.E CHECK THE
BOTTOM FIELDS OF TABLE CONTROL.
THE TOP FIELDS WATEVER CHECK WHERE CHECKS DISPAPEARS FOR TOP FIELDS .
BY THIS I UNABLE TO SELECT THE FIELDS OF TABLE.
PLZ HELP ME URGENTLY NEEDED.
MY MONDAY I NEEDEDYou use an internal table for values in table control..
One of the fields( very first field) in that itab is used for check - uncheck..
u have make it 'X' when u click any row...
I think this might be the problem in ur case.. when u scroll PAI starts... in that PAI check the value of check box for that particular field...
Regards
Prax
Maybe you are looking for
-
HELLLLLLLLLLPPPPPP!
-
Analytic Functions in PL/SQL
This procedure won't compile - the word PARTITION seems to be the problem - with this error... PLS-00103: Encountered the symbol "(" when expecting one of the following: , from The query in the cursor runs correctly as a stand-alone query. Can analyt
-
F.01 & KE80 Report not match Value
Hi Expert, We have made KE80 report as well F.01 FSV but while check both T.Code F.01 is giving Correct Information but Ke80 report giving Less amount then F.01. note : I have copied from KE5B as advice by Ravi Sankar Veena posted date 4th of June 20
-
Function sys_context('USERENV','CLIENT_IDENTIFIER') Returns ANONYMOUS
our application codes has custom fine grain access control that looks for certain id's such as the userid and machine identifier. some of the codes rely on this sys_context('USERENV','CLIENT_IDENTIFIER') function to compare it's return result to some
-
Hi, We have 2 Excise Groups for One Plant (Becaz they have two Excise Regn) .If the user forgor to Change proper excise group at the time of GR (MIGO) Then How to correct it he has to cancel the Migo and then hehas to post again with reqd excise grou