Problem in Customising JTable's Functionality
Problem Scenario :
We are facing a problem related to JTables. In our GUI, we have used JTables and the data model that we are using for the table is a bit complicated. Complicated in the sense that we want different values(multiple) in each cell of a particular column in the table and we want to use JComboBox at that particular cell. For achieving this we have set the values in the JComboBox in its renderer class. But to set the user selected value in the particular cell JComboBox we initialized a new JComboBox in the renderer class. With this the GUI is working fine but it has raised a problem that if we renderer the component another JComboBox appears in the same cell. The problem is obvious as we are initializing a new JComboBox in the renderer class, but to solve our purpose we don�t have another way.
With the kind of data model we are using is it possible to create a JTable with combo boxes in a particular cell having different option values in each cell?
Could someone suggest a solution for this problem?
Regards
Prajkta Bonde
[email protected]
I have done it around 4 years back. Add filled JComboBox as table data.
Attached sample code should help
// Imports
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
class SimpleTableExample
extends JFrame
// Instance attributes used in this example
private JPanel topPanel;
private JTable table;
private JScrollPane scrollPane;
// Constructor of main frame
public SimpleTableExample()
// Set the frame characteristics
setTitle( "Simple Table Application" );
setSize( 300, 200 );
setBackground( Color.gray );
// Create a panel to hold all other components
topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
getContentPane().add( topPanel );
// Create columns names
String columnNames[] = { "Column 1", "Column 2", "Column 3" };
Object dataValues[][] = new Object[10][3];
for(int row=0;row<dataValues.length;row++) {
for(int col=0;col<dataValues[row].length;col++){
JComboBox tempBox = new JComboBox();
for(int data=0;data<10;data++){
tempBox.addItem("Row "+row+" Column "+col+" Data "+data);
dataValues[row][col]=tempBox;
// Create a new table instance
table = new JTable( dataValues, columnNames );
comboBoxColumn(table.getColumnModel().getColumn(0));
comboBoxColumn(table.getColumnModel().getColumn(1));
comboBoxColumn(table.getColumnModel().getColumn(2));
// Add the table to a scrolling pane
scrollPane = new JScrollPane( table );
topPanel.add( scrollPane, BorderLayout.CENTER );
public void comboBoxColumn(TableColumn comboBoxCol) {
comboBoxCol.setCellEditor(new TableComponentEditor());
comboBoxCol.setCellRenderer(new TableComponentRenderer());
//Set up tool tip for the sport column header.
TableCellRenderer headerRenderer = comboBoxCol.getHeaderRenderer();
if (headerRenderer instanceof DefaultTableCellRenderer) {
((DefaultTableCellRenderer)headerRenderer).setToolTipText("Click the sport to see a list of service stations");
} //end of method
class TableComponentEditor extends DefaultCellEditor {
* Constructor
* @param none
TableComponentEditor() {
super(new JComboBox());
* Called when table Cell is clicked
* @param table
* @param value - Object associated with the particular column for which it is called
* @param isSelected -whether the particular cell is selected
* @param row - The row to which cell belongs
* @param column - The Column To which Cell Belongs
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
cbo = (JComboBox)value;
return cbo;
* getCellEditorValue
* @return Object
public Object getCellEditorValue() {
return cbo;
/***************CLASS VARIABLES***********************/
private JComboBox cbo = null;
class TableComponentRenderer implements TableCellRenderer {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
return (JComboBox)value;
// Main entry point for this example
public static void main( String args[] )
// Create an instance of the test application
SimpleTableExample mainFrame = new SimpleTableExample();
mainFrame.setVisible( true );
}
Similar Messages
-
Hello folks,
i got two problems with a JTable.
1. how do I change the size of a table header???
2. I know that it is possible to set different column-sizes. The problem in my table is that I don't know how long some cells are. In this case, I want to to get the biggest cell of one column and set its size as the default size of that specific column.
Is that possilbe?
Hopefully you can help me out,
thank youA JTableHeader is just another Component, so you ought to be able to set its size like you would
any other component; however, since its function is to act as a header for a table, it might constrain
itself to fit the table.
In order to size the column to fit the largest cell, for each row, go through each column and get the
renderer component for that column (which configures the component for rendering) and get the width
of that component. If that's bigger than the column's current width, set its width and preferred width.
You'll also want to check the renderer component width for the header to make sure the header doesn't
get truncated if the column doesn't have a cell whose value is longer than the header.
: jay -
Problem with dynamic LOV and function
Hello all!
I'm having a problem with a dynamic lov in APEX 3.0.1.00.08. Hope you can help me!
I have Report and Form application. On the Form page i have a Page Item (Popup Key LOV (Displays description, returns key value)).
When i submit the sql code in the 'List of vaules defention' box. I get the following message;
1 error has occurred
LOV query is invalid, a display and a return value are needed, the column names need to be different. If your query contains an in-line query, the first FROM clause in the SQL statement must not belong to the in-line query.
When i excecute the code below in TOAD or in the SQL Workshop it returns the values i want to see. But somehow APEX doesn't like the sql....
SELECT REC_OMSCHRIJVING d, REC_DNS_ID r FROM
TABLE(CAST(return_dns_lov_fn(:P2_DNS_ID) AS dns_table_type)) order by 1
returns_dns_lov_fn is a function, code is below;
CREATE OR REPLACE FUNCTION DRSSYS.return_dns_lov_fn (p2_dns_id number)
RETURN dns_table_type
AS
v_data dns_table_type := dns_table_type ();
BEGIN
IF p2_dns_id = 2
THEN
FOR c IN (SELECT dns_id dns, omschrijving oms
FROM d_status dst
WHERE dst.dns_id IN (8, 10))
LOOP
v_data.EXTEND;
v_data (v_data.COUNT) := dns_rectype (c.dns, c.oms);
END LOOP;
RETURN v_data;
END IF;
END;
and the types;
CREATE OR REPLACE TYPE DRSSYS.dns_rectype AS OBJECT (rec_dns_id NUMBER, rec_omschrijving VARCHAR2(255));
CREATE OR REPLACE TYPE DRSSYS.dns_table_type AS TABLE OF dns_rectype;
I tried some things i found on this forum, but they didn't work as well;
SELECT REC_OMSCHRIJVING display_value, REC_DNS_ID result_display FROM
TABLE(CAST(return_dns_lov_fn(:P2_DNS_ID) AS dns_table_type)) order by 1
SELECT REC_OMSCHRIJVING display_value d, REC_DNS_ID result_display r FROM
TABLE(CAST(return_dns_lov_fn(:P2_DNS_ID) AS dns_table_type)) order by 1
SELECT a.REC_OMSCHRIJVING display_value, a.REC_DNS_ID result_display FROM
TABLE(CAST(return_dns_lov_fn(:P2_DNS_ID) AS dns_table_type)) a order by 1
Edited by: rajan.arkenbout on 8-mei-2009 14:41
Edited by: rajan.arkenbout on 8-mei-2009 14:51I just had the same problem when I used a function in a where clause.
I have a function that checks if the current user has acces or not (returning varchar 'Y' or 'N').
In where clause I have this:
where myFunction(:user, somePK) = 'Y'
It seems that when APEX checked if my query was valid, my function triggered and exception.
As Varad pointed out, check for exception that could be triggered by a null 'p2_dns_id'
Hope that helped you out.
Max -
Problem with tpcall and tpgetrply functions
Hi,
I have a problem with tpcall() and tpgetrply() functions.
In this example (invoke tpcall()):
FBFR32 *buf;
FLDLEN32 buflen;
buf = a_buffer.getBuffer(); /* getBuffer() returns FBFR32* */
buflen = a_buffer.getLongitud();
/* at this point: buf == a_buffer.getBuffer() */
if (tpcall(a_contenedor.getServname(),
(char*)a_contenedor.getBufferPeticion()->getBuffer(),
a_contenedor.getBufferPeticion()->getLongitud(),
(char**)&buf,
(long*)&buflen,
0) == -1)
if (tperrno != TPESVCFAIL)
LANZAR_EXCEPCION(CADENA_WHAT_SB,
"Error en funcion Execute(), llamada tpcall()",
tpstrerror(tperrno))
/* at this point: buf != a_buffer.getBuffer() */
tpcall() function change the memory address of buf. What is the problem? Is wrong my code? Is a problem with tuxedo version?
My tuxedo version is:
tmadmin -vINFO: BEA Tuxedo, Version 8.0, 32-bit, Patch Level 306
INFO: Serial #: 650522264137-773290431251, Expiration NONE, Maxusers 150
INFO: Licensed to: Telefonica Moviles Espa?a, S.A.
INFO: 56-bit Encryption Package
Thanks,
ANTONIO.There's nothing wrong with your code or tuxedo. tpcall (and tpgetrply) can change the address of the return buffer if it needs to allocate more memory to hold the data. This is the reason why you pass a pointer to the buffer as the output buffer parameter to tpcall and tpreturn. Everything is working as expected.
-
Hi all,
I have a problem with printing JTable.
My application has a submit button,JTable and Print Button.
As I click on the Submit button, the data is retrieved from the Database(MS Access) and displayed on the JTable.
Now when I click on the Print button, the printer properties dialog box is displayed. But when I click on the print button in the dialog box, nothing is printed on the paper.
I checked the printers and faxes in the control panel, It showed Java printing under the Document name and Printing under the Status. It is displayed for sometime and then disappeared after some time. But nothing is printed on the paper(not even the blank paper).
I tried a lot but couldn't understand the problem.
I have used the following files:
PrintJTable.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import java.awt.geom.*;
import java.awt.Dimension;
import java.applet.*;
import java.sql.*;
import java.util.*;
import java.net.*;
import java.lang.*;
import javax.swing.table.*;
import javax.swing.event.*;
import javax.swing.border.*;
class PrintJTable implements ActionListener,Printable
Connection connect;
ResultSet rs;
JTable table;
JScrollPane tableAggregate;
DisplayTable displayTable;
JButton print,submitButton;
public PrintJTable()
JFrame frame = new JFrame("Table");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}});
connect();
displayTable= new DisplayTable();
JButton submitButton= new JButton("SUBMIT");
submitButton.addActionListener(this);
JButton printButton= new JButton("PRINT!");
// for faster printing turn double buffering off
RepaintManager.currentManager( frame).setDoubleBufferingEnabled(false);
printButton.addActionListener( new ActionListener(){
public void actionPerformed(ActionEvent evt) {
PrinterJob pj=PrinterJob.getPrinterJob();
pj.setPrintable(PrintJTable.this);
pj.printDialog();
try{
pj.print();
}catch (Exception PrintException) {}
tableAggregate = createTable();
tableAggregate.setBorder(new BevelBorder(BevelBorder.LOWERED));
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(submitButton,BorderLayout.NORTH);
frame.getContentPane().add(tableAggregate,BorderLayout.CENTER);
frame.getContentPane().add(printButton,BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
} // end of constructor
public void connect()
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
System.out.println("Opening db connection");
connect = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/db1.mdb","","");
catch (ClassNotFoundException ex) {
System.err.println("Cannot find the database driver classes.");
System.err.println(ex);
catch (SQLException ex) {
System.err.println("Cannot connect to this database.");
System.err.println(ex);
public JScrollPane createTable() {
displayTable= new DisplayTable();
JTable table = new JTable(displayTable);
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.getTableHeader().setReorderingAllowed(false);
JScrollPane scrollpane = new JScrollPane(table,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
return scrollpane;
} // end of createTable()
public void actionPerformed(ActionEvent ie)
try
Statement statement6=connect.createStatement();
ResultSet rs6=statement6.executeQuery("select * from benf_details");
displayTable.executeQuery(rs6);
statement6.close();
catch(SQLException sqle)
JOptionPane.showMessageDialog(null,"error2"+sqle);
}// end of actionPerformed
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.black);
int fontHeight=g2.getFontMetrics().getHeight();
int fontDesent=g2.getFontMetrics().getDescent();
double pageHeight = pageFormat.getImageableHeight()-fontHeight; //leave room for page number
double pageWidth = pageFormat.getImageableWidth();
System.out.println("page width = " + pageWidth );
double tableWidth = (double) table.getColumnModel().getTotalColumnWidth();
System.out.println("table width = " + tableWidth );
double scale = 1;
if (tableWidth >= pageWidth) {
scale = pageWidth / tableWidth;
System.out.println("scale = " + scale );
double headerHeightOnPage = table.getTableHeader().getHeight() * scale;
double tableWidthOnPage = tableWidth * scale;
double oneRowHeight = (table.getRowHeight() + table.getRowMargin()) * scale;
int numRowsOnAPage = (int)((pageHeight - headerHeightOnPage) / oneRowHeight);
double pageHeightForTable = oneRowHeight * numRowsOnAPage;
int totalNumPages = (int)Math.ceil(((double)table.getRowCount())/numRowsOnAPage);
if(pageIndex >= totalNumPages) {
return NO_SUCH_PAGE;
g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
g2.drawString("Page: "+ (pageIndex + 1),(int)pageWidth / 2 - 35,
(int)( pageHeight + fontHeight - fontDesent ));//bottom center
g2.translate( 0f, headerHeightOnPage );
g2.translate( 0f, -pageIndex * pageHeightForTable );
//If this piece of the table is smaller than the size available,
//clip to the appropriate bounds.
if (pageIndex + 1 == totalNumPages) {
int lastRowPrinted = numRowsOnAPage * pageIndex;
int numRowsLeft = table.getRowCount() - lastRowPrinted;
g2.setClip(0, (int)(pageHeightForTable * pageIndex),
(int) Math.ceil(tableWidthOnPage),
(int) Math.ceil(oneRowHeight * numRowsLeft));
//else clip to the entire area available.
else{
g2.setClip(0, (int)(pageHeightForTable * pageIndex),
(int) Math.ceil(tableWidthOnPage),
(int) Math.ceil(pageHeightForTable));
g2.scale(scale,scale);
table.paint(g2);
g2.scale(1/scale,1/scale);
g2.translate( 0f, pageIndex * pageHeightForTable);
g2.translate( 0f, -headerHeightOnPage);
g2.setClip(0, 0,(int) Math.ceil(tableWidthOnPage), (int)Math.ceil(headerHeightOnPage));
g2.scale(scale,scale);
table.getTableHeader().paint(g2);//paint header at top
return Printable.PAGE_EXISTS;
} // end of print()
public static void main(String[] args) {
new PrintJTable();
}// end of PrintJTable
DisplayTable.java
import java.util.Vector;
import java.sql.*;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.event.TableModelEvent;
public class DisplayTable extends AbstractTableModel {
Connection connection;
Statement statement;
ResultSet resultSet;
String[] columnNames = {};
Vector rows = new Vector();
ResultSetMetaData metaData;
String db_uname,db_passwd;
public DisplayTable() {
public void executeQuery(ResultSet resultSet) {
try {
metaData = resultSet.getMetaData();
int numberOfColumns = metaData.getColumnCount();
columnNames = new String[numberOfColumns];
// Get the column names and cache them.
// Then we can close the connection.
for(int column = 0; column < numberOfColumns; column++) {
columnNames[column] = metaData.getColumnLabel(column+1);
// Get all rows.
rows = new Vector();
while (resultSet.next()) {
Vector newRow = new Vector();
for (int i = 1; i <= getColumnCount(); i++) {
newRow.addElement(resultSet.getObject(i));
rows.addElement(newRow);
// close(); Need to copy the metaData, bug in jdbc:odbc driver.
fireTableChanged(null); // Tell the listeners a new table has arrived.
catch (SQLException ex) {
System.err.println(ex);
public void close() throws SQLException {
System.out.println("Closing db connection");
resultSet.close();
statement.close();
connection.close();
protected void finalize() throws Throwable {
close();
super.finalize();
// Implementation of the TableModel Interface
// MetaData
public String getColumnName(int column) {
if (columnNames[column] != null) {
return columnNames[column];
} else {
return "";
public Class getColumnClass(int column) {
int type;
try {
type = metaData.getColumnType(column+1);
catch (SQLException e) {
return super.getColumnClass(column);
switch(type) {
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGVARCHAR:
return String.class;
case Types.BIT:
return Boolean.class;
case Types.TINYINT:
case Types.SMALLINT:
case Types.INTEGER:
return Integer.class;
case Types.BIGINT:
return Long.class;
case Types.FLOAT:
case Types.DOUBLE:
return Double.class;
case Types.DATE:
return java.sql.Date.class;
default:
return Object.class;
// to make the cells editable
public boolean isCellEditable(int row, int column) {
try {
return metaData.isWritable(column+1);
catch (SQLException e) {
return false;
public int getColumnCount() {
return columnNames.length;
// Data methods
public int getRowCount() {
return rows.size();
public Object getValueAt(int aRow, int aColumn) {
Vector row = (Vector)rows.elementAt(aRow);
return row.elementAt(aColumn);
public String dbRepresentation(int column, Object value) {
int type;
if (value == null) {
return "null";
try {
type = metaData.getColumnType(column+1);
catch (SQLException e) {
return value.toString();
switch(type) {
case Types.INTEGER:
case Types.DOUBLE:
case Types.FLOAT:
return value.toString();
case Types.BIT:
return ((Boolean)value).booleanValue() ? "1" : "0";
case Types.DATE:
return value.toString(); // This will need some conversion.
default:
return "\""+value.toString()+"\"";
public void setValueAt(Object value, int row, int column) {
try {
String tableName = metaData.getTableName(column+1);
// Some of the drivers seem buggy, tableName should not be null.
if (tableName == null) {
System.out.println("Table name returned null.");
String columnName = getColumnName(column);
String query =
"update "+tableName+
" set "+columnName+" = "+dbRepresentation(column, value)+
" where ";
// We don't have a model of the schema so we don't know the
// primary keys or which columns to lock on. To demonstrate
// that editing is possible, we'll just lock on everything.
for(int col = 0; col<getColumnCount(); col++) {
String colName = getColumnName(col);
if (colName.equals("")) {
continue;
if (col != 0) {
query = query + " and ";
query = query + colName +" = "+
dbRepresentation(col, getValueAt(row, col));
System.out.println(query);
System.out.println("Not sending update to database");
// statement.executeQuery(query);
catch (SQLException e) {
// e.printStackTrace();
System.err.println("Update failed");
Vector dataRow = (Vector)rows.elementAt(row);
dataRow.setElementAt(value, column);
}Java 1.5 incorporates a very simple way to print from a JTable. I am using a mysql DB but it is the same concept. Review my code and let me know if you have any questions.
package emsmain;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.sql.*;
import java.text.MessageFormat;
import java.util.*;
import javax.print.*;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.swing.*;
import javax.swing.JTable;
import javax.swing.table.*;
import java.awt.print.*;
public class TableFromDatabase extends JFrame implements ActionListener{
JButton jbtprint = new JButton("Print Report");
JTable Reporttable;
Connection conn = Connect_Database.getConnection();
public TableFromDatabase()
Vector columnNames = new Vector();
Vector data = new Vector();
try{
String query = null;
Statement ps = null;
ResultSet rs = null;
//Class Master List
if (Report_Menu.jrbMaster_list.isSelected()){
query =("Select * from students") ;
//Classes taken by student
if (Report_Menu.jrbClass_taken.isSelected()){
String taken = Report_Menu.jtfStudent.getText();
query = ("select program.course_num, course_name, course_start_date, course_stat_desc from registration, program where student_id = '"+taken+"' and program.course_num = registration.course_num");
//Birthday report
if (Report_Menu.jrbBirthday.isSelected()){
String birthday = (String) Report_Menu.jcb_birthday.getSelectedItem();
query = ("SELECT student_id, fname, lname, address, city, state_name, zipcode, dob FROM students where substring(dob, 6,2) = '"+birthday+"'");
//Course Catologue
if (Report_Menu.jrbCourseCatologue.isSelected()){
String course = (String) Report_Menu.jcbChooseCourse.getSelectedItem();
query = ("select course_name, course_length, course_cost, course_credits from course where course_name = '"+course+"'");
//Certification expiration report
if (Report_Menu.jrbExpiration.isSelected()){
String month = (String) Report_Menu.jcbMonth.getSelectedItem();
String year = (String) Report_Menu.jcbYear.getSelectedItem();
query = ("SELECT FNAME, LNAME FROM STUDENTS, REGISTRATION WHERE substring(expiration_date, 6,2) = '"+month+"' and substring(expiration_date, 1,4) = '"+year+"' and registration.student_id = students.student_id") ;
//Class Roster
if (Report_Menu.jrbRoster.isSelected()){
String c_number = Report_Menu.jtfClassNumber.getText();
query = ("Select course_name, course_start_date, fname, lname from program, registration, students where program.course_num = '"+c_number+"' and registration.student_id = students.student_id;");
//Squad list and counts
if (Report_Menu.jrbSquadCount.isSelected()){
query = ("SELECT Squad_Name, count(student_id) from students group by Squad_Name");
//Student List
if (Report_Menu.jrbStudent_list.isSelected()){
String Choose_month = (String) Report_Menu.jcbcourse_month.getSelectedItem();
String Choose_Course = (String) Report_Menu.jcbcourse_name.getSelectedItem();
query = ("select count(student_id) from (registration, program) where program .course_name = '"+Choose_Course+"' and substring(course_start_date, 6,2) = '"+Choose_month+"'and registration.course_num = program.course_num;");
ps = conn.createStatement();
//Run Selected Report
ps.execute(query);
rs = ps.executeQuery(query);
ResultSetMetaData md = rs.getMetaData();
int columns = md.getColumnCount();
// Get column names
for (int i = 1; i <= columns; i++)
columnNames.addElement( md.getColumnName(i) );
// Get row data
while (rs.next())
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++)
row.addElement( rs.getObject(i) );
//add row data to JTable
data.addElement( row );
rs.close();
ps.close();
catch(Exception e)
JOptionPane.showMessageDialog(null,e.getMessage());
// Create Jtable with database data
Container c = getContentPane();
c.setLayout(new BorderLayout());
Reporttable = new JTable(data, columnNames);
JScrollPane scrollPane = new JScrollPane( Reporttable );
c.add( scrollPane );
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
buttonPanel.add(jbtprint);
c.add(buttonPanel,BorderLayout.SOUTH);
jbtprint.addActionListener(this);
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("Print Report")){
PrintForm();
public void PrintForm(){
try {
String name = null;
// Will display correct heading for print job
if (Report_Menu.jrbMaster_list.isSelected()){
name = "Master List";
if (Report_Menu.jrbBirthday.isSelected()){
name = "Birthday List";
if (Report_Menu.jrbClass_taken.isSelected()){
name = "Classes taken by Student";
if (Report_Menu.jrbCourseCatologue.isSelected()){
name = "Course Catalogue";
if (Report_Menu.jrbExpiration.isSelected()){
name = "Certification Expiration Report";
if (Report_Menu.jrbRoster.isSelected()){
name = "Class Roster";
if (Report_Menu.jrbSquadCount.isSelected()){
name = "Squad list with Student Counts";
if (Report_Menu.jrbStudent_list.isSelected()){
name = "Student count by Course";
// fetch the printable
Printable printable = Reporttable.getPrintable(JTable.PrintMode.FIT_WIDTH,
new MessageFormat(name),
new MessageFormat("Page - {0}"));
// fetch a PrinterJob
PrinterJob job = PrinterJob.getPrinterJob();
// set the Printable on the PrinterJob
job.setPrintable(printable);
// create an attribute set to store attributes from the print dialog
PrintRequestAttributeSet attr = new HashPrintRequestAttributeSet();
// display a print dialog and record whether or not the user cancels it
boolean printAccepted = job.printDialog(attr);
// if the user didn't cancel the dialog
if (printAccepted) {
try {
// do the printing (may need to handle PrinterException)
job.print(attr);
} catch (PrinterException ex) {
ex.printStackTrace();
} finally {
// restore the original table state here (for example, restore selection)
} -
Problem with active noise cancellation function : ...
My nokia 6720 have problem with active noise cancellation function. It seem not working because it also have noise when this function is active. So, I try to disable this function and found that the noise is reduce (but still not clear). How do I correct this problem?
Thanks.
P.S. Firmware version is 012.008"I must must achive a segnificant attenuation of the noise in a closed volume using some NI devices ..."
At first glance I would say "probably can be done using an FPGA as a target" since the FPGA can close a very fast loop.
But to do that with a microphone input on a PC running Windows...
I suspect that would be an exercise in futility.
Anyone out there been able to turn around a microphone input fast enough to something like this?
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
Problems using the reset password function on mac osx server.
Hey ,
Having problems with the reset password functions on the OSX server. When I try to do through the command line it asks for the old password of the user. So how do I fix the problem? Do I have to log in onto the ldap server as the admin and reset from there or is there an easy fix to make the reset password function work. When I try the reset password function the server is not taking the input when I click on change password. So any helpful suggestions are welcome. Verson OSX lion 10.7.5
Thanks in Advance,Excuse me for misunderstanding your post. You explicitly stated in your post
ashdatla wrote:
through the command line
and wrote that it asks for the old password. Server.app is not accessed through the command line, and it does not ask for the old password of the user.
You might like to try Workgroup Manager instead. -
Problem in creation of partner function creation.
Hi all,
During customer Master upload using LSMW direct method, Iam getting this problem.
while creating Sales view using XD01, three partner function VE (Sales Representative), SH (Ship-to party), ZI (Front Office) are getting displayed in the last tab of sales view creation.
Because of some customizing,value for SH is getting populated automatically. But the values for VE & SH are not getting populated from the flat file.
But the values are present in the respective field (KTONR) and able to see in the display convert data.
If I enter the manual value during runtime in LSMW, it accepts the value. Since it involves huge amount of data, manual entry for records is not possible.
Kindly provide the solution.
Regards
Narasingam.BThis problem can be solved by proper customizing.
Regards
Narasingam -
Problem with instantiation in static function
I have a problem with instatiation of objects in a static function. When I do something like this,
public static void test1() {
String s = new String();
everything works fine, but when I try to do the same with a internally defined class, I get the error "non-static variable this cannot be referenced from a static context".
My code looks roughly like this:
public static void test2() {
Edge e = new Edge();
class Edge {
public int y_top;
public double x_int;
public int delta_y;
public double delta_x;
The compiler complains with the mentioned error message over the creation of a new Edge object and I don't have the slightest clue why... :| When I put the class Edge into an external file, it works.
Can anyone help me out there?Your class Edge is a member of the instance of the current class. You don't have an implicit instance of the current class (the "this" reference) in a static context, therefore you get the error.
You need to either declare Edge as static, move it outside your class, or create an explicit instance of the outer class which you use to create instances of Edge ("Edge e = new YourMainClass().new Edge()") -
In the past two weeks I have been documenting my Lion problems.
First, Arrows gone from finder windows; makes it difficult in comparing long lists of files in folder, or compare documents when reviewing line by line. This is obviously a change by people who do not compare long lists in windows comparing files between versions of projects ... the click to next screen is NOT equal to arrows.
Second, Finder Redreaw - doesn't. Move files to a fold, if there are a lot of files, they image of the files being moved remains in finder (see attached screen capture) until Finder is restarted and if COPY function is running. last files in Copy queue are not copied.
Screen capture 5 minutes after moving files to a folder - the selected file images are still in Finder after the move was completed.
Third, it is SLOW, particularly going to an "Attach file" in email, drawing the content of a folder to select an attachment is long enough for me to go to the kitchen, get a drink and come back. Just like the old days of OS7.
Fourth, shifting/recentering screen away from where I am working. Several programs, browsers, Adobe Photoshop/inDesign, and dear old Pages re center my screen - not to the center, but if I choose 30 of 70 images in a folder, it will shift … somewhere else in the folder instead of where I just clicked. If I am working on a document in inDesign or PhotoShop it will do the same - the cursor and screen drift elsewhere to find something it has been amused by. Sometimes it is a word, or a file, but often it is off the pastboard and on the etherial pasteboard on which the pages sit. Or if I'm zoomed in on an image, it moves to somewhere else.
I use a mouse and keyboard, both Apple wireless. I do not use a trackpad, but have a tablet/stylus I am afraid to put into the mix until this crap is stopped.
Fifth, SAVE AS… is gone. You must unlock, duplicate and edit the duplicate … and must rename it in Finder, or use EXPORT to save as the same format under a new name. SAVE AS… worked. Not broke, why fix it?
Personal Comment: The problems seem to be the triumph of coked up software engineers ooohing and aaahing over "Wouldn't it be cool if..." Cool, if they were Microsoft, and required everyone change how they have worked on Macs for the past (almost) three decades. Triumph of brainstorming over functionality.
Sixth, I can't use Cocoa Booklet, but that really started in OSX 10.6 "Snow Leopard". Most of my X11/Cocoa programs stopped worked about that time. Apple is no longer supporting "open source"?
But Wait! There's More...
Seventh, Tonight, trying to download a 1.7 gig archive onto a disk where 280 Gigs were supposedly free, it would not download because, according to the wonderful new Safari and the wonderful new Lion, there is not enough disk space to download a 1.7 gig file in a mere 280 Gigs of free space.
I might be able to move Snow Leopard onto the iMac, but my deciding factor was that Apple, in its wisdom, decided to make iBook Author unable to run under Snow Leopard. So moving to Snow Leopard means I have lost the ONLY benefit I get from the new computer and the new system.
This really stinks.bigbookjoe wrote:
In the past two weeks I have been documenting my Lion problems.
First, Arrows gone from finder windows; makes it difficult in comparing long lists of files in folder, or compare documents when reviewing line by line. This is obviously a change by people who do not compare long lists in windows comparing files between versions of projects ... the click to next screen is NOT equal to arrows.
Second, Finder Redreaw - doesn't. Move files to a fold, if there are a lot of files, they image of the files being moved remains in finder (see attached screen capture) until Finder is restarted and if COPY function is running. last files in Copy queue are not copied.
Screen capture 5 minutes after moving files to a folder - the selected file images are still in Finder after the move was completed.
Third, it is SLOW, particularly going to an "Attach file" in email, drawing the content of a folder to select an attachment is long enough for me to go to the kitchen, get a drink and come back. Just like the old days of OS7.
Fourth, shifting/recentering screen away from where I am working. Several programs, browsers, Adobe Photoshop/inDesign, and dear old Pages re center my screen - not to the center, but if I choose 30 of 70 images in a folder, it will shift … somewhere else in the folder instead of where I just clicked. If I am working on a document in inDesign or PhotoShop it will do the same - the cursor and screen drift elsewhere to find something it has been amused by. Sometimes it is a word, or a file, but often it is off the pastboard and on the etherial pasteboard on which the pages sit. Or if I'm zoomed in on an image, it moves to somewhere else.
I use a mouse and keyboard, both Apple wireless. I do not use a trackpad, but have a tablet/stylus I am afraid to put into the mix until this crap is stopped.
Fifth, SAVE AS… is gone. You must unlock, duplicate and edit the duplicate … and must rename it in Finder, or use EXPORT to save as the same format under a new name. SAVE AS… worked. Not broke, why fix it?
Personal Comment: The problems seem to be the triumph of coked up software engineers ooohing and aaahing over "Wouldn't it be cool if..." Cool, if they were Microsoft, and required everyone change how they have worked on Macs for the past (almost) three decades. Triumph of brainstorming over functionality.
Sixth, I can't use Cocoa Booklet, but that really started in OSX 10.6 "Snow Leopard". Most of my X11/Cocoa programs stopped worked about that time. Apple is no longer supporting "open source"?
But Wait! There's More...
Seventh, Tonight, trying to download a 1.7 gig archive onto a disk where 280 Gigs were supposedly free, it would not download because, according to the wonderful new Safari and the wonderful new Lion, there is not enough disk space to download a 1.7 gig file in a mere 280 Gigs of free space.
I might be able to move Snow Leopard onto the iMac, but my deciding factor was that Apple, in its wisdom, decided to make iBook Author unable to run under Snow Leopard. So moving to Snow Leopard means I have lost the ONLY benefit I get from the new computer and the new system.
This really stinks.
http://www.apple.com/feedback/macosx.html -
Urgent: Problems in Generic Extraction by Function Module
Hi BW Gurus,
I am new to SDN and also new to generic extraction using function module. My requirement is to extract long text(142 char) from CRM to BW as the text is not stored in database table I used function module read_text with in another ZXXX function module copy of (RSAX_BIW_GET_DATA_SIMPLE). In my extract structure I used GUID(char,32), Langu, long text(142 char) and 2 placeholders. Text can be extracted by passing STXH table fields(Tdname, Tdid, Tdobject, Tdspars) to read_text as parameters and i also need to use CRMD_ORDERADM_H field GUID(32 char) to compare 1st 32 chars of tdname(70 char) with Guid to select Guids and loop thru this Guids and for each Guid i need to append lines of text to e_t_data but as i donot know ABAP i unable to write the code for this. Through my friends help i wrote code when i check in RSA3 it is displaying the text but when i replicate into BW and load into data target in monitor the status is red with records initially but afterwards it will be red status again with 0 from 0 records for initial load again.when i check on job logs the errors i have are:
The background job has created a job log file of 2Gb size and it is currently on a infinite loop writing entries into the SAP System Log that it cannot write to the Job log file due to Error 22 for write/read access to a file this is because of the datasource i have created. Please find my Function module and if anyone would please correct FM and send me that will be really great.I appreciate it in advance.
MY Function Module is:
FUNCTION Z_CRMORDERH_STR_TXT.
""Local Interface:
*" IMPORTING
*" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
*" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
*" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
*" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
*" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
*" VALUE(I_REMOTE_CALL) TYPE SBIWA_FLAG DEFAULT SBIWA_C_FLAG_OFF
*" TABLES
*" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
*" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
*" E_T_DATA STRUCTURE YCRM_TEXT_STR OPTIONAL
*" EXCEPTIONS
*" NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
***" EXCEPTIONS NO_MORE_DATA
*" ERROR_PASSED_TO_MESS_HANDLER
Tables: CRMD_ORDERADM_H, STXH.
Auxiliary Selection criteria structure
data: l_s_select type srsc_s_select.
Maximum number of lines for DB table
Statics: s_s_if type srsc_s_if_simple,
counter
s_counter_datapakid like sy-tabix,
Cursor
s_cursor type cursor.
data: i_crmtext type standard table of TLINE .
types: begin of xsreph ,
GUID type CRMD_ORDERADM_H-guid,
end of xsreph.
data: i_guid type standard table of xsreph.
data: I_TEXT type STXH-TDNAME.
data: xempl like YCRM_TEXT_STR occurs 0 with header line.
data: t_tab like dd03l-tabname.
Select ranges
ranges: l_r_guid for CRMD_ORDERADM_H-guid.
l_r_connid for sflight-connid.
Initialization mode (first call by SAPI) or data transfer mode
(following calls) ?
if i_initflag = sbiwa_c_flag_on.
Initialization: check input parameters
buffer input parameters
prepare data selection
Check DataSource validity
case i_dsource.
when 'yCRM_TEXT'. " for S_SREPH1
when others.
if 1 = 2. message e009(r3). endif.
this is a typical log call. Please write every error message like this
log_write 'E' "message type
'R3' "message class
'009' "message number
i_dsource "message variable 1
' '. "message variable 2
raise error_passed_to_mess_handler.
endcase.
append lines of i_t_select to s_s_if-t_select.
Fill parameter buffer for data extraction calls
s_s_if-requnr = i_requnr.
s_s_if-dsource = i_dsource.
s_s_if-maxsize = i_maxsize.
Fill field list table for an optimized select statement
(in case that there is no 1:1 relation between InfoSource fields
and database table fields this may be far from beeing trivial)
append lines of i_t_fields to s_s_if-t_fields.
we will do our selection based on what is in the p table for the
infoobject
else. "Initialization mode or data extraction ?
Data transfer: First Call OPEN CURSOR + FETCH
Following Calls FETCH only
First data package -> OPEN CURSOR
if s_counter_datapakid = 0.
Fill range tables BW will only pass down simple selection criteria
of the type SIGN = 'I' and OPTION = 'EQ' or OPTION = 'BT'.
LOOP AT S_S_IF-T_SELECT INTO L_S_SELECT WHERE FIELDNM = 'GUID'.
MOVE-CORRESPONDING L_S_SELECT TO L_R_GUID.
APPEND L_R_GUID.
ENDLOOP.
case i_dsource.
when 'YCRM_TEXT'. " for S_SREPH1
t_tab = 'CRMD_ORDERADM_H'.
endcase.
select GUID
from (t_tab)
into table i_guid where PROCESS_TYPE = 'ZACI' and ( OBJECT_ID < '0000000042').
select tdname from stxh into i_text where tdobject = 'TEXT'.
if sy-subrc ne 0.
message e009(r3).
this is a typical log call. Please write every error message like this
log_write 'E' "message type
'R3' "message class
'009' "message number
i_dsource "message variable 1
'No master data found'. "message variable 2
raise error_passed_to_mess_handler.
endif.
Determine number of database records to be read per FETCH statement
from input parameter I_MAXSIZE. If there is a one to one relation
between DataSource table lines and database entries, this is trivial.
In other cases, it may be impossible and some estimated value has to
be determined.
open cursor with hold s_cursor for
select (s_s_if-t_fields) from CRMD_ORDERADM_H
where GUID in L_R_GUID .
ENDIF.
Fetch records into interface table.
named E_T_'Name of extract structure'.
fetch next cursor s_cursor
appending corresponding fields
of table e_t_data
package size s_s_if-maxsize.
IF SY-SUBRC <> 0.
CLOSE CURSOR S_CURSOR.
RAISE NO_MORE_DATA.
ENDIF.
as we are doing this only once can use the select statement.
***data: crmtext like tline occurs 0 with header line.
**data: i_crmtext type standard table of TLINE.
**data: i_guid type standard table of xsreph.
data: l_guid type THEAD-TDNAME.
data: st_guid type xsreph.
data: st_crmtext type TLINE.
data: lan type THEAD-TDSPRAS.
lan = 'E'.
loop at i_guid into st_guid.
l_guid = st_guid-guid.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'A002'
LANGUAGE = lan
NAME = l_guid
OBJECT = 'CRM_ORDERH'
ARCHIVE_HANDLE = 0
LOCAL_CAT = ' '
IMPORTING
HEADER =
TABLES
LINES = i_crmtext.
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8
e_t_data-guid = l_guid.
loop at i_crmtext into st_crmtext.
move lan to e_t_data-langu.
move st_crmtext-tdline to e_t_data-description.
append e_t_data.
endif.
endloop.
clear: st_guid,l_guid.
refresh: i_crmtext.
endloop.
S_COUNTER_DATAPAKID = S_COUNTER_DATAPAKID + 1.
endif.
ENDFUNCTION.
please Gurus as I donot know ABAP i appreciate if anyone would write a FM based on requirement and send me that will be really great this is my request. I gurantee of award points for good answers.
Regards
KishoreHi,
The statement <b>RAISE NO_MORE_DATA</b> should be active (uncommented) in your code. Otherwise, the infinte loop occurs.
See also, the Siggi's blog:
/people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
BTW, was it your thread here:
Re: Urgent: problems in extracting Long Text
Best regards,
Eugene -
Problem while calling an RFC Function Module in Background
Hello,
I have created a RFC function module for reading data from an external DB system. The FM calls an external RFC program (coded in C++ using RFC SDK), which delivers the required data. This external program is maintainged as an TCP RFC Connection in SM59.
Further I have created a report, that calls the RFC function module to get the data from the external RFC programm.
My problem is, when I call the report in foreground, everything works OK, the RFC connection works and data can be read from the external program.
However, when I schedule the report to run in background as a job, the report is stating in the protocoll that there was a problem calling the defined RFC connection (although the connection is working properly at that time).
More funny is, this particular problem with running in background occurs only in the productive system, in test and development system the report works correctly also while running as a job in background.
Can you suggest the solution to this problem? Could it be something with authorisations or server settings?
I will be on holiday for the next 6 weeks, so take your time to answer .
Regards,
Dusan.
Edited by: Julius Bussche on Jan 22, 2009 7:19 PM
Please read the forum rules about u r g e n t ...This is an external RFC server program, not a remote enabled ABAP RFC function module as the others seem to be assuming, right?
Is it possible that your DEV and QAS systems only have one application server, but the PROD has many and dedicated one(s) for processing low priority background jobs?
It might be that the target server of your TCP connection is not this BTC instance, and your RFC server is returning the data "locally" - so, into nirvana...
Just guessing, but might be worth checking.
Cheers,
Julius -
Can anybody help me in fixing the problem ? of JTable ( CODE GIVEN )
My problem is
1)when i select the combo box (2nd column) through keyboard the selected item is not visible in the cell
2) i need to press TAB key twice to go to next cell .
3) also before editing i need to press a key to start editing (caret visible) HELP ME
CODE CAN BE RUN TO SEE WHAT I MEANT
<code>
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;
import java.text.*;
public class BaseTable
public JScrollPane scrollPane;
public JTable table;
public int totalRows;
public int i,numRows,numCols;
public TableModel model;
public int rowCount;
public JComboBox box;
public BaseTable()
String[] items=new String[]{"item1","jItem2","kItem3","Item4","Item5","Item6"};
String[] columns = {"Column1","Column2","Column3","Column4","Column5","Column6","Column7","Column8","Column9"};
box=new JComboBox(items);
box.setEditable(true);
DefaultTableModel baseModel=new DefaultTableModel();
baseModel.setColumnIdentifiers(columns);
table = new JTable(baseModel)
protected void processKeyEvent(KeyEvent e)
if ( e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() != e.VK_TAB)
int column = table.getSelectedColumn();
int row = table.getSelectedRow();
Rectangle r = getCellRect(row, column, false);
Point p = new Point( r.x, r.y );
SwingUtilities.convertPointToScreen(p, table);
try
System.out.println("PROCESS KEY EVENT Typing"+e.getKeyCode());
Robot robot = new Robot();
robot.mouseMove(p.x, p.y );
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mouseMove(0, 0 );
catch (Exception e2) {}
else
System.out.println("PROCESS KEY EVENT IN ELSE");
if(e.getKeyCode() == e.VK_TAB && table.isEditing())
((DefaultCellEditor)table.getCellEditor()).stopCellEditing();
else
super.processKeyEvent(e);
Vector vectorRow = new Vector();
vectorRow.addElement("");
vectorRow.addElement("");
vectorRow.addElement("");
vectorRow.addElement("");
vectorRow.addElement("");
vectorRow.addElement("");
vectorRow.addElement("");
vectorRow.addElement("");
vectorRow.addElement("");
TableCellEditor tableCellEditor_comboBox = new MyCustomTableCellEditor(box,this);
table.getColumnModel().getColumn(1).setCellEditor(tableCellEditor_comboBox);
((DefaultTableModel)table.getModel()).addRow(vectorRow);
rowCount = table.getRowCount();
((DefaultTableModel)table.getModel()).fireTableRowsInserted(rowCount,rowCount);
scrollPane = new JScrollPane(table);
scrollPane.setForeground(Color.white);
rowCount = table.getRowCount();
numCols = table.getColumnCount();
public class MyCustomTableCellEditor extends DefaultCellEditor
JTable table=null;
BaseTable baseTable=null;
JComboBox box=null;
MyCustomTableCellEditor(JComboBox editorComponent,BaseTable baseTable)
super(editorComponent);
this.table=baseTable.table;
this.baseTable=baseTable;
setClickCountToStart(0);
public Component getTableCellEditorComponent(
JTable table,
Object value,
boolean isSelected,
int row,
int column)
super.getTableCellEditorComponent(table,value,isSelected,row,column);
box=(JComboBox)getComponent();
box.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
return box;
public static void main(String s1[])
BaseTable t=new BaseTable();
JFrame f=new JFrame();
f.getContentPane().add(t.scrollPane);
f.setSize(800,200);
f.setVisible(true);
</code>sahas@sun, you're very impolite! farukkhan was trying to help, and he's right because when you use code formatting the code is really easier to read.
Perhaps you have lost a chance for getting the answer! -
Problem in execution of a function having clob datatype
[http://www.orafaq.com/forum/t/128331/98870/]
Hi,
I had a Problem in executing a function having clob datatype.
Here below is my function.
create or replace type split_obj as object
occurence_id number(10,0),
splitvalue varchar2(1000)
create or replace type split_rec as table of split_obj;
create or replace FUNCTION Split_new1(
p_string IN clob,
p_delimiter IN VARCHAR2
) return split_rec pipelined is
v_length NUMBER := dbms_lob.getlength(p_string);
v_start NUMBER := 1;
v_index NUMBER;
V_temp NUMBER(10,0):=0;
begin
WHILE(v_start <= v_length)
LOOP
v_index := dbms_lob.INSTR(p_string, p_delimiter, v_start);
IF v_index = 0 THEN
V_temp:=V_temp+1;
PIPE ROW(split_obj(v_temp,dbms_lob.SUBSTR(p_string, v_length,v_start)));
v_start := v_length + 1;
ELSE
v_temp:=v_temp+1;
PIPE ROW(split_obj(v_temp,dbms_lob.SUBSTR(p_string, v_index - v_start,v_start)));
v_start := v_index + 1;
END IF;
END LOOP;
return;
end Split_new1;Here attached link contains the procedure trying to execute the function with huge string more than 400kb.
Could you pls let me know how to do the same in sqlplus and toad.
Thanks in advance.
Edited by: user512743 on Nov 27, 2008 4:31 AMBluShadow wrote:
The problem is that in your execution of this you are trying to assign a value to the clob variable using
v_clob := '<string>'
where the string is greater than allowed in PL/SQL.
Whilst the CLOB itself can hold more data, the string is actually the equivalent of a VARCHAR2 so cannot exceed VARCHAR2 limits.
You should use the DBMS_LOB package to append data to your CLOB in chunks of no more than 32767 characters at a time.??? PL/SQL provides full CLOB support. There is no need to use DBMS_LOB (although you could). OP's function has logic errors. Anyway:
SQL> create or replace type split_obj as object
2 (
3 occurence_id number(10,0),
4 splitvalue varchar2(1000)
5 );
6 /
Type created.
SQL> create or replace type split_rec as table of split_obj;
2 /
Type created.
SQL> create or replace
2 FUNCTION Split_new1(
3 p_string IN clob,
4 p_delimiter IN VARCHAR2
5 )
6 return split_rec pipelined
7 is
8 v_length NUMBER := length(p_string);
9 v_start NUMBER := 1;
10 v_end NUMBER;
11 V_id NUMBER :=0;
12 v_clob CLOB := p_string || p_delimiter;
13 begin
14 while(v_start <= v_length) loop
15 v_end := instr(v_clob, p_delimiter, v_start);
16 v_id := v_id + 1;
17 pipe row(split_obj(v_id,substr(p_string,v_start,v_end - v_start)));
18 v_start := v_end + length(p_delimiter);
19 end loop;
20 return;
21 end Split_new1;
22 /
Function created.
SQL> create table test_table(x clob)
2 /
Table created.
SQL> declare
2 c clob;
3 begin
4 for i in 1..26 loop
5 c := c || lpad(chr(ascii('a') + i - 1),1000,chr(ascii('a') + i - 1)) || ',';
6 end loop;
7 for i in 1..26 loop
8 c := c || lpad(chr(ascii('A') + i - 1),1000,chr(ascii('A') + i - 1)) || ',';
9 end loop;
10 for i in 1..26 loop
11 c := c || lpad(chr(ascii('a') + i - 1),1000,chr(ascii('a') + i - 1)) || ',';
12 end loop;
13 for i in 1..26 loop
14 if i > 1 then c := c || ','; end if;
15 c := c || lpad(chr(ascii('A') + i - 1),1000,chr(ascii('A') + i - 1));
16 end loop;
17 insert into test_table
18 values(c);
19 end;
20 /
PL/SQL procedure successfully completed.
SQL> select length(x)
2 from test_table
3 /
LENGTH(X)
104103
SQL> select t.occurence_id,
2 length(splitvalue) len,
3 substr(splitvalue,1,20) first_20
4 from test_table,
5 table(Split_new1(x,',')) t
6 /
OCCURENCE_ID LEN FIRST_20
1 1000 aaaaaaaaaaaaaaaaaaaa
2 1000 bbbbbbbbbbbbbbbbbbbb
3 1000 cccccccccccccccccccc
4 1000 dddddddddddddddddddd
5 1000 eeeeeeeeeeeeeeeeeeee
6 1000 ffffffffffffffffffff
7 1000 gggggggggggggggggggg
8 1000 hhhhhhhhhhhhhhhhhhhh
9 1000 iiiiiiiiiiiiiiiiiiii
10 1000 jjjjjjjjjjjjjjjjjjjj
11 1000 kkkkkkkkkkkkkkkkkkkk
OCCURENCE_ID LEN FIRST_20
12 1000 llllllllllllllllllll
13 1000 mmmmmmmmmmmmmmmmmmmm
14 1000 nnnnnnnnnnnnnnnnnnnn
15 1000 oooooooooooooooooooo
16 1000 pppppppppppppppppppp
17 1000 qqqqqqqqqqqqqqqqqqqq
18 1000 rrrrrrrrrrrrrrrrrrrr
19 1000 ssssssssssssssssssss
20 1000 tttttttttttttttttttt
21 1000 uuuuuuuuuuuuuuuuuuuu
22 1000 vvvvvvvvvvvvvvvvvvvv
OCCURENCE_ID LEN FIRST_20
23 1000 wwwwwwwwwwwwwwwwwwww
24 1000 xxxxxxxxxxxxxxxxxxxx
25 1000 yyyyyyyyyyyyyyyyyyyy
26 1000 zzzzzzzzzzzzzzzzzzzz
27 1000 AAAAAAAAAAAAAAAAAAAA
28 1000 BBBBBBBBBBBBBBBBBBBB
29 1000 CCCCCCCCCCCCCCCCCCCC
30 1000 DDDDDDDDDDDDDDDDDDDD
31 1000 EEEEEEEEEEEEEEEEEEEE
32 1000 FFFFFFFFFFFFFFFFFFFF
33 1000 GGGGGGGGGGGGGGGGGGGG
OCCURENCE_ID LEN FIRST_20
34 1000 HHHHHHHHHHHHHHHHHHHH
35 1000 IIIIIIIIIIIIIIIIIIII
36 1000 JJJJJJJJJJJJJJJJJJJJ
37 1000 KKKKKKKKKKKKKKKKKKKK
38 1000 LLLLLLLLLLLLLLLLLLLL
39 1000 MMMMMMMMMMMMMMMMMMMM
40 1000 NNNNNNNNNNNNNNNNNNNN
41 1000 OOOOOOOOOOOOOOOOOOOO
42 1000 PPPPPPPPPPPPPPPPPPPP
43 1000 QQQQQQQQQQQQQQQQQQQQ
44 1000 RRRRRRRRRRRRRRRRRRRR
OCCURENCE_ID LEN FIRST_20
45 1000 SSSSSSSSSSSSSSSSSSSS
46 1000 TTTTTTTTTTTTTTTTTTTT
47 1000 UUUUUUUUUUUUUUUUUUUU
48 1000 VVVVVVVVVVVVVVVVVVVV
49 1000 WWWWWWWWWWWWWWWWWWWW
50 1000 XXXXXXXXXXXXXXXXXXXX
51 1000 YYYYYYYYYYYYYYYYYYYY
52 1000 ZZZZZZZZZZZZZZZZZZZZ
53 1000 aaaaaaaaaaaaaaaaaaaa
54 1000 bbbbbbbbbbbbbbbbbbbb
55 1000 cccccccccccccccccccc
OCCURENCE_ID LEN FIRST_20
56 1000 dddddddddddddddddddd
57 1000 eeeeeeeeeeeeeeeeeeee
58 1000 ffffffffffffffffffff
59 1000 gggggggggggggggggggg
60 1000 hhhhhhhhhhhhhhhhhhhh
61 1000 iiiiiiiiiiiiiiiiiiii
62 1000 jjjjjjjjjjjjjjjjjjjj
63 1000 kkkkkkkkkkkkkkkkkkkk
64 1000 llllllllllllllllllll
65 1000 mmmmmmmmmmmmmmmmmmmm
66 1000 nnnnnnnnnnnnnnnnnnnn
OCCURENCE_ID LEN FIRST_20
67 1000 oooooooooooooooooooo
68 1000 pppppppppppppppppppp
69 1000 qqqqqqqqqqqqqqqqqqqq
70 1000 rrrrrrrrrrrrrrrrrrrr
71 1000 ssssssssssssssssssss
72 1000 tttttttttttttttttttt
73 1000 uuuuuuuuuuuuuuuuuuuu
74 1000 vvvvvvvvvvvvvvvvvvvv
75 1000 wwwwwwwwwwwwwwwwwwww
76 1000 xxxxxxxxxxxxxxxxxxxx
77 1000 yyyyyyyyyyyyyyyyyyyy
OCCURENCE_ID LEN FIRST_20
78 1000 zzzzzzzzzzzzzzzzzzzz
79 1000 AAAAAAAAAAAAAAAAAAAA
80 1000 BBBBBBBBBBBBBBBBBBBB
81 1000 CCCCCCCCCCCCCCCCCCCC
82 1000 DDDDDDDDDDDDDDDDDDDD
83 1000 EEEEEEEEEEEEEEEEEEEE
84 1000 FFFFFFFFFFFFFFFFFFFF
85 1000 GGGGGGGGGGGGGGGGGGGG
86 1000 HHHHHHHHHHHHHHHHHHHH
87 1000 IIIIIIIIIIIIIIIIIIII
88 1000 JJJJJJJJJJJJJJJJJJJJ
OCCURENCE_ID LEN FIRST_20
89 1000 KKKKKKKKKKKKKKKKKKKK
90 1000 LLLLLLLLLLLLLLLLLLLL
91 1000 MMMMMMMMMMMMMMMMMMMM
92 1000 NNNNNNNNNNNNNNNNNNNN
93 1000 OOOOOOOOOOOOOOOOOOOO
94 1000 PPPPPPPPPPPPPPPPPPPP
95 1000 QQQQQQQQQQQQQQQQQQQQ
96 1000 RRRRRRRRRRRRRRRRRRRR
97 1000 SSSSSSSSSSSSSSSSSSSS
98 1000 TTTTTTTTTTTTTTTTTTTT
99 1000 UUUUUUUUUUUUUUUUUUUU
OCCURENCE_ID LEN FIRST_20
100 1000 VVVVVVVVVVVVVVVVVVVV
101 1000 WWWWWWWWWWWWWWWWWWWW
102 1000 XXXXXXXXXXXXXXXXXXXX
103 1000 YYYYYYYYYYYYYYYYYYYY
104 1000 ZZZZZZZZZZZZZZZZZZZZ
104 rows selected.
SQL> As you can see, function works OK without DBMS_LOB on CLOB of 104103 bytes.
SY. -
Problem with bfilename(directory_name,file_name) function
Hi all,
I have a problem with this function. I have built and pl/sql program in order to send an email wich includes "pdf" file.
I have found that bfilename function works fine when you want to send a pdf file.
However, when I execute this query
SELECT bfilename('/usr/tmp', 'pdf_report.pdf') dato
FROM dual;
The result shows in the screen : /usr/tmp//pdf_report.pdf (NoExist)
I don't know why the path includes double "//".
Then, I wanted to open the file in this way
bfile_len := dbms_lob.getlength(bfile_handle);
pos := 1;
dbms_lob.open(bfile_handle,dbms_lob.lob_readonly);
an error occurs :
ORA-22285: non-existent directory or file for GETLENGTH operation.
I infere that the problem is "//" but I don't know why it happened.
Can I use another function in order to send a pdf file inside an email ? Or can I change a blob type column in order to replace "/" insted of "//" ?.
I appreciate your help.
Best Regards,
Mariano.-Hi Damorgan,
I did what you told me but the error still appears.
I created my directory in the database. But when the program executed the line with the "fileopen sentence" the error appeared again.
I saw that the directory contained '//' instead of '/'. Can I use another function in order to send a pdf file inside an email ?
Thanks for your cooperation and patience.
Best Regards.
Mariano.-
Maybe you are looking for
-
BT Email not loading on Chrome Browser
I have not been able to get BT email to work on both Chrome and Internet Explorer so phoned BT and they fixed it remotley to work on internet explorer including adding the website into the compatibility view area on IE. However they told me the reaso
-
Logical AND vs logical OR on empty boolean array
Just satisfying a curiousity...Can anyone tell me the logic behind this behavior (LV 7.1,8.0 and 8.2 do it)? Logical AND on empty Bool Array = TRUE Logical OR on empty Bool Array = FALSE Of course there are very simple ways to work around this, but i
-
After Effects CC 2014.1 nicht kompatibel mit anderen Versionen?
Hallo zusammen, wir haben festgestellt, dass sich Projekte, die mit After Effects 2014.1 erstellt wurden, nicht mehr mit vorhergehenden AE-Versionen öffnen lassen? Wenn das so sein soll, wäre das der Hammer, und völlig an der Workflow-Realität vorbei
-
Star ratings on iphone aren't displaying proplerly in itunes
Hello, I am new to the community, so this may be a very stupid problem that i am having. No matter how many times i sync my iphone with itunes, the star ratings that i have assigned songs on my iphone will not display correctly in itunes. I understan
-
Help Save for Web problem PE9 default gif setting
I have a 64 bit PC with Windows 7. PE9 and problem is when I "Save for Web" as a jpg....everytime I save a file it defaults back to the gif everytime. I want the default to be JPG!! I never use gif for anything. Pain in the rear to change the drop