JTextArea + position of cursor from beginning of line
Hi all,
I want to find how many characters my cursor is located away from the beginning of a line, in a JTextArea.
I already know the position of the cursor using the following statement:
int caret = myJTextArea.getCaretPosition();
I also use the following method to get the line number the cursor is located (I found it in a forum posting):
public static int getLineAtCaret(JTextArea textArea)
int caretPosition = textArea.getCaretPosition();
Element root = textArea.getDocument().getDefaultRootElement();
return root.getElementIndex(caretPosition) + 1;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends JFrame {
JTextArea jta = new JTextArea("Hi all,\nI want to find how many characters "+
"my cursor is located away from the beginning of a line, in a "+
"JTextArea.\nI already know the position of the cursor using the "+
"following statement:\nint caret = myJTextArea.getCaretPosition();"+
"\nI also use the following method to get the line number the "+
"cursor is located (I found it in a forum posting):\npublic static "+
"int getLineAtCaret(JTextArea textArea)\n{\nint caretPosition = "+
"textArea.getCaretPosition();\nElement root = textArea."+
"getDocument().getDefaultRootElement();\nreturn root."+
"getElementIndex(caretPosition) + 1;\n}");
public Test() {
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
Container content = getContentPane();
content.add(new JScrollPane(jta), BorderLayout.CENTER);
JButton jb = new JButton("Do Not Press!!!");
content.add(jb, BorderLayout.SOUTH);
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int cpos = jta.getCaretPosition(), lpos=-1, line=-1;
try {
for (int x=0; x<jta.getLineCount(); x++) {
if (jta.getLineStartOffset(x)<=cpos) {
line=x;
lpos = cpos-jta.getLineStartOffset(x);
} else break;
System.out.println("line="+line+", col="+lpos);
} catch (javax.swing.text.BadLocationException ble) {
ble.printStackTrace();
setSize(400,300);
show();
public static void main( String args[] ) { new Test(); }
}
Similar Messages
-
[Solved] How do I delete from cursor to beginning of line in Vi?
I'm wondering if there's a way to delete from the the cursor to the beginning of the current line in Vi, basically doing D backwards. I would find this very useful, as manually doing this is getting annoying.
Edit: Of course after days of searching I figure it out right after asking. It's d0 that I need to type in.
Last edited by zenten (2012-06-13 17:42:45)I saw your thread title and that it was already solved, so I gave myself a little quiz to see if I knew the answer before reading what you wrote.
Since I use 'd$' to delete to the end of the line, I guessed that it was 'd0' to delete to the beginning of the line. Looks like I was right! Who says Vim isn't intutitive?
I didn't even know about the 'D' command... -
Position the cursor in a JTextField
Hi !
I have an App with 10 JTextFields and I want to position the cursor from JTextField No.2 to JTextField No.8
Is there a possibility to tell the program that the cursor have to go to an other Component ?
Thank you. Wolfgang (KLD)You'll want to check out
"grabFocus" in javax.swing.JComponent
For some additional niceties you may want to check out
"setFocusAccelerator" in javax.swing.text.JTextComponent
It provides automated ways to jump around components.
H -
How do I stop the cursor from spontaneously going to Line one space one in Notes?
How do I stop the cursor from spontaneously going to Line one Space one in Notes?
I am currently working on a MacBook Pro connected by Wi-Fi or Blue Tooth to my 16GB iPhone 4S; and supposedly to iCloud. I install every upgrade on each computer till the computer can take no more. My current MacBook Pro continues to accept upgrades.
I have been dealing with Address Book foibles since it first came out and the problems seem to get worse rather than resolved.
Problem #1: When a Company Name is checked to take precedence over a personal name the record/file does not surface during searches. This has happened for years on all my Macs, including most recently my MacBook Pro and its predecessor PowerBook G4. How do I fix this?
Problem #2: The Printing Defaults for Address Book Files are not useful and I can find no way to change them to my own preferences once and for all. I must reset them for every file every time I choose to print a file. Is there some way to set the defaults to MY preferences and only occasionally reset them according to my needs?
Problem #3: When entering information in "Notes" the cursor randomly and spontaneously goes to line one space one as I am entering information. How do I stop this? Then when I cut and paste the misplaced text to where it belongs it may or may not return to once again begin at line one space one and following.
Problem #4: When Printing a Record/File from Address Book I would like to use the whole 8.5" x 11" page. Instead it prints on an 8.5" x 11" page in three columns. Is there a way to format the output? I have not found one and the Mac 'Geniuses' do not know of any.
Problem #5: Subsequent to one of the upgrades in the last year or so, the search feature does not work. (I have had this computer since May 2011). No matter what I type in the search line I am stuck in the 'All' Directory. To find anyone or anything I must scroll through the address book manually. Is there a fix to this?
Problem #6: Sometimes, when I try to sync my MacBook Pro and my iPhone, the records simply duplicate. How d I undo this without manually deleting the duplicates?
Problem #7: Does anyone know of a third party Address-Book-type App that is better than the Apple version and can easily import over 3000 contacts information?'''I had the same problem when I updated to firefox 4. This is how i fixed it:'''
The problem seems to be caused by the 'New Tab Homepage' add on. So:
# Disable or remove the 'New Tab Homepage' add on and restart firefox.
# Download and install the firefox add on called 'NewTabURL' and restart firefox.
# Click on the Options button for NewTabURL and uncheck 'Select location bar after loading new tab'
# Under the 'Default URL for new tabs' heading, choose 'Home Page'
# Click on the Save button.
Hopefully, problem solved! -
In alv report , how to reserve 20 lines from beginning of page
hi experts
in alv report , how to reserve 20 lines from beginning of page.
regards
subhasis.If by reserve you mean should not move on scrolling then make them KEY from fieldcatalog.
But I think maximum of 10-12 can be handled by that.
Regards,
Amit
Reward all helpful replies. -
Error in TCode iview Select a line or position the Cursor correctly
Hi All,
I am getting the below error while selecting the row in Tcode iview
Select a line or position the Cursor correctly.
You have not selected a delivery or a delivery item for processing and the cursor is not positioned on a valid line, even after i am
selecting the Delivery and click on the execute button
My system config :
NW04s SP 20
Thanks&Regards
MurthyHi Murthy,
Create the Iview again.Hope the issue will resolve.
Thanks,
Arun -
How do I prevent the playhead from returning to it's original position after pausing or stopping with the spacebar or k button? With either the skimmer on or off, whenever I pause or stop the **** playhead will always return to the position it was last at. I don't understand why neither of the shortcuts would just stop the playhead at the point that is being played at. This may seem like an extremely edgy way to go about editing, but I might actually wish to pause the playhead at any given moment and position my playhead nearby said moment before creating an edit point (without having to add a marker and return to it with the blade tool, or take note of the specific duration and use the duration control to go to that specific point or any other unnecessary steps when doing a rough cut). I simply would like the playhead to pause/stop at the moment I press either keyboard shortcut. After the many attempts at trying to make FCP X work for me and the many "workarounds" by FCPX enthusiasts, it's disheartening to know that most other editors in my circle who make a living doing paid commercial work are wondering why I've decided to take a break from using CS6 (and it's integration with the industry-standard AE) to give FCP X a shot, all to make very simple tasks like the one aforementioned a mystery... any help in this matter would be greatly appreciated.
Thank you for your response Luis and for your previous help (regarding multiple selections being added to the timeline in reverse order when working in list view in the event browser).
Yes i've trashed my preferences, but I should be more specific as to what I am actually doing. Because I am working from my macbook pro and do not have a "home button" which was the original shortcut to "play from/go to beginning" and because I did not like the replacement shortcut in FCP X to play from beginning (without a home button it was something like Function + Shift something else on a laptop) I became used to Adobe Premiere CS6 and made the return key my "play from beginning" shortcut. It was available and did not have a use by itself (only to confirm changes/choices), did not effect it's use in conjunction with other shorctus so I choose enter as my "play from/go to beginning"...
So when I play from the beginning and attempt to pause or stop the playhead, regardless of how I choose to do it (spacebar or k) it does not stop at that specific instance and always returns to where it previously was. This seems very confusing and inconvenient, I would hope at least one of these shortcuts would actually stop the playhead where it was at that moment where I press stop or pause. It's extremely frustrating knowing that I cannot pause the playhead where it's playing if I choose my "play from beginning" shortcut.
Also since you seem to be a guru and an expert, i'd like to know if you cut with FCPX on a laptop and what shortcut you use whenever you'd like the playhead to go to the beginning of the timeline, end, etc since there are no "home" or "end" buttons on a laptop....
Thanks a million, talk soon...
Anthony -
Position the cursor at the top of the JTextArea?
How do you position the cursor or document at the top of the JTextArea. When I set the JTextArea to some text that exceeds the JTextArea ScrollPane it scrolls to the bottom of the document. How do you position the document to the top of the JTextArea?
thanks,
PetersetCaretPosition(0);
-
JTextField: How to selectAll() AND Position Cursor at Beginning of Text
Hi All,
I have a problem with when a JTextField is selected, I cannot simultaneously selectAll() and position the cursor at the beginning of the text. (selectAll() positions the cusror at the end of the selected text, not the beginning, which is what I require).
Does anyone have a solution for this as I haven't found an answer as of yet.
Many thanks.Thanks uncle_alice, but as far as I have determined, the setCaret() and selectAll() methods are mutally exclusive. Why do people ask for help and then disagree with the answer given?
Thanks uncle_alice, I tried the code and it works.It amazes me that it took half an hour to "try" the code. Why not try the code first, ask a followup question later if it doesn't work? Why do we have to waste time resonding to a question twice, just to get you to try the code? -
How to position the cursor at the end of the text with EDIT_TEXT?
Hello, it wanted to ask to them if somebody could make work the module of function EDIT_TEXT so that it positions the cursor at the end of the text that is visualizing in the text editor. In the documentation it says that passing a ' X' to him in the field scrollend of the parameter Control is obtained that operation. Nevertheless, I did this and the cursor continues appearing at the beginning of the text that visualizes.
Somebody could help me please?
Regards,
Gabriel
PD: The code that I use is the following one:
FORM f_ingresar_comentarios.
DATA: l_action,
l_result LIKE itcer,
l_pedido LIKE thead-tdname,
li_coment_save LIKE i_comentarios OCCURS 0,
li_coment_aux LIKE i_comentarios OCCURS 0 WITH HEADER LINE,
l_lines TYPE i,
l_lines_save TYPE i,
l_lines_insert TYPE i,
l_index TYPE i,
l_index_aux TYPE i,
l_insert,
lwa_control LIKE itced.
CLEAR: l_action.
CLEAR i_comentarios.
REFRESH: i_comentarios,
li_coment_save,
li_coment_aux.
l_pedido = v_pedido.
Leemos el texto si es que existe
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = v_id_text
language = sy-langu
name = l_pedido
object = c_ekko
IMPORTING
header = wa_cabecera
TABLES
lines = i_comentarios "Lineas de texto leídas
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
Armamos la cabecera por primer comentario para el pedido
CLEAR wa_cabecera.
wa_cabecera-tdobject = c_ekko. "Objeto en tabla TTXID
wa_cabecera-tdname = v_pedido. "Nro de pedido
wa_cabecera-tdid = v_id_text. "ID en tabla TTXID
wa_cabecera-tdspras = sy-langu. "Lenguaje
wa_cabecera-tdlinesize = 70.
ENDIF.
Salva comentarios originales
li_coment_save[] = i_comentarios[].
lwa_control-scrollend = c_x. " c_x = 'X'
Abre el editor de texto
CALL FUNCTION 'EDIT_TEXT'
EXPORTING
header = wa_cabecera
save = space
control = lwa_control
IMPORTING
newheader = wa_cabecera
function = l_action
RESULT = l_result
TABLES
lines = i_comentarios
EXCEPTIONS
object = 1
id = 2
language = 3
name = 4
linesize = 5.
Si cambio los comentarios, actualiza comentarios
CASE l_action.
WHEN c_unchanged.
WHEN c_delete.
WHEN c_update OR
c_insert.
Obtiene cantidad de lineas de comentarios originales y modificados
DESCRIBE TABLE li_coment_save LINES l_lines_save.
DESCRIBE TABLE i_comentarios LINES l_lines.
Si se insertaron lineas...
IF l_lines > l_lines_save.
Calcula cantidad de lineas a insertar para luego calcular valor de
indice a partir del cual insertar los nuevos comentarios
l_lines_insert = l_lines - l_lines_save.
l_index = ( l_lines - l_lines_insert ) + 1.
Controla que al menos una de las lineas insertadas sea diferente de
blanco
l_index_aux = l_lines.
l_insert = c_n.
DO l_lines_insert TIMES.
READ TABLE i_comentarios INDEX l_index_aux.
IF sy-subrc = 0 AND
i_comentarios-tdline <> space.
l_insert = c_s.
EXIT.
ENDIF.
l_index_aux = l_index_aux - 1.
ENDDO.
IF l_insert = c_s.
Carga comentarios originales y agrega lineas insertadas
li_coment_aux[] = li_coment_save[].
APPEND LINES OF i_comentarios
FROM l_index
TO l_lines
TO li_coment_aux.
Setea variable para indicar actualizacion de comentarios.
v_comentario = 'S'.
Agrega usuario y fecha del comentario
CONCATENATE sy-uname
sy-datum
INTO li_coment_aux-tdline
SEPARATED BY space.
li_coment_aux-tdformat = '*'.
APPEND li_coment_aux.
Grabamos el texto
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
client = sy-mandt
header = wa_cabecera
savemode_direct = c_x
IMPORTING
newheader = wa_cabecera
TABLES
lines = li_coment_aux
EXCEPTIONS
id = 1
language = 2
name = 3
object = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDIF.
ENDCASE.
ENDFORM. " f_ingresar_comentarios
In addition, I made another program simpler that it uses the same functions and also have the same problem:
*& Report Y_GVA_TEXT *
REPORT y_gva_text .
DATA: wa_cabecera LIKE thead,
i_comentarios LIKE tline OCCURS 0 WITH HEADER LINE.
DATA: l_action,
v_comentario,
l_result LIKE itcer,
v_pedido LIKE thead-tdname VALUE '3',
l_pedido LIKE thead-tdname,
c_a05 LIKE thead-tdid VALUE 'A05',
c_ekko LIKE stxh-tdobject VALUE 'EKKO',
l_lines LIKE sy-tabix,
lwa_control LIKE itced.
CONSTANTS: c_x VALUE 'X',
update VALUE 'U', "Langtext verändert
insert VALUE 'I', "Langtext eingefügt
delete VALUE 'D', "Langtext gelöscht
modify VALUE 'M', "Kein Langtext, Inlinezeile veränd.
unchanged VALUE ' '.
CLEAR: l_action.
CLEAR i_comentarios.
REFRESH i_comentarios.
Leemos el texto si es que existe
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = c_a05
language = sy-langu
name = v_pedido
object = c_ekko
IMPORTING
header = wa_cabecera
TABLES
lines = i_comentarios "Lineas de texto leídas
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Armamos las cabecera para mostrar los comentarios
CLEAR wa_cabecera.
wa_cabecera-tdobject = c_ekko. "Objeto en tabla TTXID
wa_cabecera-tdname = v_pedido. "Nro de pedido
wa_cabecera-tdid = c_a05. "ID en tabla TTXID
wa_cabecera-tdspras = sy-langu. "Lenguaje
wa_cabecera-tdlinesize = 70.
ENDIF.
lwa_control-noendlines = c_x.
lwa_control-scrollend = c_x.
Abre el editor de texto
CALL FUNCTION 'EDIT_TEXT'
EXPORTING
header = wa_cabecera
save = space
control = lwa_control
IMPORTING
newheader = wa_cabecera
function = l_action
RESULT = l_result
TABLES
lines = i_comentarios
EXCEPTIONS
object = 1
id = 2
language = 3
name = 4
linesize = 5.
Si cambio los comentarios, actualiza comentarios
CASE l_action.
WHEN unchanged.
WHEN delete.
WHEN update OR
insert.
Agrega usuario y fecha del comentario
CONCATENATE sy-uname
sy-datum
INTO i_comentarios-tdline
SEPARATED BY space.
i_comentarios-tdformat = '*'.
APPEND i_comentarios.
CALL FUNCTION 'SAVE_TEXT'
EXPORTING
header = wa_cabecera
IMPORTING
newheader = wa_cabecera
TABLES
lines = i_comentarios.
ENDCASE.Murugesh,
I believe that you have mis-read Gabriel's problem.
Gabriel,
The cursor is not positioning at the base of the editor as you have cited.
In order to get this functionality to work, you must set the LINE_EDITOR import paramter to 'X'.
data: hdr like THEAD.
data: l_itced like itced.
hdr-tdobject = 'VBBP'.
hdr-tdname = '4000029521000030'.
hdr-tdid = 'Z005'.
hdr-tdspras = 'E'.
hdr-TDLINESIZE = '100'.
hdr-TDTXTLINES = '3'.
l_itced-SCROLLEND = 'X'.
CALL FUNCTION 'EDIT_TEXT'
EXPORTING
DISPLAY = ' '
EDITOR_TITLE = ' '
HEADER = hdr
PAGE = ' '
WINDOW = ' '
SAVE = 'X'
LINE_EDITOR = 'X' " here !!!
CONTROL = l_itced
PROGRAM = ' '
LOCAL_CAT = ' '
IMPORTING
FUNCTION =
NEWHEADER =
RESULT =
TABLES
LINES = lines
EXCEPTIONS
ID = 1
LANGUAGE = 2
LINESIZE = 3
NAME = 4
OBJECT = 5
TEXTFORMAT = 6
COMMUNICATION = 7
OTHERS = 8
Don't forget those points !! -
How to position the cursor at next item if i choose kod_kat_pkj = '2' then the cursor will go(jump to) to kod_ngra ( state)
Begin
--Job categories
begin
select initcap(nama)
into :lmd_pmk_pkj.kod_kat_pkjn_d
from lmd_ref_kat_kerja
where kod = :lmd_pmk_pkj.kod_kat_pkjn;
exception
when no_data_found then
:lmd_pmk_pkj.kod_kat_pkjn_d := '-Tiada-';
end;
--Worker Categories
begin
select initcap(nama)
into :lmd_pmk_pkj.kod_kat_pkj_d
from lmd_ref_kat_pkj
where kod = :lmd_pmk_pkj.kod_kat_pkj;
exception
when no_data_found then
:lmd_pmk_pkj.kod_kat_pkj_d := '-Tiada-';
end;
--State if imigran
if :lmd_pmk_pkj.kod_kat_pkj = '3' then
begin
select initcap(nama)
into :lmd_pmk_pkj.kod_ngri_d
from lmd_ref_ngri
where kod = :lmd_pmk_pkj.kod_ngri;
exception
when no_data_found then
:lmd_pmk_pkj.kod_ngri_d := '-Tiada-';
end;
end if;
--State
if :lmd_pmk_pkj.kod_kat_pkj = '2' then
begin
select initcap(nama)
into :lmd_pmk_pkj.kod_ngra_d
from lmd_ref_ngra
where kod = :lmd_pmk_pkj.kod_ngra;
exception
when no_data_found then
:lmd_pmk_pkj.kod_ngra_d := '-Tiada-';
end;
end if;
exception
when others then
call_alert('e_alt01','POST_QUERY LMD_PMK_PKJ : '||dbms_error_text);
End;Post-Text-Item
if :lmd_pmk_pkj.kod_kat_pkj = '2' then
go_item('lmd_pmk_pkj.kod_ngra');
elsif :lmd_pmk_pkj.kod_kat_pkj = '3' then
go_item('lmd_pmk_pkj.kod_ngri');
else
go_item('lmd_pmk_pkj.bil_pkj_l');
end if;
But why when i choose 2, the cursor not jump to next item kod_ngra. -
Populate a REF CURSOR from regular cursor...
Hi all,
I apologize if the answer to this is somewhere...I've been looking on the web for sometime and can't find an answer to the following problem. I have a Significant Events database that contains network based issues and problems. As problems are detected on the network an SE is issued and published. As the SE records are updated, NEW records are entered into the table and "linked" back to the original. Each update results in a new row. Thus, an SE with two updates would have a total of 3 lines. When the SE gets closed (set the column CLOSED to SYSDATE), only the "original" SE is closed, any updates are left open...aka, the CLOSED column is left null.
That said, I need a way to get the original and/or latest updated SE rows from the table. Thus, I am trying to use a PL/SQL package. The PL/SQL "must" return a REF CURSOR as the results are being passed to a client process.
My initial approach was within a PL/SQL procedure, I have an SQL statement that returns the SE originals. Once in that cursor I need to do the following:
- Attempt to fetch any linked SE rows.
- if no rows then
- add the original to the REF CURSOR.
- else
- find latest SE update
- add latest SE update to REF CURSOR.
- end if
My Question is : How do I manually "add" a row to a REF CURSOR?
If this is not possible, is there a way to populate a REF CURSOR from maybe another construct like:
TYPE ian_se_record is RECORD (
se_id number
,linked_se_id number
,submitted date
,updated date
,closed date
,segroup varchar2(150)
,incident_start_time varchar2(150)
,business_units_affected varchar2(150)
,officenum varchar2(1500)
,sedetails varchar2(4000)
TYPE ian_se_table is table of ian_se_record index by binary_integer;
With the above construct I could:
- Fill ian_se_table with the process described above.
- And finally select off ian_se_table into the REF CURSOR?
Any help would be greatly appreciated,
adymHi michaels,
I've put your solution in place, but can't seem to get it to run. The two types were moved out of the package and into real types as you said. Here's the function, for brevity, I've remove some of the less important code:
function ian_se_fetch return sys_refcursor
is
p_csr_events sys_refcursor;
cursor csr_items is
select
se_id
...removed for brevity...
/* END : csr_items */
ian_se_row ian_se_record;
ian_se_tbl ian_se_table;
l_lng_index number;
l_lng_linked number;
l_lng_id number;
begin
* OPEN : Open the main cursor of originals...
for the_item in csr_items loop
* CHECK : Check for any updates to the original...
l_lng_linked := 0;
select count(*)
into l_lng_linked
from sig_se_t src
where src.linked_se_id = the_item.se_id;
l_lng_id := 0; /* reset the se-id */
/* SE original...no linked records yet. */
if ( l_lng_linked = 0 ) then
l_lng_id := the_item.se_id;
/* SE updates...one or more updates are present. */
else
begin
select
se_id
into l_lng_id
from sig_se_t src
where src.linked_se_id = the_item.se_id
and rownum = 1
order by updated desc; /* latest update */
exception
when too_many_rows then
l_lng_id := the_item.se_id;
when others then
l_lng_id := 0;
end;
end if;
if ( l_lng_id != 0 ) then
select
se_id
,linked_se_id
,submitted
,updated
,closed
,segroup
,incident_start_time
,business_units_affected
,officenum || decode( nvl(impact,'1')
,'1',''
,decode(impact
,'NA', ''
,':' || impact
) impact
,sedetails
into ian_se_row.se_id
,ian_se_row.linked_se_id
,ian_se_row.submitted
,ian_se_row.updated
,ian_se_row.closed
,ian_se_row.segroup
,ian_se_row.incident_start_time
,ian_se_row.business_units_affected
,ian_se_row.officenum
,ian_se_row.sedetails
from sig_se_t src
where src.se_id = l_lng_id;
l_lng_index := nvl(ian_se_tbl.last,0)+1;
ian_se_tbl(l_lng_index).se_id := ian_se_row.se_id;
ian_se_tbl(l_lng_index).linked_se_id := ian_se_row.linked_se_id;
ian_se_tbl(l_lng_index).submitted := ian_se_row.submitted;
ian_se_tbl(l_lng_index).updated := ian_se_row.updated;
ian_se_tbl(l_lng_index).closed := ian_se_row.closed;
ian_se_tbl(l_lng_index).segroup := ian_se_row.segroup;
ian_se_tbl(l_lng_index).incident_start_time := ian_se_row.incident_start_time;
ian_se_tbl(l_lng_index).business_units_affected := ian_se_row.business_units_affected;
ian_se_tbl(l_lng_index).officenum := ian_se_row.officenum;
ian_se_tbl(l_lng_index).sedetails := ian_se_row.sedetails;
end if;
end loop;
* REF CURSOR : Open the ref cursor on the dataset...
if ( nvl(ian_se_tbl.last,0) = 0 ) then
p_csr_events := null;
else
open p_csr_events for
select *
from table (cast ( ian_se_tbl as ian_se_table ));
end if;
return p_csr_events;
end;Here's the test. I keep getting the same error ORA-06530:
SQL> variable v refcursor;
SQL> exec :v:=pkg_ian.ian_se_fetch;
BEGIN :v:=pkg_ian.ian_se_fetch; END;
ERROR at line 1:
ORA-06530: Reference to uninitialized composite
ORA-06512: at "N0002501.PKG_IAN", line 131
ORA-06512: at line 1
SQL> print v
ERROR:
ORA-24338: statement handle not executedOther things I tried:
- The ian_se_fetch() function was a procedure using an in out parameter...same error.
- Wrote a small anonymous block and tried to LOOP/FETCH. Same ORA-06530 error.
P.S. Line 131 of pkg_ian is the SELECT ... INTO ian_se_row.se_id, ...
Any help would be greatly appreciated,
tia,
adym
Message was edited by:
alink -
Vertical Distance of Cursor From Top of Page
I am looking for the display that shows the vertical distance of the cursor from the top edge of the page in inches. In every other word processor that I have used there is a read-out at the bottom of the display that shows the current vertical location of the cursor, in inches, from the top edge of the page. In Microsoft Word this a standard feature. For business applications this is an important feature, yet when I speak to Apple's own experts on the telephone they seem to think
I share Peter's curiosity, particularly since an admittedly cursory examination of an MS Word (Win) screen did not reveal the readout mentioned by redpony, or any other indcation of the position of the 'cursor' or of an inserted and selected graphics object. Did I miss a setting somewhere?
I looked at MS Works, MS Word and OpenOffice.org on Windows and at Pages and NeoOffice on Mac OS X.
On Windows:
MS Works does not include a vertical ruler, and the help files didn't suggest one was available.
Didn't see the readout redpony claimed in MS Word 2007, or any indication on the rulers of the current location of either the cursor (mouse pointer) or the insertion point.
OpenOffice.org didn't indicate the location of either, but did mark the vertical and horizontal location of a selected object on both rulers.
On the iBook:
NeoOffice showed the location of a selected object in the same manner that OpenOffice.org did on the Windows machine. Not surprising, as Neo is developed from OOo.
Pages '09 did not show a vertical ruler (on a word processing document) by default, but did so after a change in Pages > Preferences > Rulers. Like the others, Pages did not show the location of the insertion point or the mouse pointer either on the rulers or through a readout. But Pages DID show the location of an object when the object was clicked. The location of the top, vertical center and bottom of the object were shown with index lines on the vertical ruler (if present), and the corresponding three markers were placed on the horizontal ruler. In addition, Pages presented a numerical readout near the object showing the current x and y coordinates of the object's upper left corner with a precision of two places after the decimal.
Regards,
Barry -
Returning SQL cursor from Stored Procedure
Hi,
I have a query regarding returning sql cursor from stored procedure to java in oracle 11g.
I want to query some data ex: my query returns A, B, C. Also, now I want to query some other data ex: D, E, F. Now I want to return this data as an sql cursor as a single row . Example: A,B,C,D,E,F. Is it possible to return/create a cursor in stored procedure?
assume both query returns equal number of rows.. however both are not related to each other..RP wrote:
Hi,
I have a query regarding returning sql cursor from stored procedure to java in oracle 11g.
I want to query some data ex: my query returns A, B, C. Also, now I want to query some other data ex: D, E, F. Now I want to return this data as an sql cursor as a single row . Example: A,B,C,D,E,F. Is it possible to return/create a cursor in stored procedure?
assume both query returns equal number of rows.. however both are not related to each other..It sounds like what you need is a ref cursor.
First thing to remember though is that cursors do not hold any data (see: {thread:id=886365})
In it's simplest form you would be creating a procedure along these lines...
SQL> create or replace procedure get_data(p_sql in varchar2, p_rc out sys_refcursor) is
2 begin
3 open p_rc for p_sql;
4 end;
5 /
Procedure created.
SQL> var rc refcursor;
SQL> exec get_data('select empno, ename, deptno from emp', :rc);
PL/SQL procedure successfully completed.
SQL> print rc;
EMPNO ENAME DEPTNO
7369 SMITH 20
7499 ALLEN 30
7521 WARD 30
7566 JONES 20
7654 MARTIN 30
7698 BLAKE 30
7782 CLARK 10
7788 SCOTT 20
7839 KING 10
7844 TURNER 30
7876 ADAMS 20
7900 JAMES 30
7902 FORD 20
7934 MILLER 10
14 rows selected.
SQL> exec get_data('select deptno, dname from dept', :rc);
PL/SQL procedure successfully completed.
SQL> print rc
DEPTNO DNAME
10 ACCOUNTING
20 RESEARCH
30 SALES
40 OPERATIONS
50 IT SUPPORTWhich takes an SQL statement (as you said that both your queries were unrelated), and returns a ref cursor, and then your Java code would fetch the data using that cursor.
Now, as for getting your rows to columns and combining two queries that do that... something along these lines...
SQL> select * from x;
C
A
B
C
SQL> select * from y;
C
D
E
F
SQL> ed
Wrote file afiedt.buf
1 select x.col1, x.col2, x.col3
2 ,y.col1 as col4
3 ,y.col2 as col5
4 ,y.col3 as col6
5 from (
6 select max(decode(rn,1,col1)) as col1
7 ,max(decode(rn,2,col1)) as col2
8 ,max(decode(rn,3,col1)) as col3
9 from (select col1, rownum rn from (select * from x order by col1))
10 ) x
11 cross join
12 (
13 select max(decode(rn,1,col1)) as col1
14 ,max(decode(rn,2,col1)) as col2
15 ,max(decode(rn,3,col1)) as col3
16 from (select col1, rownum rn from (select * from y order by col1))
17* ) y
SQL> /
C C C C C C
A B C D E F... will do what you ask. For further information about turning rows to columns read the FAQ: {message:id=9360005} -
Hi,
Again, I made a nice coloured picture from a screen capture which summarise the improvements that I would like to make in my form,
Situation:
For an educational purpose, I made this form to simplify the way of recording the data and also to develope the independence of the students.
( I am doing this on a voluntary basis, working extra hours on my free time but I don't really mind because I am learning a lot of things in the same time)
After being tested by the teacher, the student has to record the short date, the lines memorised, his grade, number of mistakes, and his attendance.
I created everything in Word, then converted the file in PDF, then I created all the different fields with Adobe acrobat.
There is in total 4 sheets, there are all similar except the first one in which there is a box with: date started, date finished, total time spent, absences.
Below this box there is a table with 16 lines from (A to P) and 7 columns (Days, Date, From.. to.. , Grade, No. lines memorised, No. Errors, Attendance) ( so this table is present on all the sheets)
Due to the fact that some students need more time than others, and also beacause some text need more time, I estimated a need of 4 sheets at the very most.
I would like to make the following amelioration and automate the inputting of some of the data because I know that some of the students will certainly forget, so to avoid this scenario I am trying to make this form the easiest possible.
screen capture of the form:
screen capture of the form editing, you can see the names of the different fields:
here is the form (only the first page) : http://cjoint.com/12fe/BBotMMgfYIy_memorisation_sheet_sample.pdf
In yellow 00000:
At present, the students has to input the total of absences manually, is there a way ( script) to automate this by initialising the field next to "Absences" at " 0 day" and then everytime that Absent is selected from the COMBO BOX, it add 1 and it is displayed like this: " 1 day" then " 2 days" then " 3 days" etc … (so from what I read I have to initialise a counter a the beginning and then for (i... ) count= count++; something like this...
Furthermore, I need a solution to overcome the possibility that a second sheet may be needed for the same student; therefore I would need the data from the "attendance column" from the second sheet ( and perhaps the 3rd and 4th aswell) to be added on the "absences field" in the first sheet
My idea: everytime that the short date is inputted in the first line (next to A) in the "Date" column of one of the 4 sheets then we check the 16 Combo box of the attendance column in this sheet instead to check 16*4=64 fields fot the 4 sheets in one go?
but I don't know at all how to write it in Javascript. Or perhaps there is a way more easier than that?
Shall I allocate a value for Absent on the “ export value”?
In purple
At present I wrote a simple script which matches the number of lines to the poem selected (Eg. if I select the poem V.Hugo, the number "36" will appear next to Number of lines).
Again I would like the make the life of the students very easy so I would like a script which detects this number “36” on the "From .. to …" column, as soon it is detected (on the first sheet or 2nd or 3rd or 4th) check from the same line if "A / Pass" or "B / Pass" have been selected in the "Grade" column ,if yes the short date inputted on this line will be written on the field next to "Date finished" .
this is a simple example with 36 lines only but somethimes, the students may have to memorise 80 lines and more, this is the reason for having 4 sheets in total.
So basically I would like to automate the field next to" Date finished:" with a script that collect the short date from the day in which the student has finished his memorisation with "A / Pass" or "B / Pass"
As for the "Total time spent" George Johnson helped me with a script that calculate the difference betwen date started and date finished (thank you)
I am sollicting your help, because after trying for hours I was really confused with the different if/else needed. And in top of that, it’s my first experience with Javascript.
I anticipate your assistance, thanking you in advance.I found this for counting the absences, its give you the total that's perfect, but is there a better methode which avoid me to write all the fields name, more simple????
( I found the idea here : Re: Total number added automatically )
// custom calculation script for field "Total #"
function CountFields(aFields) {
var nFields = 0;
for(i = 0; i < aFields.length; i++) {
try {
// count null values, export value of Absence is 0;
if(this.getField(aFields[i]).value == "0") nFields++;
} catch(e) {
if(e['message'] == "this.getField(aFields[i]) has no properties") app.alert("unknown field name: " + aFields[i]);
else app.alert(e.toString());
} // end catch
} // end for aFields
return nFields;
// create array of field names to count
var aNames = new Array("Sheet1AttendanceA","Sheet1AttendanceB","Sheet1AttendanceC","Sheet1AttendanceD","Sh eet1AttendanceE","Sheet1AttendanceF",
"Sheet1AttendanceG","Sheet1AttendanceH","Sheet1AttendanceI","Sheet1AttendanceJ","Sheet1Att endanceK","Sheet1AttendanceL",
"Sheet1AttendanceM","Sheet1AttendanceN","Sheet1AttendanceO","Sheet1AttendanceP" );
// count the non-null fields;
event.value = CountFields(aNames);
As for the 2nd question, I've tried to do something similar to the previous script, but of course it doesn't work, but I am quite sure that the idea is similar:
I don't know also how to add the other condition: the student should get A / Pass or B / Pass in order to consider he has finished??? and also how to check these condition from page 2, 3 and 4 and collect the date
function Datefinished(bFields) {
d2.value = nFields[i].value;
for(i = 0; i < aFields.length; i++) {
try {
if(this.getField(aFields[i]).value == this.getField("NumberLines").value) d2.value = nFields[i].value;
} catch(e) {
if(e['message'] == "this.getField(aFields[i]) has no properties") app.alert("unknown field name: " + aFields[i]);
else app.alert(e.toString());
} // end catch
} // end for aFields
return nFields;
// create array of field names to check
var aNames = new Array("Texte00","Texte54","Texte56","Texte58","Texte60","Texte62","Texte64","Texte66","Te xte68","Texte70","Texte72","Texte74","Texte76","Texte78","Texte80","Texte82");
var bNames = new Array("d1","d3","d4","d5","d6","d7","d8","d9","d10","d11","d12","d13","d14 ","d15","d16","d17"); // d1 is included because in some cases a student can finish in 1 day (short text);
Maybe you are looking for
-
If Number = than then display text from another cell
Hi I'd appreciate it if anyone can help me with this please. I am putting together a gradebook type spreadsheet. I would like to display the text from another cell if the number entered in another cell is greater than or less than a certain number. S
-
Migration of Oracle 7.3.4.2 to Oracle 8i or Oracle 9i
i need a clarification in regard with the migration of Oracle 7.3.4.2 to Oracle 8i or 9i along with the porting of the underlying OS from win NT to Win 2000. can u please eloborate me on the issues which i need to look into (if any).and cud u pls elo
-
Internet question...
I would like to get an ipod touch for Christmas. See, I live in a small town, where iPhone service will not arrive until late 2009...so until then, I would like to get an iPod touch. So... I have a few questions...I do not think there is a wifi "Hots
-
Problem With Uploading IDOC Metadata using IDX2
Hi Experts, While i am uploading IDoc metadata using IDX2 it is showing "I::000" information. Anybody please help me why i am getting this problem?
-
Generating user defined Graph nodes
Can anyone tell me how I can generate a user defined number of Graph.Nodes from the keyboard instead of going through them one at a time please. I have tried to use a for loop but I can't get it to work. Can anyone help. import java.util.Iterator; pu