Creating jbutton name dynamically
I am trying to create a Battleship type game. It is a gui with the standard 10x10 grid. I am using JButtons for this. My issue is that originally I was using a loop with a generic name for the JButton like this:
JButton cell = new JButton();
cell.addActionListener(this);
offensePanel.add(cell);This will not work as I am unable to use an action listener on a specific button (because of the generic name: cell). My next thought was to dynamically name the buttons from an arraylist of potential names (A1, B2,...) I cannot seem to make this work either
cells.add(getRow(i).concat(getCol(i)));
JButton cells.get(j) = new JButton();Cells is an arraylist in the above example. Does anyone have any idea on how I might be able to do this or better yet, maybe a better design idea? Thanks.
Thanks for the reply. I will just post the entire code as it is:
package battleship;
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.awt.event.*;
public class BattleshipGUI implements ActionListener{
String[] yAxisLabel = {"A","B","C","D","E","F","G","H","I","J"};
String[] xAxisLabel = {"1","2","3","4","5","6","7","8","9","10"};
ArrayList<String> cells = new ArrayList<String>();
String row;
String col;
int j = 0;
public void buildGUI(){
JFrame theFrame = new JFrame("Battleship");
theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
BorderLayout layout = new BorderLayout();
JPanel background = new JPanel(layout);
background.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
GridLayout grid = new GridLayout(11,11,1,1);
JPanel defensePanel = new JPanel(grid);
JPanel offensePanel = new JPanel(grid);
background.add(BorderLayout.WEST, defensePanel);
background.add(BorderLayout.EAST, offensePanel);
for (int i = 0; i < 121; i++){
if (i == 0){
Label blank = new Label();
defensePanel.add(blank);
continue;
else{
if (i < 11){
Label xCoord = new Label(xAxisLabel[i-1]);
defensePanel.add(xCoord);
else if (i%11 == 0){
Label yCoord = new Label(yAxisLabel[(i/11) - 1]);
defensePanel.add(yCoord);
else{
JButton cell = new JButton();
defensePanel.add(cell);
cell.addActionListener(this);
cells.add(getRow(i).concat(getCol(i)));
JButton cells.get(j) = new JButton(); //----this line
System.out.println(cells.get(j));
j++;
for (int i = 0; i < 121; i++){
if (i == 0){
Label blank = new Label();
offensePanel.add(blank);
continue;
else{
if (i < 11){
Label xCoord = new Label(xAxisLabel[i-1]);
offensePanel.add(xCoord);
else if (i%11 == 0){
Label yCoord = new Label(yAxisLabel[(i/11) - 1]);
offensePanel.add(yCoord);
else{
JButton cell = new JButton();
cell.addActionListener(this);
offensePanel.add(cell);
theFrame.getContentPane().add(background);
theFrame.pack();
theFrame.setVisible(true);
public String getRow(int index){
row = yAxisLabel[((index - (index%11))/11) - 1];
return row;
public String getCol(int index){
col = xAxisLabel[(index%11) - 1];
return col;
public void actionPerformed(ActionEvent ev){
}I have tried a couple of different ways in the above code. (actionPerformed is blank since I couldn't think of a way to make it work) This will compile and run if the marked line is taken out. Again, my idea was to create individual button names dynamically at compile time so that a actionPerformed event could be associated with it. Am I heading in the right direction or should I turn around and rethink what is needed?
Sorry, will compile and run if a main is added:
public static void main(String[] args){
BattleshipGUI ship = new BattleshipGUI();
ship.buildGUI();
}Edited by: sdhalepaska on Sep 27, 2007 4:27 PM
Similar Messages
-
Need example to create File names dynamically using File adapter
hello,
I am mapping an IDOC to a flat file using XI and a file adapter. I need to be able to output a file name dynamically depending on the data in the IDOC. For example if the IDOC has 310 as the company code, the file name should be xyz.310 and if the IDOC has 600 as the company code, the file name created by the file adapter should be xyz.600. Please some body provide me with an example of the XSLT code that I will have to write in the dispatcher User Exit.
Any help will be greatly appreciated.Nope
But you could add a dummy row to your source to include column headers and then use options column headers in first row in flat file connection manager.
So suppose you've three columns column0,coulmn1,column2 and you want to make it as ID,Name,Datethen make source query as
SELECT 'ID' AS Col1,'Name' AS Col2,'Date' AS Col3, 0 AS ord
UNION ALL
SELECT Column1,Column2,Column3,1
FROM YourTable
ORDER BY Ord
then choose column headers in first row option
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How can i create varaible name dynamically?
amx$var$ = value.
this statement is in loop and i want to change variable name in each pass like,
amx11 = value
amx12 = value
Please help me out of this.its urgent.
good answers will be awarded pointsHi Amresh,
Please check the following sample code.
Hope this will surely help you out.
Sample Code:
types: BEGIN OF ty_field,
field TYPE fieldname,
END OF ty_field,
BEGIN OF ty_values,
value TYPE fieldname,
END OF ty_values.
CONSTANTS: c_amx type char3 VALUE 'amx'.
FIELD-SYMBOLS: <fs_val> TYPE ANY.
DATA: l_variable TYPE char2,
l_value TYPE char2,
l_fname TYPE fieldname,
lt_field TYPE STANDARD TABLE OF ty_field,
ls_field TYPE ty_field,
lt_values TYPE STANDARD TABLE OF ty_values,
ls_values TYPE ty_values.
l_value = 1.
DO 20 TIMES.
ls_values-value = l_value.
APPEND ls_values to lt_values.
l_value = l_value + 1.
ENDDO.
l_variable = 01.
LOOP AT lt_values INTO ls_values .
CLEAR: l_fname.
UNASSIGN <fs_val>.
CONCATENATE c_amx l_variable INTO l_fname.
ASSIGN COMPONENT l_fname OF STRUCTURE ls_values-value TO <fs_val>.
l_variable = l_variable + 1.
IF sy-subrc EQ 0.
ls_field-field = <fs_val>.
ENDIF.
WRITE: / l_fname , ls_values-value.
ENDLOOP.
Pls do reward if useful.
Regards,
Farheen.
Edited by: Farheen Fatima on Jan 22, 2008 1:19 PM -
Dynamically creating variable names in javascript
Hi.
I have to create variable names dynamically in JavaScript.
My JSP file accesses information from Database and forms a String corresponding to the information received.
This String is passed to a JAvaScript function that should CREATE a variable with that NAME.
For Ex:
My database access resulted in a single row...
id name sal
34 John Smith 38000
the resulting VARIABLE NAME should be Menu34. 34 comes from the database result.
Is there any function to dynamically create a variable name in JavaScript?
Thanks in advance.The JSP is printing the contents of an HTML page, and Javascript code can be part of that output...
So you would just write out the stuff, something like this....
<script>
<% while(rs.hasNext()) { %>
var Menu<%= rs.getInt("id") %> = '<%= rs.getString("name") %>';
<% } %>
</script>
In the browser, it'll just look like another long list of Javascript variables. -
Create table with dynamic table name.
I'm trying to create a table
like
select x.*, convert(nvarchar(20), getdate(), 101) AS LoadDate
into table1_20140512
from (
select c1,c2,c3 from table2_20140512
WHERE(LoadDate = (select MAX(LoadDate) FROM table2_20140512 )
union all
select c1,c2,c3 from table3_20140512
WHERE(LoadDate = (select MAX(LoadDate) FROM table3_20140512 )
) X
I want to make table name dynamic, like 'table1'+toady's date
I declared three variables, but they didn't work as I expected
These are my variables
DECLARE @table1 nvarchar(500)
DECLARE @table2 nvarchar(500)
DECLARE @table3 nvarchar(500)
SET @table1='H1_' +(CONVERT(VARCHAR(8),GETDATE(),112))
SET @table2='H2_' +(CONVERT(VARCHAR(8),GETDATE(),112))
SET @table2='H3_' +(CONVERT(VARCHAR(8),GETDATE(),112))Try the following:
DECLARE @SQL nvarchar(2000);
DECLARE @table1 nvarchar(500) ='H1_' +(CONVERT(VARCHAR(8),GETDATE(),112));
DECLARE @table2 nvarchar(500) ='H2_' +(CONVERT(VARCHAR(8),GETDATE(),112));
DECLARE @table3 nvarchar(500) ='H3_' +(CONVERT(VARCHAR(8),GETDATE(),112));
PRINT @table1+' '+@table2+' '+@table3;
--H1_20140512 H2_20140512 H3_20140512
SET @SQL = 'select x.*, convert(nvarchar(20), getdate(), 101) AS LoadDate
into '+QUOTENAME(@table1)+'
from (
select c1,c2,c3 from table2_20140512
WHERE(LoadDate = (select MAX(LoadDate) FROM '+QUOTENAME(@table2)+' ))
union all
select c1,c2,c3 from table3_20140512
WHERE(LoadDate = (select MAX(LoadDate) FROM '+QUOTENAME(@table3)+' ))
) X '
PRINT @SQL; -- debugging
/* select x.*, convert(nvarchar(20), getdate(), 101) AS LoadDate
into [H1_20140512]
from (
select c1,c2,c3 from table2_20140512
WHERE(LoadDate = (select MAX(LoadDate) FROM [H2_20140512] ))
union all
select c1,c2,c3 from table3_20140512
WHERE(LoadDate = (select MAX(LoadDate) FROM [H3_20140512] ))
) X
EXEC sp_executeSQL @SQL;
Dynamic SQL examples:
http://www.sqlusa.com/bestpractices/dynamicsql/
Kalman Toth Database & OLAP Architect
SQL Server 2014 Design & Programming
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
Hello,
Can anyone help me out to write a vb.net script.
I need to read the column names from excel and based on that column names I need to create a table in database(I have more than one sheet in excel).
For each sheet columns will be changing and should create a table dynamically for each sheet.
Any help would be appreciated.Refer the below script to read columns in each sheet.
Dim excelfile As String = Dts.Variables("ExcelPath").Value.ToString
Dim connectionstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + excelfile + ";Extended Properties=Excel 8.0"
Dim oledbcon As New OleDb.OleDbConnection(connectionstring)
oledbcon.Open()
Dim dt As DataTable
Dim schemaTable As DataTable
Dim OLEDBCMD As New OleDb.OleDbCommand
Dim oledbdatareader As OleDb.OleDbDataReader
Dim columns As String = ""
dt = oledbcon.GetSchema("Tables")
Dim TABCOMMAND(20) As String
Dim TABCOUNT As Integer = 0
For Each row As DataRow In dt.Rows
TABCOMMAND(TABCOUNT) = "SELECT * FROM [" & row.Item("TABLE_NAME").ToString & "]"
OLEDBCMD.CommandText = TABCOMMAND(TABCOUNT)
OLEDBCMD.Connection = oledbcon
oledbdatareader = OLEDBCMD.ExecuteReader(CommandBehavior.KeyInfo)
schemaTable = oledbdatareader.GetSchemaTable()
For Each myfield As DataRow In schemaTable.Rows
For Each myproperty As DataColumn In schemaTable.Columns
If myproperty.ColumnName = "ColumnName" Then
columns = columns & myfield(myproperty).ToString & ","
MsgBox(myfield(myproperty).ToString)
End If
Next
Next
oledbdatareader.Close()
OLEDBCMD.Dispose()
Next
oledbcon.Close()
Regards, RSingh -
How to pass the table name dynamically in xml parsing
Hi All,
I have created one procedure for parsing xml file which is working perfectly.
FORALL i IN t_tab.first .. t_tab.last
INSERT INTO Test_AP VALUES t_tab(i);Now I want to put the table name dynamically+. For that I have added one query and modify above code as follow:-
I have already declare dml_str varchar2(800) in declaration part.
Query is as follows:-
select table_name into tab_name from VERSION_DETAILS where SUBVERSION_NO=abc; -- here abc is variable name which contains values.
FORALL i IN t_tab.first .. t_tab.last
dml_str := 'INSERT INTO ' || tab_name || ' values :vals';
EXECUTE IMMEDIATE dml_str USING t_tab(i);But it's not working. How I will resolve this or through which way I achieved the intended results. Anyone can guide me on this matter.
Thanks in advance for your help...Hi,
But it's not working.Don't you think it would help to give the error message?
Put the assignment before FORALL.
FORALL only accepts one subsequent DML statement (static or dynamic SQL) :
dml_str := 'INSERT INTO ' || tab_name || ' values :vals';
FORALL i IN t_tab.first .. t_tab.last
EXECUTE IMMEDIATE dml_str USING t_tab(i); -
Execute immediate with using clause to pass column name dynamically
Hai,
Is there any way using execute immeidate to pass the column name dynamically. I used to pass the column value as dynamic with the help of "Using clause" . But if i use to pass column name, it is giving numberic error at run time. Eg,. for testing has been given below.
1. Column value as dynamic, which is working correctly.
create or replace function testexeimm (acctnum char)
return number as
acctbal number;
begin
execute immediate 'select balance from acct_master where acct_no=:a' into acctbal using acctnum;
return acctbal;
end;
2. Column name as dynamic which is not working
create or replace function testexeimm (colnam char)
return char as
acctbal char;
begin
execute immediate 'select :a from ch_acct_mast where rownum=1' into acctbal using colnam;
return acctbal;
end;
Any help in this regard will be highly appericated.
Regards
SridharSo the variable has to be numeric too:
create or replace function testexeimm (colnam char)
return number as
acctbal number;
begin
execute immediate 'select '|||colnam||' from ch_acct_mast where rownum=1' into acctbal;
return acctbal;
end;Max
http://oracleitalia.wordpress.com -
How to create internal table dynamically based on a table entry
hi Experts,
I have table yprod_cat. It has product categories.
In my ABAP program I need to create internal table dynamically based on the number of entries in the table.
For example:
If the table has 3 entries for product category
1. Board
2. Micro
3. Syst
Then create three (3) internal tables.
i_board
i_micro
i_syst
How can we do this? Any sample code will be very usefull
Thanks & Regards
Gopal
Moderator Message: No sample codes can be given. Please search for them or work it!
Edited by: kishan P on Jan 19, 2011 4:22 PMOur APEX version is 4.2We are using below SQL query to display radio groups dynamically..
SELECT APEX_ITEM.RADIOGROUP (1,deptno,'20',dname) dt
FROM dept
ORDER BY 1;
Created a form using SQL type and given abouve SQL query as source.. But when we run the page, there were no radio groups displayed in the page..
Below is the output of the query..
<input type="radio" name="f01" value="10" />ACCOUNTING
<input type="radio" name="f01" value="20" checked="checked" />RESEARCH
<input type="radio" name="f01" value="30" />SALES
<input type="radio" name="f01" value="40" />OPERATIONS
>
If Tabular Form:
Edit Region > Report Attributes > Edit Column > Change the Column type to "Standard Report Column"
If normal Page Item:
Edit Page Item > Security > Escape special characters=No.
Pl read the help on that page item to understand the security risk associated with =NO.
Cheers,
Edited by: Prabodh on Dec 3, 2012 5:59 PM -
How to create some columns dynamically in the report designer depending upon the input selection
Post Author: ekta
CA Forum: Crystal Reports
how to create some columns dynamically in the report designer depending upon the input selection
how export this dynamic report in (pdf , xls,doc and rtf format)
report format is as below:
Element Codes
1
16
14
11
19
10
2
3
Employee nos.
Employee Name
Normal
RDO
WC
Breveavement
LWOP
Sick
Carers leave
AL
O/T 1.5
O/T 2.0
Total Hours
000004
PHAN , Hanh Huynh
68.40
7.60
76.00
000010
I , Jungue
68.40
7.60
2.00
5.00
76.00
000022
GARFINKEL , Hersch
66.30
7.60
2.10
76.00
In the above report first column and the last columns are fixed and the other columns are dynamic depending upon the input selection:
if input selection is Normal and RDO then only 2 columns w'd be created and the other 2 fixed columns.
Can anybody help me how do I design such report....
ThanksHi Developer life,
According to your description that you want to dynamically increase and decrease the numbers of the columns in the table, right?
As Jason A Long mentioned that we can use the matrix to do this and put the year field in the column group, amount fields(Numric values) in the details, add an filter to filter the data base on this column group, but if
the data in the DB not suitable to add to the matrix directly, you can use the unpivot function to turn the column name of year to a single row and then you can add it in the column group.
If there are too many columns in the column group, it will fit the page size automatically and display the extra columns in the next page.
Similar threads with details steps for your reference:
https://social.technet.microsoft.com/Forums/en-US/339965a1-8cca-41d8-83ef-c2548050799a/ssrs-dataset-column-metadata-dynamic-update?forum=sqlreportings
If your still have any problem, please try to provide us more details information, such as the data structure in the DB and the table structure you are currently designing.
Any question, please feel free to let me know.
Best Regards
Vicky Liu -
How to create a Tray dynamically
Hi All
I have tried to develop a method where I can create a tray dynamically. I have embedded this code in the method WDDOINIT of my View called 'MAIN_VIEW'. My longer term plan is to create x number of trays where x is dictated by the number of entires in an Internal Table.
The code I have written compiles, but nothing appears where I thought it would. Can anyone spot what I have so fundementally missed?
Assistance is sincerely appreciated.
Regards
Tony
create object wd_this->all_in_one_util.
data: node_input type REF TO if_wd_context_node,
elem_input TYPE REF TO if_wd_context_element,
stru_input type if_main_view=>element_input.
data: lr_view type ref to cl_wdr_view,
lr_tray type REF TO CL_WD_TRAY,
tray_id type string,
lr_caption type ref to cl_wd_caption,
caption_id type string,
lr_grid_data type ref to cl_wd_grid_data,
lr_grid_layout type ref to cl_wd_grid_layout.
*Navigate from <CONTEXT> to <INPUT> via lead selection
node_input = wd_context->get_child_node( name = if_main_view=>wdctx_input ).
lr_tray = cl_wd_tray=>new_tray(
EXPANDED = ABAP_TRUE
ID = tray_id
VIEW = lr_view "'MAIN_VIEW'
WIDTH = '100%'
set the caption of the tray
concatenate lr_tray->id '_HEADER' into caption_id.
lr_caption = cl_wd_caption=>new_caption(
id = caption_id
text = 'text goes here'
view = lr_view ).
lr_tray->set_header( lr_caption ).
create the grid layout data for tray
lr_grid_data = cl_wd_grid_data=>new_grid_data( lr_tray ).
assign the layout data to the tray
lr_tray->set_layout_data( lr_grid_data ).
create a new grid layout for the content of the tray
lr_grid_layout = cl_wd_grid_layout=>new_grid_layout( lr_tray ).
assign the grid layout to the tray
lr_tray->set_layout( lr_grid_layout ).Hi Tony,
If we have to do any dynamic programming in webdynpro( creating UIelements dynamically ), WDDOMODIFYVIEW is the method where we need to code the logic for creating the tray.
But you have done the coding of creating tray in WDDOINIT thats why it is not working fine. Just the have the same code in WDDODMODIFYVIEW and you need to have below code to add this tray to view's ROOTUICONTAINER.
data: lr_container TYPE REF TO cl_wd_uielement_container.
lr_container ?= view->get_element( 'ROOTUIELEMENTCONTAINER' ).
" View is import parameter of wddomodifyview method.
lr_container->add_child( '' pass the tray that is created ' ).
This is the way to create dynamic UIelements in webdynpro using wddodmodifyview
For more information on dynamic programming have at following information
<a href="http://help.sap.com/saphelp_crm50/helpdata/en/44/2d9a41ed79a009e10000000a155106/frameset.htm">http://help.sap.com/saphelp_crm50/helpdata/en/44/2d9a41ed79a009e10000000a155106/frameset.htm</a>
Thanks,
Prashanth Kumar B -
Creating variable names?
hi all
is it possible to dynamically create variable names so you can keep track of them?
I have to generate the following code a number of times depending on a number the user has input. So ideally Id like to create
variables whose names i can keep track of for later reuse
eg horHatch1, horHatch2.... without hardcoding them in. is this possible?? are there any better ways of accomplishing this task?
this code just draws and adds labels on an x axis.
thanks
Line2D.Double horHatch1 = new Line2D.Double(horAxis.getP1().getX() + horInterval,
horAxis.getP1().getY() - HatchLength/ 2,
horAxis.getP1().getX() + horInterval,
horAxis.getP1().getY() + HatchLength/2);
graphics.draw(horHatch1);hi
i used the following code
but i need to convert Line"d to Line2d.Double as explained below
for(int i=1; i<x+1; i++)
Line2D.Double horHatch1 = new Line2D.Double(horAxis.getP1().getX() + horInterval*i,
horAxis.getP1().getY() - HatchLength/ 2,
horAxis.getP1().getX() + horInterval*i,
horAxis.getP1().getY() + HatchLength/2);
graphics.draw(horHatch1);
v.addElement(horHatch1);
Add text to hatches
decorateVerticalLine(graphics, horHatch1, "M");
decorateVerticalLine(graphics, horHatch2, "T");
decorateVerticalLine(graphics, (Line2D)v.elementAt(i), names.elementAt(nColumn).toString());
//compiler complains that (Line2D)v.elementAt(i) is not of type java.awt.geom.Line2D.Double but of java.awt.geom.Line2Di tried :
horizontalAxisTicks[i] =((Double)(Line2D)v.elementAt(i)).doubleValue()).getX1();
but this isnt correct i dont think.
thanks -
How to create a table dynamically
Hello All,
I want to create a table dynamically in DDIC. I know that there is function module exist DB_CREATE_TABLE but i am getting some errors while using it.
Could any please post some code for it.
Regards,
LisaHere is the code i have writen my self.
PARAMETERS: tabname TYPE dd02l-tabname,
fldname TYPE dd03p-fieldname,
rollname TYPE dd03p-rollname.
DATA: gt_cl_bc_dyn TYPE REF TO zcl_bc_dyn,
status TYPE sy-subrc.
data: lct_table type ZTT_ZTSITAB.
INITIALIZATION.
tabname = 'ZTEST1'.
CREATE OBJECT gt_cl_bc_dyn.
START-OF-SELECTION.
CALL METHOD gt_cl_bc_dyn->create_table
EXPORTING
tabname = tabname
fieldname = fldname
rollname = rollname
itab = lct_table
IMPORTING
status = status .
IF status = 0.
WRITE: 'Table creation is successful'.
ELSE.
WRITE: 'Table creation is unsuccessful'.
ENDIF.
Code in the method
METHOD create_table.
DATA: ls_dd02v_wa TYPE dd02v,
ls_dd09l_wa TYPE dd09l,
ls_dd03p TYPE dd03p,
lt_dd03p TYPE TABLE OF dd03p,
rc TYPE sy-subrc.
ls_dd02v_wa-tabname = tabname.
ls_dd02v_wa-tabclass = 'TRANSP'.
ls_dd02v_wa-contflag = 'A'.
ls_dd09l_wa-tabname = tabname.
ls_dd09l_wa-tabkat = '0'.
ls_dd09l_wa-tabart = 'APPL0'.
ls_dd03p-tabname = tabname.
ls_dd03p-fieldname = fieldname.
ls_dd03p-position = '0001'.
ls_dd03p-keyflag = 'X'.
ls_dd03p-rollname = rollname.
APPEND ls_dd03p TO lt_dd03p.
CALL FUNCTION 'DDIF_TABL_PUT'
EXPORTING
name = tabname
dd02v_wa = ls_dd02v_wa
dd09l_wa = ls_dd09l_wa
TABLES
dd03p_tab = lt_dd03p
EXCEPTIONS
tabl_not_found = 1
name_inconsistent = 2
tabl_inconsistent = 3
put_failure = 4
put_refused = 5
OTHERS = 6
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'DDIF_TABL_ACTIVATE'
EXPORTING
name = tabname
IMPORTING
rc = rc
EXCEPTIONS
not_found = 1
put_failure = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
status = rc.
ENDMETHOD. -
Problem in using table name dynamically in PL/SQL
I tried to create a procedure to use table name dynamically and got the following error. Anything wrong with my procedure?
NFADV>declare
2 cnt number;
3 cursor cur is select table_name from user_tables where table_name in ('EMP','DEPT');
4 begin
5 for c1 in cur
6 loop
7 execute immediate select count(*) into cnt from c1.table_name;
8 dbms_output.put_line('Count is : '||cnt);
9 end loop;
10 end;
11 /
declare
ERROR at line 1:
ORA-06550: line 7, column 21:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + case mod new not null <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall merge time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
<an alternatively-quoted string literal with character set specification>
<an alternatively-quo
ORA-06550: line 8, column 5:
PLS-00103: Encountered the symbol "DBMS_OUTPUT"
ORA-06550: line 8, column 45:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( , * % & - + / at mod remainder rem <an identifier>
<a double-quoted delimited-identifier> <an exponent (**)> as
from into || multiset bulkThanks and Regards
KaustubhHi,
The wrong part is in execute immediate, it should be as follows:
execute immediate ('select count(*) from '|| c1.table_name)
into cnt
(not tested)
Regards
AK -
Getting the column names dynamically
hi gurus,
i have list item populated with many table names from a schema.
i have grid in oracle forms 10g and i want to fill the grid with the data that should come at least four/more columns.
i want to fire the list change trigger when each time any one table name is selected/changed.
how can i get the column names dynamically
please give me the step by step process
for filling the grid..hi ,
by getting column names dynamically i am creating a record group
using this below query
SELECT COLUMN_NAME, DATA_TYPE FROM USER_TAB_COLUMNS WHERE TABLE_NAME = <table_name>
but when timestamp datatype is there then it is showing error cannot create group groupname
but the record group is running successful on varchar2,number,date dayatypes
if any alternative is there i mean to say without using record group then tell me or where is the problem
Maybe you are looking for
-
How can I custom my date in OBIEE.
How can I custom my date in OBIEE.I want to see date in my user friendly format for Date Format MM/DD/YYYY to filter with leading zero(number) eg (01.21.2008) and not M/D/YYYY (1.21.2008) that i am seeing.I would appreciate it if you could give me a
-
My iCloud account has been hacked
I think my iCloud account was hacked this morning. I went to log in and iCloud refused my password was refused and I noticed an email from Apple iCloud in Chinese. I have now reset the password, but just as a heads up to the wider Apple community tha
-
How to return a javascript window.open object
Hi all, I am calling a javascript function to create a window using the External Interface from flex. The function call works and I get a popup window, but I want to return the window.open object that I just created so that I reuse the same window ag
-
Unable to launch adobe flash player
All of a sudden, my computer says that I require adobe flash player. I use windows 7 on internet explorer. I have tried uninstalling and then re-installing without success. When I download flash player, a page comes up saying flash player downloaded
-
Acrobat Pro won't open, how do I restore it?
My Acrobat Pro won't open, how do I restore it?