Can i generate dynamic variables
hi guys
can we generate varibles in a plsql block dynamically ..viz i have some varibles in the data base that are entered by the user and the values are to be calculated at the run time based on some of those varible eg
in database
code formula (varchar2)
a --
b a/2
c b-a*6
etc..
so the problem is to calculate them at run time say based on a (in the above eg).
so scract ur head a little and ....enjoy
You cannot create a table inside a trigger (unless you use an autonomous transaction) since that invloves DDL. Are you certain that you cannot use something like a global temporary table?
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC
Similar Messages
-
I'm kinda new to JSP, and have the following question:
is it possible to generate dynamic variables in JSP? I searched the WWW, and it seems nobody ever used it. Or I just searched wrong :)
So:
String result = "";
for(int i = 1; i <= 10; i++){
result = "test" + i;
// do something with result here
I would like that the string "result" becomes a variable: test1, test2, test3, ...
I know it is possible in PHP like this:
for($i=1; $i<=$10; $i++){
$result = ${"test".$i};
// here I can do something with the generated variables $test1, $test2, $test3, ...
Does anyone got a solution for this problem? Cause it's driving me crazy ;)I tried, but I keep getting error's... Anything wrong?
import java.awt.event.*;
import java.awt.*;
import java.util.*;
import java.util.Map;
public class AwtCalculatorFrame extends Frame{
private Button[] btnCalc;
private Panel pnlLabel;
private String[][] btnArrRow;
private Label lblRes;
private Panel[] pnlBtnRow;
public AwtCalculatorFrame(String titel) {
super(titel);
MaakLayout();
ToonFrame();
private void ToonFrame() {
setSize(250, 250);
Dimension d = getToolkit().getScreenSize();
setLocation((d.width - getSize().width) / 2, (d.height - getSize().height) / 2);
addWindowListener(new AwtCalculatorListeners());
setVisible(true);
private void MaakLayout(){
setBackground(new Color(224, 224, 224));
setLayout(new GridLayout(6, 1, 5, 5));
pnlLabel = new Panel(new GridLayout(1, 1, 5, 5));
String[][] btnArrRow = new String[5][5];
btnArrRow[0][0] = "Sin";
btnArrRow[0][1] = "Cos";
btnArrRow[0][2] = "Tan";
btnArrRow[0][3] = "C";
btnArrRow[0][4] = "CA";
btnArrRow[1][0] = "7";
btnArrRow[1][1] = "8";
btnArrRow[1][2] = "9";
btnArrRow[1][3] = "Sqrt";
btnArrRow[1][4] = "Pow";
btnArrRow[2][0] = "4";
btnArrRow[2][1] = "5";
btnArrRow[2][2] = "6";
btnArrRow[2][3] = "x";
btnArrRow[2][4] = "/";
btnArrRow[3][0] = "1";
btnArrRow[3][1] = "2";
btnArrRow[3][2] = "3";
btnArrRow[3][3] = "+";
btnArrRow[3][4] = "-";
btnArrRow[4][0] = "+/-";
btnArrRow[4][1] = "0";
btnArrRow[4][2] = ".";
btnArrRow[4][3] = "Pi";
btnArrRow[4][4] = "=";
Label lblRes = new Label("0.");
add(pnlLabel);
Button[] btnCalc = new Button[btnArrRow.length];
for(int c = 0; c < btnArrRow.length; c++){
pnlBtnRow[c] = new Panel(new GridLayout(1, 5, 5, 5));
for(int i = 0; i < btnArrRow.length; i++){
btnCalc[i] = new Button(btnArrRow[c]);
pnlBtnRow[c].add(btnCalc[i]);
add(pnlBtnRow[i]); -
Can we generate Dynamic fields in HANA
Hi Frzz,
I have a requirement, in which i need to generate the fieds based on the value set dynamically. Is it possible in HANA with scripted Calculation view??
Please guide.
Best Regards,
Krishna.Hello Krishna,
If i understood your problem
Your data looks like this
ActualField
SuperiorField
1
2
1
3
1
4
2
5
2
6
2
7
3
8
3
9
3
your output needs to look like this:
Level 1
Level 2
Level 3
1
2
4
3
5
6
7
8
9
if so, dynamic sql might seem a good option.
My experience suggest there may be a better way...
For Starters ... check out
Window Functions - SQL Reference - SAP Library
Let me know if you see a way forward...or any problems as i am sure there is more to your use case that you cannot reveal on an open forum...So tell me the problem you face if you try it using Window functions.
Warm regards
aadi -
Okay, I just need to figure out how to make dynamic variable
names. In this case, I have a loop, and inside the loop I need to
create a new array for every iteration of the loop. Something like
<cfloop from="0" to="10" index="i">
<cfset LoopArray#i# = Some Value>
</cfloop>
But that doesn't work. How can you make dynamic variable
named? I think it's probably something to do with evaluate or DE,
but I don't know how to use them, and the livedocs make no sense to
me. Thanks!On Thu, 22 May 2008 17:14:42 +0000 (UTC), kenji776 wrote:
> Thank you both for your replied, I did manage to find a
solution (the same one
> posted by JR "Bob" Dobbs). Pretty much just looks
like...
>
>
> <cfloop from="1" to="3" index="i">
> <cfset LinkResults["#i#"][1] = "Player 1's Move
ID">
> <cfset LinkResults["#i#"][2] = "Player 2's Move
ID">
> <cfset LinkResults["#i#"][3] = "Damage to player
1">
> <cfset LinkResults["#i#"][4] = "Damage to player
2">
> </cfloop>
From your values, you don't want a two-dimensional array
(which although
you're actually building LinkResults as a struct, with the
sequential
numeric keys, it's basically an array), you want an array of
structs, eg:
LinkResults
.player1.moveId
LinkResults.player1.damage
What is "i" actually counting through? IE: from 1-3 things...
which are...
what?
Adam -
Hi experts,
How can i declare Dynamic variable under loop,
I have Data from CABN Table with Char Name /Data type/Length.
Is there any function module or method where i provide the parameters for declaration.
thanks.DATA r_elemdescr TYPE REF TO cl_abap_elemdescr.
r_elemdescr ?= cl_abap_elemdescr=>describe_by_name( 'DATA_ELEMENT_HERE' ).
DATA r_field TYPE REF TO data.
FIELD-SYMBOLS <field> TYPE ANY.
CREATE DATA r_field TYPE HANDLE r_elemdescr.
ASSIGN r_field->* TO <field>.
<field> = .....
"now <field> is your dynamic field value
Regards
Marcin -
How can I refresh Dynamic Variables in OBIEE in a Unix enviroment? and can I only refresh a certain list of them?
hi,
Repository variables will be refreshed by giving refresh interval to initialization block.(Specific time scope)
Session variable will refreshed by the sessions management.(Session scope)
Presentation variables will refresh whenever you have the report to run.(Report scope)
--Shiva -
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 -
using action script 2 how can i send a variable value to a dynamic textbox on a different keyframe?
Thanks for your swift response.
That sounds like a good solution, but the code I have on frame 2 is this
timer = 0;
countup = function(){
timer++;
countupInterval = setInterval(countup,100);
If I added the same actionscript to frame 3 which has a dynamic textbox with a variable timer attached wouldn't it just put the timer back to 0? What I want is the last known value that was given when it was in frame 2.
I am thinking of temple run here, I am trying to caculate the total distance(set in the timer variable) from the previous try.
Hope this makes sense.
Chazwick -
How we can generate dynamic menu in jsp page
Hi all,
how we can generate dynamic menu in jsp page.
Thanks
Manjinderby reading more about them on the web or in a good book, OR BY HIRING SOMEBODY TO DO SO. ;)
-
How to create dynamic variable in Java?
Hi,
I want to create dynamic varible , using ArrayList or Vector. The number of array i dont knwo, so how to create dynamic ArrayList or Vector.
for example:
ArrayList1,ArrayList2,ArrayList3.....n
or
Vector1,Vector2,Vector3 .....n, the n value i will get at run time, so how to create the dynamic ArrayList or Vector or i can use any other Object in java,
Pls provide your input.
Sridhar1. I have a HashMap with dataok ... fair enough.
2. depending on its size, i need to create variable
to store them.uhm ... why? If you have a variable number of elements in the map then you'd need to generate a variable number of variables (a number, that is not know at compile time, as it seems). Now if you could somehow create those variables, how would you access them? You'd have to generate the code handling them as well ...
Tell us what kind of data you've got and what you want to do with it. There's certainly a better solution to your problem.
how to generate variables as per content size of the
HashMapYou don't. -
<p>I have some code with a connect by clause. When I use atext string in the 'start with' part of the statement the codecompiles and runs. When I use the dynamic variable [$folder]I get a compilation error: Error and then code is includedbelow. </p><p> </p><p>(SQR 5528) ORACLE OCIStmtExecute error 1788 in cursor 1:<br>ORA-01788: CONNECT BY clause required in this query block<br>SQL: SELECT level, ro_tree_entry_lbl, ro_childobjtyp_cd from<br>dss.ie_mstr_cat_alph_v<br>Error on line 28:<br>(SQR 3716) Error in SQL statement.<br><br></p><p> </p><p>begin-program<br>columns 2 7 12 17 22 27 32 37 42 47<br>do get_input<br>do main<br>end-program<br><br>begin-procedure main<br>begin-select<br>level &level<br>Move &level to #level<br>use-column #level<br>Print #level (+1) edit 888<br>!lpad(level,2*level -1)||' '||<br>ro_tree_entry_lbl &label (, +2)<br>ro_childobjtyp_cd &child (, +2)<br>from dss.ie_mstr_cat_alph_v<br>start with ro_tree_entry_lbl like [$folder]<br>connect by prior ro_child_tech_nm = ro_parnt_tech_nm<br>end-select<br>end-procedure ! main<br><br>begin-procedure get_input<br>Input $folder<br>Let $folder = '''' || $folder || ''''<br>end-procedure ! get_input<br></p>
Jim - I don't really know, to be honest, but there's clearly a limit to how much APEX can work out at design time about what the query is going to do, especially what columns are going to be generated and how they are going to be presented.
The other problem I've had is that when APEX is able work out what the query is going to do (and generates a set of report attributes to go with it), when the dynamic SQL changes this slightly, the region will break and show an error.
So, for dynamic reports, I would always use the generic option.
John. -
Generating dynamic column in planning layout
Hi Guys,
I am new to BPS.. My task is user inputs calendar year thru variable, based on the year it has generate dynamic columns as month of the year entered by the user.
Dnt know i am right or wrong based on the sdn threads. i think i have to create user input variable, and create a FM to read the user input value. Upto to this i can understand, after reading the user input how to calculate the months and generate 12 columns dynamically for each month...
Kindly help me in this scenario..
Edited by: kevin peterson on Jun 6, 2008 5:23 AMHi,
I hope you are using calendar year/month and calendar year characteristics. Create an user input variable for calendar year,
create one exit variable for calendar year month.
Inside this exit, read the value of the user input variable, append the year with all 12 months, so u get 12values for this exit variable.
Now keep calendar year in header, restricted by user input variable, create one data column dynamic for calendar year month restricted by this exit variable. This will generate 12columns dynamically.
Bindu -
Formula- for generating a variable discount
I need some help string some ifs together in a formula to dynamically generate a number. I'm not sure how to do it.
I have got as far as this.
=IF(H18<=5, 2)
=IF(H18<=20, 10)
=IF(H18<=50, 20)
but not sure how to link them together or refine the number range in the same field. Any help or pointers appreciated.
Graeme
*_+Detail of what i'm trying to do+_*
+I'm trying to create a formula to do the following:+
+Variable 1 - Field A1+
+(Number of units for sale-can be any number- user entered)+
+Variable 2 -Field A2+
+(variable discount % dynamically generated from variable 1)+
+(discount to be applied later in the spreadsheet)+
+So for example+
+1-5 units get 2% discount+
+6-20 units get 10% discount+
+21-50 units get 20% discount+
+And so on...+
+So I assume I want to use the 'if' and that I need to use a string of several ifs. To dynamically generate variable 2. +
+So assume I need to code the following:+
+If A1 is less than or equal to 5 then return '2' to field A2+
Or
+If A1 is more than or equal to 6 and less than or equal to 20 then return '10' to field A2+
Or
+If A1 is more than or equal to 21 and less than or equal to 50 then return '20' to field A2+In this sheet I used two soluces.
In cells of column B I inserted the formula :
=IF(A<=0,0,IF(A<=5,2,IF(A<=20,10,IF(A<=50,20,"and so on"))))
In cells of column C I inserted the formula :
=VLOOKUP(A,look_in :: A:B,2,)
From my point of view it's the best soluce because it's easy to enhance it.
Yvan KOENIG (VALLAURIS, France) mardi 16 mars 2010 21:48:07 -
can we generate one report tab which filters
with each prompt value selected in bobj 4.0 webi report.Hi Shrinidhi ,
It can be achievable with static tabs created for each LOV .But this is not recommended because , object values can change dynamically .
It is good idea to use section on prompt object in the report .With sections great feature available is in larger report it’s easy to navigate using map. It displays the section tree.You can select the particular LOV to navigate. -
How can I generate SSL Keys from a Oracle 9iAS server version 1.0.2.2.0
How can I generate SSL Keys for use on Oracle 9iAS server
version 1.0.2.2.0. I have tried using the open_ssl method but
was unsuccessful.<?xml version="1.0" encoding="UTF-8" ?>
<nodes>
<node>
<category_id>3</category_id>
<parent_id>2</parent_id>
<name>Mobile</name>
<is_active>1</is_active>
<position>1</position>
<level>2</level>
<children>
<node name="Nokia" category_id="6" parent_id="3" is_active="1" position="1" level="3">
<node name="Nokia N79" category_id="7" parent_id="3" is_active="1" position="2" level="3" />
<node name="Nokia N95" category_id="7" parent_id="3" is_active="1" position="2" level="3" />
<node name="Nokia N97" category_id="7" parent_id="3" is_active="1" position="2" level="3" />
</node>
<node name="Samsung" category_id="7" parent_id="3" is_active="1" position="2" level="3">
</node>
</children>
</node>
<node>
<category_id>4</category_id>
<parent_id>2</parent_id>
<name>Laptop</name>
<is_active>1</is_active>
<position>2</position>
<level>2</level>
<children></children>
</node>
<node>
<category_id>5</category_id>
<parent_id>2</parent_id>
<name>Monitor</name>
<is_active>1</is_active>
<position>3</position>
<level>2</level>
<children></children>
</node>
<node>
<category_id>8</category_id>
<parent_id>2</parent_id>
<name>Camera</name>
<is_active>1</is_active>
<position>4</position>
<level>2</level>
<children></children>
</node>
</nodes>
Is this correct format to create dynamic menu?
Maybe you are looking for
-
Why does my Macbook keeps freezing?
I've had my macbook since thanksgiving 2008 and I have added a few programs to it. Nothing major since I am not a heavy computer user. I've noticed over the past several weeks that I can be in the middle of a webpage or a program and the computer sto
-
HT4914 I cannot get Itunes match to work on my iphone? All settings are correct.
I cannont get Itunes match to work on my new iPhone. It works on my IPAD, IPOD and other devices.
-
I have a scenario in a configure to order environment where I want to automatically creating flow schedules based on sales order demand. I have two orgs in same OU. 1. How to setup sales order line to generate flow schedules in the manufacturing org
-
After upgrading ios6 my app color note lost all of my notes
Color not lost all of my notes. Any way to get it back?
-
Reg. developer 6i and 9i, please...
Hi, currently our application is in forms 5.0 nd reports 3.0 so I can not open a report output into a excell sheet, I mean after generating a report, I should be able to save it in a excell sheet. This is a very important feature for Accounts departm