Changing a dynamic variable to static while runtime
How can I change a variable to be static runtime?
I have a defined variable but I can't put data into it after a few calculations, but when I have put data into it I want to make sure that the data doesn't get overwritten. Is this possible?
GTH
Kinda, but not quite what I meant. I'll try to give a
rough code example:
public class Foo {
int notToBeChanged;
public Foo (int Bar) {
notToBeChanged = bar * bar;
// From here on it shall not be possible to change
ge what's in notToBeChanged
public void Bar () {
notToBeChanged = 5 // Illegal!!
Of course this is easily overcome by just being
careful about how I code this. But what I'm worried
about is that when someone else will come to do
maintenance on my code that they won't be so careful.
Heck, they won't even know that I don't want that
variable changed.You can't change a variable to be static. Given what you've said, I don't think that is what you want. You can make a class immutable by not providing any capability to change the variables (no mutator methods).
As far as protecting your code from other programmers who inherit it when they get the responsibility to maintain it ... you can't. Document your intent, and hope they are intelligent enough to read and understand.
� {�
Similar Messages
-
How do I make dynamic text look static while the HMTL tagging is enabled?
Hi all,
I am using flash 8 with AS 2.0.
I have a dynamic text field where I am setting it's text value through a variable. Now, I need this dynamic text field content to look like static font on runtime. I tried embedding the text field but that makes my file so heavy and most importantly, it disables the HTML tagging on the text field.
Please suggest me on how to make a dynamic text field content look static on runtime while the HTML tagging is enabled and working fine.
Thanks.I am sorry. But the attachment was not intended for what you
thought my friend.
It was there so that there are no confusions for what I mean by look of dynamic and static text fields. -
Change name of variable addressed programatically while looping
I am creating a vi which has to set up 24 channels of instrumentation with five different values for each channel. I need to pass these values as variables to other stages of the vi.
Is there a way to have the same basic variable name with a channel appended and then during the course of looping through all the channels address this variable with one object whose name changes on each loop.
For example, I create InstrumentNameCh0 through InstrumentNameCh23 as variables, is there a way for the loop to output to InstrumentNameCh"i" where "i" is the loop count.
Otherwise, I have to create 24 parallel structures differening only by name.Thanks Matt!
Don't know if it is getting close to the original query or not. Here is an image to go with my pvious outline for the AE.
Ben
Message Edited by Ben on 03-13-2009 02:34 PM
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction
Attachments:
AE.PNG 89 KB -
VM NIC keeps changing from Dynamic to Static IP (from a static IP pool)
Back ground:
Having migrated our VM's from 2008R2 and 2012SP1 servers into one 4 node 2012R2 Hyper V Cluster we have a problem with NIC's being changed to Static IP, this in turn gives a range of warning and errors when
moving VM's between the nodes (example during a live migrate or when we put a node in maintenance mode).
The cluster share a Logical Switch, this switch has 1 Uplink. The uplink is a Port Profile called "TrunkPort" and it contains lots of network sites. Each network site links to a Logical Network, each Logical Network is basically a VLAN on our Cisco
router/switch.
We don't have any IP Pools configured since we assign all VM's a static IP manually or they use DHCP provided by our AD servers.
When we change a NIC to from Static IP to Dynamic (there might be power shell to do this), bit in the GUI its painfull as you have to shutdown the VM remove the adapter and create a new one. I does not last long as the system after a few minutes changes
the NIC configuration back to Static IP again. Any idea why and how to stop it?
example of errors after a migration that completed w/ Info :
Error (23801)
No available connection to selected VM Network can be found.
Recommended Action
Ensure host NICs have connection to the fabric network on which VM Network is created.
Error (23810)
There is no host NIC with required classification.
Recommended Action
Ensure that there NICs with required classification on a host.
Error (23806)
All available ports on switch extension has been used.
Recommended Action
Ensure there are free ports available on a switch extension.
Error (23808)
All available ports on port profile has been used.
Recommended Action
Ensure that there are free ports available on a port profile.
Error (23807)
The switch extension has reached maximum supported ports on this host.
Recommended Action
Ensure there are free ports available on a switch extension per host.
Error (23809)
The port profile has reached maximum supported ports on this host.
Recommended Action
Ensure that there are free ports available on a port profile per host.
Error (23825)
The virtual machine requires a logical switch connection and the host network adapter is not attached to a logical switch or operating system doesn't support logical switch.
Recommended Action
Ensure operating system supports logical switch and there is a logical switch connection for the host or remove the network interface card from the virtual machine and try the operation again.
Error (23753)
The virtual machine or tier load balancer configuration requires an IP pool and there are no appropriate IP pools accessible from the host.
Recommended Action
Select a host with access to an appropriate IP pool and try the operation again.
Warning (23830)
Unable to find compliant logical switch.
Recommended Action
Fix logical switch compliance state.
Note: a server configured with Dynamic NIC will move between nodes without any errors (nice green tick box icon), our problem is that SCVMM or the servers deside to reconfigure the NIC's to Static IP when ever they see fit!!I feel like some issue with the Fabric configuration.
If you are create a new VM through SCVMM, do you face this issue? (While creating the new VM, on the hardware configuration page, use dynamic IP and Dynamic MAC)
The first event which you listed says about missing VM Network.
No available connection to selected VM Network can be found.
Please check the VM Network to where the VM is connected through SCVMM. And check if all the nodes have the same VM Network.
If thats missing, fixing it might fix few other errors which you mentioned.
Optimism is the faith that leads to achievement. Nothing can be done without hope and confidence.
InsideVirtualization.com -
How to change the dynamic IP address to Static IP Address in Solaris 10X86
Hi,
I have installed Solaris 10X86 in a VM.While installing Solaris I have enabled DHCP.So its created with dynamic IP Address.Now I want to change the dynamic IP address to static IP address.Please anyone can help me to sort out this problem.Hi,
I have installed Solaris 10X86 in a VM.While installing Solaris I have enabled DHCP.So its created with dynamic IP Address.Now I want to change the dynamic IP address to static IP address.Please anyone can help me to sort out this problem. -
Change the image in the statice adobe forms dynamically based on condition.
Hi Experts,
Could you please explain how to change the image dynamically in the static adobe forms based on certain condition/calculation.
Thanks in Advance.One of the very few options you have is loading them all into the form as embedded images, and then dynamically making the visible and hidden depending on your conditions.
Dynamic loading of images (from a URL or remote location) was completely removed from Interactive Forms a while ago as it was deemed insecure. (and it is)
The second option is loading them all into your SAP system and then making a webservice which you call with a trigger to return you the binary form of the image, which you can read by creating the correct type in the Context.
Kind regards,
Frederik-Jan. -
While trying to change a BOM with transaction CS02, a runtime error appears
While trying to change a BOM with transaction CS02, a runtime error appears.
In intial screen he entered material ,plant BOM usage and date valid from after executed then id displayed item list in that he wantu2019s delete one item, he has been deleted selected item after that when he was saving he is getting runtime error
Developer trace
ABAP Program SAPLKED1_WRITE_CE4_BPS1 .
Source LKED1_WRITE_CE4_BPS1U01 Line 30.
Error Code SAPSQL_ARRAY_INSERT_DUPREC.
Module $Id: //bas/640_REL/src/krn/runt/absapsql.c#17 $ SAP.
Function HandleRsqlErrors Line 775.
RABAX: level LEV_RX_STDERR completed.
RABAX: level LEV_RX_RFC_ERROR entered.
RABAX: level LEV_RX_RFC_ERROR completed.
RABAX: level LEV_RX_RFC_CLOSE entered.
RABAX: level LEV_RX_RFC_CLOSE completed.
RABAX: level LEV_RX_IMC_ERROR entered.
RABAX: level LEV_RX_IMC_ERROR completed.
RABAX: level LEV_RX_DATASET_CLOSE entered.
RABAX: level LEV_RX_DATASET_CLOSE completed.
RABAX: level LEV_RX_RESET_SHMLOCKS entered.
RABAX: level LEV_RX_RESET_SHMLOCKS completed.
RABAX: level LEV_RX_ERROR_SAVE entered.
RABAX: level LEV_RX_ERROR_SAVE completed.
RABAX: level LEV_RX_ERROR_TPDA entered.
RABAX: level LEV_RX_ERROR_TPDA completed.
RABAX: level LEV_RX_PXA_RELEASE_RUDI entered.
RABAX: level LEV_RX_PXA_RELEASE_RUDI completed.
RABAX: level LEV_RX_LIVE_CACHE_CLEANUP entered.
RABAX: level LEV_RX_LIVE_CACHE_CLEANUP completed.
RABAX: level LEV_RX_END entered.
RABAX: level LEV_RX_END completed.
RABAX: end RX_RFC
In sm21
Perform rollback
Run-time error "SAPSQL_ARRAY_INSERT_DUPREC" occurred
Short dump "090618 110101 donalda 11557 " generated
Runtime Error SAPSQL_ARRAY_INSERT_DUPREC
Exception CX_SY_OPEN_SQL_DB
Occurred on 18.06.2009 at 11:01:01
The ABAP/4 Open SQL array insert results in duplicate database records.
What happened?
Error in ABAP application program.
The current ABAP program "SAPLKED1_WRITE_CE4_BPS1" had to be terminated because
one of the
statements could not be executed.
This is probably due to an error in the ABAP program.
What can you do?
Print out the error message (using the "Print" function)
and make a note of the actions and input that caused the
error.
To resolve the problem, contact your SAP system administrator.
You can use transaction ST22 (ABAP Dump Analysis) to view and administer
termination messages, especially those beyond their normal deletion
date.
Error analysis
An exception occurred. This exception is dealt with in more detail below
. The exception, which is assigned to the class 'CX_SY_OPEN_SQL_DB', was
neither
caught nor passed along using a RAISING clause, in the procedure
"RKE_WRITE_CE4__BPS1" "(FUNCTION)"
Since the caller of the procedure could not have expected this exception
to occur, the running program was terminated.
The reason for the exception is:
If you use an ABAP/4 Open SQL array insert to insert a record in
the database and that record already exists with the same key,
this results in a termination.
(With an ABAP/4 Open SQL single record insert in the same error
situation, processing does not terminate, but SY-SUBRC is set to 4.)
How to correct the error
The exception must either be prevented, caught within the procedure
"RKE_WRITE_CE4__BPS1"
"(FUNCTION)", or declared in the procedure's RAISING clause.
To prevent the exception, note the following:
Use an ABAP/4 Open SQL array insert only if you are sure that none of
the records passed already exists in the database.
You may able to find an interim solution to the problem
in the SAP note system. If you have access to the note system yourself,
use the following search criteria:
"SAPSQL_ARRAY_INSERT_DUPREC" CX_SY_OPEN_SQL_DBC
"SAPLKED1_WRITE_CE4_BPS1" or "LKED1_WRITE_CE4_BPS1U01"
"RKE_WRITE_CE4__BPS1"
If you cannot solve the problem yourself, please send the
following documents to SAP:
1. A hard copy print describing the problem.
To obtain this, select the "Print" function on the current screen.
2. A suitable hardcopy prinout of the system log.
To obtain this, call the system log with Transaction SM21
and select the "Print" function to print out the relevant
part.
3. If the programs are your own programs or modified SAP programs,
supply the source code.
To do this, you can either use the "PRINT" command in the editor or
print the programs using the report RSINCL00.
4. Details regarding the conditions under which the error occurred
or which actions and input led to the error.Hi ,
you are getting beacuse u are trying to do mass update to database.
Please check that below note are applicable to your system.
Note 453313 - DBIF_RSQL_ERROR_INTERNAL for mass insert
Note 869534 - AFS MRP doesn't work properly with all BOM item categories
Thanks Rishi Abrol -
Is it possible to change memory size while runtime?
Hi!
Is it possible to set the Xmx value while runtime?
I try to do something like this java Myclass -Xmx128mBut only in a dynamically way while my application is running.
I'm developing an image-rendering - extension for an existing app and there's no chance to edit thejava XYZ statement.
I don't think that's possible, but If anyone has an idea....
Thanks!Yes. Both RAM and the hard drive are easily accessible and replaceable. The warranty is not voided because both are considered DIY. However, if you damage the computer in the process then your warranty will not cover that damage. But it is not voided.
-
How to (if possible) change the measfilename variable at runtime
Hello / Hallo (in Deutsch unten)
Is it possible to change the measfilename at runtime? I have two HBM MGC+ which need a pretty long time to initialize. Both are installed in a car. For each measurement we make I must run the DAC scheme make the measurements an stop it. Then ich change the filename for the data and we make the next measurements. This takes a lot of time.
I want to start run the DAC scheme for only one time and let it run. Then I want to trigger the measurements with buttons setting triggerconditions in the DAC scheme. To trigger the recording of the data is not the problem but how can I change the measfilename variable at runtime so that each new measurement is saved in a new file?
The example with the GenFileName function is interesting but not the solution for my problem...
has anyone an idea?
Thanks a lot.
Sebastian
DEUTSCH:
Hallo,
kennt einer eine Möglichkeit die Variable MeasFileName bei laufender Messung zu verändern? Ich möchte die Messung starten... das Abspeichern geschieht über Triggerbedingungen die von Button im DAC Plan während der Messung gesteuert werden. Ziel wäre für jede neu getriggerte Messung je eine neue Datei mit einem neuen (in der Laufzeit eingebbaren) Dateinamen anzulegen.
Hat das oder ähnliches schonmal einer gemacht und kann sachdienliche Hinweise abgeben ?
Danke schonmal.
Grüße SebastianHallo,
ich habe noch ein wenig herumprobiert aber es klappt nicht so richtig. Ich habe noch folgendes versucht: Daten ins Datenportal ablegen und immer nach Ende einer einzelnen Messung per Button eine Autosequenz aufrufen die die Daten in eine Datei schreibt (Dateiname über Dialogfeld eingebbar). Das klappt auch... nur wenn ich dann in der Autoseq. den Datenbereich komplett lösche (DATADELALL) und eine neue Messsequenz starten will stürzt das Messprog. mit Runtimeerror ab. Irgendwie kommt der vermutlich nicht klar damit, dass der Messwertzähler während der Laufzeit wieder auf 0 gesetzt werden muss.
Eine fortlaufende Speicherung mit anschließender Sortierung wollte ich auch schon machen aber bei fast 200 Messkanälen mit 800Hz häufen sich einfach soviele Daten an, dass die Messdatei riesig werden würde.
Grüße Sebastian -
Can I create a dynamic number of inputs during runtime?
Can I create a dynamic number of inputs during runtime?
Oracle 11g
Application Express 4.0.2.00.06
Here is my problem:
We have a table that holds metadata about files (hardcopy or softcopy files).
We expect we may need more columns in the table at some point and don't want to modify the table or the application.
So in order to do this I would like to create:
A table called TBL_FILE with the columns:
TBL_FILE_ID NUMBER (This will be the primary key)
TBL_FILE_NAME VARCHAR2(1000) (This will be the name of the file)
A second table will be called TBL_FILE_META with the columns:
TBL_META_ID NUMBER (This will be the primary key)
TBL_FILE_ID NUMBER (This will be the forign key to the file table)
TBL_META_COLUMN VARCHAR2(30) (This is what the column name would be if it existed in TBL_FILE)
TBL_META_VALUE VARCHAR2(1000) (This is the value that record and the 'would be' column)
So a person can have as much meta data on the file with out having to add columns to the table.
The problem is how can I allow users to add as much data as they like with out having to re develop the page.
Other things to note is that we would like this to be on a single page.
I know how to add we can create multi-row inserts by using a SQL Query (updateable report),
however the TBL_META_VALUE column in the TBL_FILE_META will sometimes be a select list and other times a text box or number field.
So I don't see now a SQL Query (updateable report) would work for this and I can't create an array of page items at run time can I?
Any idea's how I could accomplish this? Is there a better way of doing this?
Also is there a term or a name for what I am doing by creating these 'virtual' columns in another table?
I found this method when looking at Oracles Workflow tables.Welcome to the Oracle Forums !
>
Can I create a dynamic number of inputs during runtime?
Oracle 11g
Application Express 4.0.2.00.06
Here is my problem:
We have a table that holds metadata about files (hardcopy or softcopy files).
We expect we may need more columns in the table at some point and don't want to modify the table or the application.
So in order to do this I would like to create:
A table called TBL_FILE with the columns:
TBL_FILE_ID NUMBER (This will be the primary key)
TBL_FILE_NAME VARCHAR2(1000) (This will be the name of the file)
A second table will be called TBL_FILE_META with the columns:
TBL_META_ID NUMBER (This will be the primary key)
TBL_FILE_ID NUMBER (This will be the forign key to the file table)
TBL_META_COLUMN VARCHAR2(30) (This is what the column name would be if it existed in TBL_FILE)
TBL_META_VALUE VARCHAR2(1000) (This is the value that record and the 'would be' column)
So a person can have as much meta data on the file with out having to add columns to the table.
The problem is how can I allow users to add as much data as they like with out having to re develop the page.
>
Creating Page Items dynamically is not available. You will have to create excess items and hide/show , etc. But you cannot change the Item Type. All in all, too many limitations in this approach.
>
Other things to note is that we would like this to be on a single page.
>
The 100 item limit will hit you if you go with extra item on page. With Tabular Form that should not be a limitation, unless you are exceeding the 50 item limit of APEX_APPLICATION.G_Fnn items, and the 60 column limitation of Report region with "Use Generic Column Names (parse query at runtime only)" of Dynamic region.
>
I know how to add we can create multi-row inserts by using a SQL Query (updateable report),
however the TBL_META_VALUE column in the TBL_FILE_META will sometimes be a select list and other times a text box or number field.
>
If the type if item is variable it only means you need a way to store the item type. Meta Data of the Meta Data.
>
So I don't see now a SQL Query (updateable report) would work for this and I can't create an array of page items at run time can I?
>
Yes, you can do it. Updatable report/ Tabular Form query can be constructed from the Meta Data using PL/SQL Function Returning SQL Query . It will be a bit of coding in PL/SQL where you use the Meta Data and the Meta Data of the Meta Data to piece together your SELECT with the right APEX_ITEMs. It might have a performance penalty associated with it, but will not be a serious degradation.
>
Any idea's how I could accomplish this? Is there a better way of doing this?
Also is there a term or a name for what I am doing by creating these 'virtual' columns in another table?
I found this method when looking at Oracles Workflow tables.
>
I guess that is just a good TNF. It is the Master-Detail Design Pattern, that sound more modern ? ;)
Regards, -
WEB Application / Dynamic variable input / Prompts
I've defined a variable on characteristic Currency with the following definition:
Processing by : User Entry/ Default Value
Variable represents : Single Value
Variable entry is : Optional
Ready for input : yes
Can be changed in query nav: yes
Default Value : EUR
This variable ist used in "Currency Translation" as "Target currency" (variables entry: yes)
The query is used in a Web-Report that performs the following command by selecting currencies from a checkbox:
url=SAP_BW_URL_Get() +"&CMD=PROCESS_VARIABLES&SUBCMD=VAR_SUBMIT&VAR_NAME_1=SL_CURR&VAR_VALUE_EXT_1=";
url=url+value;
(value is the code of the selected currency)
Everything works pretty good, but opening the web-report I get a prompt window for the variable. How can I avoid this ?
Changing the variable property <Ready for input : no> causes the effect that the dynamically changing of the variable doesn't work anymore. It seems that in this case always the default value of the variable is taken.
The application should use the default value while opening the report, afterwards it should be possible to set the variable dynamically.
Thank you very much for your ideas !!Hi Stefan,
you can activate/deactivate the variable screen with parameter "Force Variable Screen" in your web template.
bye -
Dynamic variable names and invalid_character_err
I'm neither an expert at structure notation nor dynamic
variable naming conventions and would appreciate any help with the
following. Thanks!
This code works fine.
<cfset idx="123">
<cfset form.product[idx]=StructNew()>
<cfparam name="form.product[idx].product_nm"
default="Raspberry Jam">
<cfform name="data_entry" method="post" format="flash"
height="525" width="675" action="formdump.cfm">
<cfformgroup type="tabnavigator" height="400"
width="650">
<cfformgroup type="page" label="Product #idx#">
<cfinput name="static_form_name" type="text"
label="Product" value="#form.product[idx].product_nm#" height="350"
width="600" readonly="yes">
</cfformgroup>
</cfformgroup>
</cfform>
The following code results in the following error:
"ORG.W3C.DOM.DOMEXCEPTION ERROR. Message: INVALID_CHARACTER_ERR: An
invalid or illegal XML character is specified." The only change is
in the "name" attribute of the <cfinput> tag:
<cfset idx="123">
<cfset form.product[idx]=StructNew()>
<cfparam name="form.product[idx].product_nm"
default="Raspberry Jam">
<cfform name="data_entry" method="post" format="flash"
height="525" width="675" action="formdump.cfm">
<cfformgroup type="tabnavigator" height="400"
width="650">
<cfformgroup type="page" label="Product #idx#">
<!--- Change value of name attribute from
"static_form_name" to "product[idx].product_nm" --->
<cfinput name="product[idx].product_nm" type="text"
label="Product" value="#form.product[idx].product_nm#" height="350"
width="600" readonly="yes">
</cfformgroup>
</cfformgroup>
</cfform>
Pam Grieger
[email protected]Thanks for the info. Knowing what WON’T work is
helpful!
Here’s what I’m trying to do. I’m rewriting
one of my apps, switching out conventional HTML form controls for
<cfform> controls in Flash format. Many of the existing forms
in my app are for updating data contained in a central database.
When such a form is rendered to the screen, each form control is
pre-populated with existing data. All form controls are named
dynamically based upon the unique ID of the record being updated.
Here’s a streamlined but typical example:
<!--- User selected projects 14, 15, 16, and 17 for
update. Get existing project data. --->
<cfquery name="get_project_detail"
datasource="#application.DataSource#">
SELECT project_oid_nbr, project_nm
FROM project_table
WHERE project_oid_nbr IN (14,15,16,17)
ORDER BY project_oid_nbr
</cfquery>
<!--- Initialize the project_nm form control. Form names
are dynamic, based upon get_project_detail.project_oid_nbr. --->
<cfloop query="get_project_detail">
<cfparam name="form.project_nm_#project_oid_nbr#"
default="#get_project_detail.project_nm#">
</cfloop>
<!--- Create HTML form control. --->
<table>
<cfloop query="get_project_detail">
<tr>
<td>
<cfoutput>
Project #project_oid_nbr#:
<input type="text" name="project_nm_#project_oid_nbr#"
value="#Evaluate("form.project_nm_#project_oid_nbr#")#">
</cfoutput>
</td>
</tr>
</cfloop>
</table>
This has been working just fine. However, I’m wondering
if using the Evaluate() function is the most efficient way to go.
Therefore I wanted to use structure notation to avoid the
Evaluate() function, but as mentioned in my original post, this
naming convention won’t work with <cfform> tags.
Any suggestions as to the most efficient way to get the same
result while still using <cfform> tags? Thanks so much! -
Hi
I am writing a procedure in which i get the schema name only as input parameter at run time.
for e.g.:
v_id sys.dba_users.username%type;
In the above datatype declaration, SYS is the schema name, dba_users is the table name and username is the column.
What if i do not know the schema name up front, is there a way for me to have dynamic declaration?
p_schema VARCHAR2(30) := 'SYS';
v_id dba_users.username%type; -- how can i associate this with p_schema
Is it even possible?The bigger picture is this. The same set of tables is copied to new schema once every few months. The tables data structure does not change except for the schema it belongs to. So i have to write a code which will accept the schema name as input parameter and retrieve data from the right tables.
My question is if there is a way to dynamically specify a schema while declaring variables.
how can i get the equivalent of v_id sys.dba_users.username%type if schema name 'SYS' is not known upfront.
If i get to to schema name 'SYS' at run time like below:
p_schema VARCHAR2(30) := 'SYS';
v_id dba_users.username%type; -- how can i associate this with p_schema
If dynamic declaration is not at all possible, i can always declare my variables as follows:
v_id VARCHAR2(30);
Thanks everyone for your answers though. -
How to generate report with dynamic variable number of columns?
How to generate report with dynamic variable number of columns?
I need to generate a report with varying column names (state names) as follows:
SELECT AK, AL, AR,... FROM States ;
I get these column names from the result of another query.
In order to clarify my question, Please consider following table:
CREATE TABLE TIME_PERIODS (
PERIOD VARCHAR2 (50) PRIMARY KEY
CREATE TABLE STATE_INCOME (
NAME VARCHAR2 (2),
PERIOD VARCHAR2 (50) REFERENCES TIME_PERIODS (PERIOD) ,
INCOME NUMBER (12, 2)
I like to generate a report as follows:
AK CA DE FL ...
PERIOD1 1222.23 2423.20 232.33 345.21
PERIOD2
PERIOD3
Total 433242.23 56744.34 8872.21 2324.23 ...
The TIME_PERIODS.Period and State.Name could change dynamically.
So I can't specify the state name in Select query like
SELECT AK, AL, AR,... FROM
What is the best way to generate this report?SQL> -- test tables and test data:
SQL> CREATE TABLE states
2 (state VARCHAR2 (2))
3 /
Table created.
SQL> INSERT INTO states
2 VALUES ('AK')
3 /
1 row created.
SQL> INSERT INTO states
2 VALUES ('AL')
3 /
1 row created.
SQL> INSERT INTO states
2 VALUES ('AR')
3 /
1 row created.
SQL> INSERT INTO states
2 VALUES ('CA')
3 /
1 row created.
SQL> INSERT INTO states
2 VALUES ('DE')
3 /
1 row created.
SQL> INSERT INTO states
2 VALUES ('FL')
3 /
1 row created.
SQL> CREATE TABLE TIME_PERIODS
2 (PERIOD VARCHAR2 (50) PRIMARY KEY)
3 /
Table created.
SQL> INSERT INTO time_periods
2 VALUES ('PERIOD1')
3 /
1 row created.
SQL> INSERT INTO time_periods
2 VALUES ('PERIOD2')
3 /
1 row created.
SQL> INSERT INTO time_periods
2 VALUES ('PERIOD3')
3 /
1 row created.
SQL> INSERT INTO time_periods
2 VALUES ('PERIOD4')
3 /
1 row created.
SQL> CREATE TABLE STATE_INCOME
2 (NAME VARCHAR2 (2),
3 PERIOD VARCHAR2 (50) REFERENCES TIME_PERIODS (PERIOD),
4 INCOME NUMBER (12, 2))
5 /
Table created.
SQL> INSERT INTO state_income
2 VALUES ('AK', 'PERIOD1', 1222.23)
3 /
1 row created.
SQL> INSERT INTO state_income
2 VALUES ('CA', 'PERIOD1', 2423.20)
3 /
1 row created.
SQL> INSERT INTO state_income
2 VALUES ('DE', 'PERIOD1', 232.33)
3 /
1 row created.
SQL> INSERT INTO state_income
2 VALUES ('FL', 'PERIOD1', 345.21)
3 /
1 row created.
SQL> -- the basic query:
SQL> SELECT SUBSTR (time_periods.period, 1, 10) period,
2 SUM (DECODE (name, 'AK', income)) "AK",
3 SUM (DECODE (name, 'CA', income)) "CA",
4 SUM (DECODE (name, 'DE', income)) "DE",
5 SUM (DECODE (name, 'FL', income)) "FL"
6 FROM state_income, time_periods
7 WHERE time_periods.period = state_income.period (+)
8 AND time_periods.period IN ('PERIOD1','PERIOD2','PERIOD3')
9 GROUP BY ROLLUP (time_periods.period)
10 /
PERIOD AK CA DE FL
PERIOD1 1222.23 2423.2 232.33 345.21
PERIOD2
PERIOD3
1222.23 2423.2 232.33 345.21
SQL> -- package that dynamically executes the query
SQL> -- given variable numbers and values
SQL> -- of states and periods:
SQL> CREATE OR REPLACE PACKAGE package_name
2 AS
3 TYPE cursor_type IS REF CURSOR;
4 PROCEDURE procedure_name
5 (p_periods IN VARCHAR2,
6 p_states IN VARCHAR2,
7 cursor_name IN OUT cursor_type);
8 END package_name;
9 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY package_name
2 AS
3 PROCEDURE procedure_name
4 (p_periods IN VARCHAR2,
5 p_states IN VARCHAR2,
6 cursor_name IN OUT cursor_type)
7 IS
8 v_periods VARCHAR2 (1000);
9 v_sql VARCHAR2 (4000);
10 v_states VARCHAR2 (1000) := p_states;
11 BEGIN
12 v_periods := REPLACE (p_periods, ',', ''',''');
13 v_sql := 'SELECT SUBSTR(time_periods.period,1,10) period';
14 WHILE LENGTH (v_states) > 1
15 LOOP
16 v_sql := v_sql
17 || ',SUM(DECODE(name,'''
18 || SUBSTR (v_states,1,2) || ''',income)) "' || SUBSTR (v_states,1,2)
19 || '"';
20 v_states := LTRIM (SUBSTR (v_states, 3), ',');
21 END LOOP;
22 v_sql := v_sql
23 || 'FROM state_income, time_periods
24 WHERE time_periods.period = state_income.period (+)
25 AND time_periods.period IN (''' || v_periods || ''')
26 GROUP BY ROLLUP (time_periods.period)';
27 OPEN cursor_name FOR v_sql;
28 END procedure_name;
29 END package_name;
30 /
Package body created.
SQL> -- sample executions from SQL:
SQL> VARIABLE g_ref REFCURSOR
SQL> EXEC package_name.procedure_name ('PERIOD1,PERIOD2,PERIOD3','AK,CA,DE,FL', :g_ref)
PL/SQL procedure successfully completed.
SQL> PRINT g_ref
PERIOD AK CA DE FL
PERIOD1 1222.23 2423.2 232.33 345.21
PERIOD2
PERIOD3
1222.23 2423.2 232.33 345.21
SQL> EXEC package_name.procedure_name ('PERIOD1,PERIOD2','AK,AL,AR', :g_ref)
PL/SQL procedure successfully completed.
SQL> PRINT g_ref
PERIOD AK AL AR
PERIOD1 1222.23
PERIOD2
1222.23
SQL> -- sample execution from PL/SQL block
SQL> -- using parameters derived from processing
SQL> -- cursors containing results of other queries:
SQL> DECLARE
2 CURSOR c_period
3 IS
4 SELECT period
5 FROM time_periods;
6 v_periods VARCHAR2 (1000);
7 v_delimiter VARCHAR2 (1) := NULL;
8 CURSOR c_states
9 IS
10 SELECT state
11 FROM states;
12 v_states VARCHAR2 (1000);
13 BEGIN
14 FOR r_period IN c_period
15 LOOP
16 v_periods := v_periods || v_delimiter || r_period.period;
17 v_delimiter := ',';
18 END LOOP;
19 v_delimiter := NULL;
20 FOR r_states IN c_states
21 LOOP
22 v_states := v_states || v_delimiter || r_states.state;
23 v_delimiter := ',';
24 END LOOP;
25 package_name.procedure_name (v_periods, v_states, :g_ref);
26 END;
27 /
PL/SQL procedure successfully completed.
SQL> PRINT g_ref
PERIOD AK AL AR CA DE FL
PERIOD1 1222.23 2423.2 232.33 345.21
PERIOD2
PERIOD3
PERIOD4
1222.23 2423.2 232.33 345.21 -
How to Make SelectedItem be a Dynamic Variable?
Hi,
My client wanted me to create something that allows certain
DataGrid to display to allow users to edit and update the database
records. The only dilemma I am having here is how to actually
create something from Flex's end to allow users update several rows
of the database at once. Since everything in my HTTPService is in
DataGrid, how can I get Flex to recognize each of the updated
variables while I update the database? I tried using dg.
.id in my code, but I kept getting errors that say it is not
defined. Is there some way where I can make selectedItem be a
dynamic variable?
Thanks in advance.
Alice
This is the current code I have:
Attach Code:
<mx:HTTPService id="save_scenario" method="POST" url="
http://localhost/save_scenario.php"
useProxy="false">
<mx:request xmlns="">
<scenario_name>{scenario_name}</scenario_name>
<id_no>{dg.selectedItem.id}</id_no>
<region_name>{dg.selectedItem.region_name}</region_name>
<population>{dg.selectedItem.population}</population>
<market>{dg.selectedItem.market}</market>
</mx:request>
</mx:HTTPService>"alice_data" <[email protected]> wrote in
message
news:ggen1o$a3c$[email protected]..
> Hi,
>
> My client wanted me to create something that allows
certain DataGrid to
> display to allow users to edit and update the database
records. The only
> dilemma I am having here is how to actually create
something from Flex's
> end to
> allow users update several rows of the database at once.
Since everything
> in my
> datagrid would be defined as selectedItem whenever a
user accesses the
> entry,
> how can I get Flex to recognize each of the updated
variables while I
> update
> the database?
Add like an updated property to each item in the collection.
Then set it
when the user has changed something. Then filter the
collection to items
that have been updated and send them to the server.
Maybe you are looking for
-
IMovie quits unexpectedly whenever I try to finalize
I receive the error message below. After searching other threads, I've tried a number of unsuccessful strategies. I've updated all the software, tried the same task as a different user, deleted recommended preference files. At this point, I'm not s
-
Cannot load a FAx driver for a Hp Laserjet 1536dnf MFP on a HP Pavilion Elite e9220y Computer
I cannot find a fax driver for this printer to install on my computer. I have uninstalled and reinstalled the printer a couple of times It will print and scan but not fax. I reinstalled fron the orignal disk and off the HP website neither get me fax
-
ITunes cannot connect to the store, connection was refused
I have used iTunes and the same iPod successfully for 2 years. A few days ago, I attempted to purchase a song in the iTunes store and it said I had to upgrade to iTunes 7.5 first. I did that and my library and songlists are fine but it says I can't c
-
Can't mount hard drive icons on desktop
Hello, Just partitioned a friend's new iMac running Snow leopard. Noticed before starting that the 1Tb drive wasn't showing on the desktop, but nor are the two new partitions, even though Disk Utility seems to be showing them as mounted. I've never s
-
Calling Oracle Application Form From Table Action (Single Select)
Can I call a Oracle Application Form From a Table (Table Select, Select Button). I also See Destination Function Could That Be Used to Launch Oracle Application Form Using One of the Columns Data (Service Request ID to Launch Service Requests Form) L