Dynamic FROM variable

I need to do something like the following in a PL/SQL package:
select from_table
into my_var
from ref_table
where id = 123
select my_text
into my_var2
from :my_var
where id = 456
Basically, I need to be able to retrieve my FROM table via the first select, and then use that retrieved table name (in the my_var variable) in the second select's FROM clause (i.e. a dynamic FROM). However, I am not sure at all if this will even work in a proc, and if so, exactly how to code it. Any help? Thanks in advance.
Tom

Since I don't have your table structures, I just made up a short example on my own:
DECLARE
my_var  VARCHAR2(30);
my_var2 NUMBER;
v_sql   VARCHAR2(255);
BEGIN
SELECT table_name from_table
   INTO my_var
   FROM user_tables ref_table
   WHERE ROWNUM < 2;
--   WHERE id = 123
v_sql := 'SELECT Count(*) FROM ' || my_var;
--  v_sql := 'SELECT my_text FROM ' || my_var || ' WHERE id = 456';
EXECUTE IMMEDIATE v_sql INTO my_var2;
dbms_output.put_line('my_var: ' || my_var || ' my_var2: ' || my_var2);
END;C.
Message was edited by:
cd

Similar Messages

  • Acces dynamic configuration variable (e.g. filename) in ABAP mapping class

    Hi experts
    I am searching for a possibility to acces a dynamic configuration variable (DCV) in an ABAP mapping class. Since I could not find a solution in SDN and other sources, I hope somebody in this forum can help me.
    What I already found is the following code which can be used to set a DCV, but what I would be interested in is how to read a DCV.
    Any help is appreciated.
    Markus
    METHOD if_mapping~execute.
    DATA l_record type mpp_dynamic.
    * copy payload
    result = source.
    * add an adapter specific attribute
    l_record-namespace = 'http://sap.com/xi/XI/System/File'.
    l_record-name = 'FileName'.
    l_record-value = 'test.xml'.
    dynamic_configuration->add_record( l_record ).
    ENDMETHOD.

    Hi Markus,
    you can find everything in my blogs
    /people/michal.krawczyk2/blog/2007/04/26/xipi-throwing-generic-exceptions-from-any-type-of-mapping
    Regards,
    michal

  • Creation of Dynamic Date Variables to be used in WebI reports

    What we are trying to achieve is to create 4 optional filters (Current Day, Current Week, Last Week, Last Month) on 4 different dates which will allow the users to use them in WebI reports.
    When using an optional SAP Customer Exit variable in BEx and creating a Universe on top, the filter becomes mandatory (i.e. the whole Universe is filtered by the SAP Exit, irrespective of whether the filter is used in the WebI report). Even if the filter is flagged as optional at the Universe level, it still behaves as mandatory.
    If each filter becomes mandatory then we'll have to create 16 different Universes (for each optional filter and date combination)! This is not feasible.
    I've seen in other posts that MDX Statements are not currently supported for Universes base on BW and SAP Exit should be utilized.
    So with the existing BO version, is it possible to create optional dynamic date variables or is that a product limitation?
    We are on XI3.1 SP3 FP3.1
    Thanks

    Hi Adam,
    In BEx, I would create this query very easily using the "Amount" key figure twice in my results and restricting each with a different SAP standard out-of-the-box delivered variable. For your reference, the variables in BEx are: 0FPER and 0FYTLFP.
    If I expose these variables in my OLE DB for OLAP query, they are not transfered into the universe, but rather act as filters on the entire universe. I've seen in documentation that only "Ready for Input" variables can be transfered as options into the universe which is not something that I have seen mentioned in this thread.
    >> In the BEx Query you have the option to either make the variable "ready for input" or not. The behavior is the same in Bex or in the Universe / Web Intelligence. "Ready for input" means the user can actually provide an input and without the flag the user can not provide an input. Yes those variables are supported in the Universe.
    Why this is a problem: I can't create separate universes based on potential variable periods that users might want to see. Additionally, many financial reports require concurrent use of these measures in the same report. Also, in reality it's not 2 variables, but dozens.
    >> Which is a decision you make already on the BEx query level. if you decide that the variable is not ready for input then the user can change the timeframe in BEx either.
    Also, I don't have a good way to mimic the standard out-of-the-box functionality given with BEx in BO. If I custom create all my variables in the universe, how do I do a lookup from the system date to the fiscal calendar that is stored on the BW server? In other words, how does BO know which date belongs in which period? (the same would be true with factory calendars for a different functional area).
    >> Variable are created in the BEx query and the Universe will leverage those.
    If you want a dynamic date range then EXIT variable as part of the BEx query - ready for input or not - is the solution.
    regards
    Ingo Hilgefort
    The only work around I can see is to require users to enter the current fiscal period and have the BO reports filter based off that user entered value. This is unfortunate as the entire purpose of SAP Exit variables is to avoid having to require user input at report time.

  • I want to create an HTML table of img maps dynamically from DB retrieves...

    Hi,
    How do I build dynamic HTML code in a function and then populate a HTML region to render it.. (did I say that right?)
    I want to create an HTML table of img maps dynamically from DB retrieves...
    Thank you, Bill

    Vikas and Andy,
    Using Andy's code I'll go further...
    I want to create a function that returns HTML code that has been built dynamically.
    create or replace function "GET_CH_TABLE"
    return VARCHAR2
    is
    HTML_STRING VARCHAR2(2000); -- Create a string variable
    BEGIN
    HTML_STRING:= '<table align="center">' ||chr(10)||
    ' <tr>' ||chr(10)||
    ' <td> TEST ' ||chr(10)||
    ' /td>' ||chr(10)||
    ' /tr>' ||chr(10)||
    ' tr>' ||chr(10)||
    ' td>' ||chr(10)||
    ' a href=https:// ............etc. etc.. building the <TABLE> and <TD> cells having whatever I want... example.. changing the name of an image dependant on something else..
    return HTML_STRING; -- output the string to the region
    --also tried htp.p(HTML_STRING);
    END;
    =====================================
    Building the dynamic HTML is not my problem. It is how to get it into a region and to be read as HTML from a function call...
    I'd like the source of the region to be the returned HTML from a function call to GET_CH_TABLE();
    but it gives error:
    ORA-06550: line 1, column 7: PLS-00221: 'GET_CH_TABLE' is not a procedure or is undefined
    ORA-06550: line 1, column 7: PL/SQL: Statement ignored
    Debug:
    1: begin
    2: GET_CH_TABLE();
    3: end;
    I

  • Dynamic configuration variable lifetime?

    We are migrating from PI 7.1 to PI 731 and one of our applications uses dynamic configuration variable. It is a custom dynamic config variable saved in the first message (IDOC to PI BPM). We have asynch to synch scenario and  send a synchronous message from BPM.
    Once the response is received, the message is sent back from BPM (Second send step). During this message, we have a receiver determination (which uses the previously defined dynamic config variable). When I look at this message in sxmb_moni, I see no 'Dynamic Configuration '  and my receiver determination fails.. This used to work in PI 7.1 before and was curious if something was changed in PI 7.31?
    I had noticed previously that dynamic configuration variable was removed when the logic went in exception processing of the BPM (even in PI 7.1).

    As I had indicated, I was creating a custom dynamic configuration variable (with custom namespace and custom name). It was not a standard...
    Essentially, a short cut to store the variable from input message (which will no longer be available in my response). 

  • OBIEE | Using Dynamic Session Variable in Physical Layer

    Hi All,
    Any idea if we can use Dynamic Session Variables (I think they are also called Repository Variables) in our physical layer. I basically need to set the value of this variable from dashboard when a link is clicked, and then use this in my SELECT query at physical layer so that OBIEE does not pull all the data from the database tables.
    Regards
    Adeel Javed
    Edited by: user10642426 on Apr 6, 2009 2:03 AM

    Christian,
    Thanks for the quick response, ok we have actually moved to a different solution now, we are actually using Direct Database Request because one of our reports is supposed to be accessing direct transactional system i.e. for this report we are using OBIEE as a reporting tool. We are able to do that and even create links between different reports i.e. based on prompt in Report A filter Report B, but the scenario now is that we need to set a presentation variable from Report A when a navigation link gets clicked, because so far according to our knowledge direct SQL only allows presentation variables in its WHERE clause. So, any ideas how can we set a presentation variable when a navigation link is clicked. Thanks.
    Regards
    Adeel Javed
    Edited by: adeeljaved on Apr 6, 2009 11:43 PM

  • Regarding dynamic repository variable

    Hi Experts,
    I have made one dynamic repository variable. this variable calculates start date of week.
    i am using this variable in prompt as default value.
    the problem i am geeting its value is not getting refreshed. it shows static value that i have given in default initializer in
    rpd.i want its value gets changed in every week but it is not changing,its shows always default value that have
    given in rpd.
    Please share any solution to resolve this problem.

    Hi,
    Kindly use the below SQL syntax in the default selection of the dashboard prompt.
    SELECT CASE WHEN 1=0 THEN date_column else TIMESTAMPADD(SQL_TSI_DAY, -0, CURRENT_DATE) END FROM SH
    Regards
    MuRam
    NOTE: Please mention if this resolved your problem/still facing and close the thread.

  • Bizarre CFIF issue with dynamic form variables? Very strange...

    I can't figure out what I'm doing wrong here.  Here's my code.  Issue explained below.
                <cfquery name="reviewconfigloader" datasource="MOLMS">
                SELECT *
                FROM dbo.BaseModel
                WHERE dbo.BaseModel.AccountID = #molmsAccountID# AND.dbo.BaseModel.basemodelActive = 1
                </cfquery>
          <table width="100%" border="0" cellspacing="0" cellpadding="3">
            <cfloop query="reviewconfigloader"><cfif isdefined("form.baseconfig#reviewconfigloader.basemodelID#") AND ("form.baseconfig#reviewconfigloader.basemodelID#") NEQ "" AND ("form.baseconfig#reviewconfigloader.basemodelID#") NEQ 0><cfoutput><tr>
              <td width="40%" bgcolor="##F7F7F7" class="basemodelsub">     #form['baseconfig#reviewconfigloader.basemodelID#']#  #reviewconfigloader.basemodelName# #reviewconfigloader.basemodelSubName#</td>
              <td width="15%" bgcolor="##F7F7F7" class="basemodelsub"><div align="center">x 14 </div></td>
              <td width="15%" bgcolor="##F7F7F7" class="basemodelsub"><div align="center">$486/yr</div></td>
              <td width="15%" bgcolor="##F7F7F7" class="basemodelsub"><div align="center">$1444/yr</div></td>
              <td width="15%" bgcolor="##F7F7F7" class="basemodelsub"><div align="center">$1444/3 yr</div></td>
            </tr></cfoutput></cfif></cfloop>
          </table>
    What I'm doing here is fairly basic.I'm running a query with a number of configs in it...and then creating a loop to output them.  Ultimately, I only want the configurations that didnt have 0 submitted in the form on the previous page.  Each one of the configs in the config query has a dynamic form variable on the previous page with a quantity tied to it.  I am trying to eliminate all quantities past that aren't 0 (or not eliminate, just not show)...as you can see from the cfif statement.
    Here's where it gets weird.  You'll notice I output #form['baseconfig#reviewconfigloader.basemodelID#']#, just for testing, which shows me the quantity as it should.  I ran a test and put in a couple of 1s, 0s, 12s, 6s, etc in the form fields on the previous page.  If this thing worked, it wouldnt show anything for any of the records with their basemodelID value being submitted as 0.  Not the case.  It shows all records.  What is more hilarious is that it outputs perfectly in my test #form['baseconfig#reviewconfigloader.basemodelID#']#, showing the correct numbers entered in the previous form, the 1s, the 0s, etc, tied to each record.  But for whatever reason, the cfif code isn't catching it.
    What's even more bizarre...I replaced the cfif ("form.baseconfig#reviewconfigloader.basemodelID#") NEQ 0 with GT 12 (12 was the highest number that I put in the form) and it still showed all records.  Then I put it in as LT 12 and it showed nothing.  I decided  to take it one step further and put it in for GT 1231243242343 (random massive number), which it still showed all of the records.  So somehow, my CFIF statement thinks that  ("form.baseconfig#reviewconfigloader.basemodelID#") is a incredibly large number, although when I output it in the row below, it is the number it should be.
    I'm stumped.  Any ideas?  Thanks in advance!!

    Hey Dan...thanks....unfortunately...with the cfif testing, thats kinda what I'm
    doing because I dont have an "expected" value.  My expected value is anything a user inputs thats greater than zero, hence NEQ 0 and NEQ "". The real problem is taht what I'm outputting works and what the cfif clause is seeing is obviously very different.
    As far as your comment about looping out the variables and then setting a query equal to the value in a cfquery, remember...these are form objects and therefore nothing can be tied back to the database.  The result from the code is establishing a form variable (example.... form.basemodel1 (if 1 was the basemodelID from the database query) so it can capture whatever data the user has passed from the previous page in a text input.  So that input could have been 23, it could have been 1053.
    So really the only way to do it is create a query and loop out the variables.... and attach them to form objects (basemodel1, basemodel2, basemodel3 etc where the 1,2 and 3 are the unique ID's for those models in the database), and then look for where those form objects may have been filled in in the previous page by stating IF this form object not equal to 0 or "", output the data.
    Does that make sense?  Thanks for the help guys I'm completely stumped by this.  I've done this a million times with CFIF and I'm really struggling with why this isnt working....
    JE    

  • Multiple dynamic repository variable using one initialization block

    I am trying to declare three dynamic repository variables var1, var2, var3. I want to have only one intialization block for all three.
    The point I am confused at is when declaring vraibles, I can normally do
    select x, y, z from table where expr1=expr2
    and then x, y, z can give values to my three variables.
    But in the above case the query is selecting three different things (different columns) from the same row in the database.
    But in my case I want to select the same column from different rows.
    for example
    var1 will be
    select x from table where expr1=expr2
    var2
    select x from table where expr1=expr3
    and var 3
    select x from table where expr1=expr4
    1. Is it possible to do that.
    2. Is it possible to dynamically name a dynamic repository varibale?
    I use OBIEE-11g
    Thank you
    Edited by: user6287828 on Jan 26, 2012 9:41 AM

    Hi,
    I think the primary advantage of WITH clause is to resolve complex sub queries (I am sorry, I am mistaken here). But as per my readings and the BI Server too generating queries using WITH clauses, I think this is an optimized option to choose from in your case (I think there might be other queries too that can get your requirement solved though).
    You may want to refer to http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:524736300346304074 for some info. The database experts say the usage is case-by-case and hence probably in your case if you want to populate 20 variables at one shot you in BI using this kind of query, you have to further evaluate the time taken by the sql etc or break it down again.
    However, I think this certainly is an option here.
    Hope this helps.
    Thank you,
    Dhar

  • Email notification from Dynamic 'From' address

    Hi,
    Can we send emails using Email activity from a dynamic 'From' address? i.e. based on value of a BPEL variable?
    I have tried this but always taking from the default From account defined in the Workflow Notification Properties under SOA-Infra-> SOA Admin in Eneterprise Manager.
    All receipients (To, cc, Bcc) are working fine as dynamic. but not this 'From'.
    Please let me know if we can't send email from a dynamic From Address?
    Regards,
    Sam
    Edited by: Sam on Mar 13, 2012 5:58 AM

    Sam,
    I don't think we can do that.
    I have tried it in the latest version too, but there is no scope to send any email dynamically.
    The only thing we can do is chande manually, else tweak the WebLogic portal Java Api and get it changed.
    Later one is a bit complex.
    Thanks,
    TIrumala Dixit.

  • Dynamic Set Variable

    I am having a peculiar issue with the Set function. See the following code.
    In a workflow I'm performing this code and yet it seems as though the user object is not actually ever modified.
    <set name='resourcename'>
    <s>server1</s>
    </set>
    <set name='attributename'>
    <s>firstname</s>
    </set>
    <set name='fqname'>
    <concat>
    <s>user.accounts[</s>
    <ref>resourcename</ref>
    <s>].</s>
    <ref>attributename</ref>
    </concat>
    </set>
    <set>
    <ref>fqname</ref>
    <s>testvalue</s>
    </set>
    When I trace <ref>user.accounts[server1].firstname</ref> it returns testvalue correctly but when I check in the view it never updates the resource and does not show in the WFTrace. I'm thinking somehow that this user object is never truly updated. Anyone know of a better way to do this dynamically generated variable name?

    When you check out the view are you assigning a Form?
    The firstname attribute appears in the default user form and will be mapped from the global namespace. This can cause unexpected issues.
    While you may not be directly using the form, if one is not assigned... it will use the default.
    Create a completely empty form called myEmptyForm and add the variable Form to the checkout view with the value myEmptyForm.
    David

  • Dynamically set variable to pass to foreach loop and exec web service inputs

    Hi, I'm a little lost (and new) on where to begin with this. Using SSIS 2008 r2 I've been able to create a small package to connect to a currency converter web service and
    select the hardcoded supplied by a web service. However, doing it this way I would have to create multiple mini sequence containers and select the currency to and from country codes. I would like to create a user::to and user::from variable and then run a
    sql task to set the variables. 
    Ie, select distinct( [to_countryCD], [from_CountryCD] ) from tbl_CountryCd
    and then run my sequence as a forloop dynamically passing the 'to' and 'from' country codes. Any idea's would really be appreciated.

    First you have to save the result of 
    select distinct( [to_countryCD], [from_CountryCD] ) from tbl_CountryCd
    into object variable. This result set will be fed to For each loop container (FELC). Inside FELC, if you need to iterate through this result set, you will have either use the input parameter method of passing the values to the exec sql task (which is inside
    FELC) or build dynamic expression using SqlStatementSource property.
    http://blog.boxedbits.com/archives/34
    http://www.toadworld.com/platforms/sql-server/b/weblog/archive/2013/01/17/ssis-replace-dynamic-sql-with-variables.aspx
    Thanks, hsbal

  • Currency Translation not working with "Time Reference from Variable"

    We have created several Currency Translations using RSCUR with a fixed "Key Date".  All have been working fine until we got the request to allow a variable date for the exchange rate date.  I have built a variable on 0DATE which I am putting a default date value into using user exit.  This default date is the SAME date as the fixed "Key Date" which we have been using.  Unfortunately when we use the "Time Reference from Variable" option and use this new variable, no currency conversion is taking place, instead it only shows the original currency values.  I am 100% sure that my variable is getting a value and it is the same date we are using for the fixed "Key Date" value so both methods should be using the exact same exchange rates.  The documentation that I can find states:
    ●      Time reference: The time reference for the currency translation can be either fixed or variable.
    If the time reference is fixed, the time at which the exchange rate is determined is independent of the data. You have the following options:
    ○       You can establish that the time reference be determined upon translation.
    ○       You can select the current date.
    ○       You can specify a fixed date as the key date.
    ○       You can specify any variable that exists for InfoObject 0DATE.
    ○       You can establish that the query key date be used. This is determined in the query settings.
    In my case I am only switching from option "You can specify a fixed date as the key date"=(Key Date) to "You can specify any variable that exists for InfoObject 0DATE"=(Time Reference from Variable).
    What am I missing?  Any help is appreciated.

    I neglected to mention that we are calling this currency translation through a WAD button using the SET_CURRENCY_TRANSLATION command.  I did do a test by applying the currency conversion within query key figure.  This seems to work.  So it appears the issue is with how the WAD is processing the variable, not the query.  When I display the variable in a drop down item within the WAD it does have the default value that I have assigned in user exit.

  • What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?

    Hi All,
    I am new to TestStand. Still in the process of learning it.
    What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?
    Thanks in advance,
    LaVIEWan
    Solved!
    Go to Solution.

    Hi,
    Using the Parameters is the correct method to pass data into and out of a sub sequence. You assign your data to be passed into or out of a Sequence when you are in the Edit Sequence Call dialog and in the Sequence Parameter list.
    Regards
    Ray Farmer

  • How to get images dynamically from database without file paths in the table field

    I have a MS-Access database. I am working with ASP.NET. In the database there is product table in which I have "CodeNo" as a field which is a text field, and the product codes like "SM-R-2035". I also have another field "Image" which is also a text field and which have a file path in it corresponding to the particular product Image (e.g. Images\Products\SM-R-2035.jpg). So far every thing is ok. I have to update this site very frequently and lots of images are added each and every time. Its a tedious work to type the paths and file name every time and it also take a lot of time.
    What I am asking is : Is it possible to get images from a specific folder at runtime which is referenced by the "code no" itself and not the file path from the database. (Say at run time the "code no" is referenced from the database and the corresponding image is loaded dynamically from the specified folder). In other word I want to avoid the tedious work of typing.
    Can any one help with this issue. Any other simple suggestions are welcome.

    All you need to do is simple concatenation to obtain the path for the image file.  You didn't mention whether you are using VB.Net, C# or some other language to do your coding.
    If the code in your database is SM-R-2035, the file name is SM-R-2035.jpg and the path to the images foilder is Images\Products\SM-R-2035.jpg, Conceptually here is what you need to do:
    dim code_var
    dim path_var
    code_var = the code you obtain from your relevant field in the database
    path_var = "Images\Products\" & code_var & ".jpg"
    Now path_var is what you would call to obtain the image from your images folder.

Maybe you are looking for