Persisting variables to global scope (M spec's 'shared' keyword?)

Hi,
I wanted to declare multiple variables I'd like to reuse in a query, and be able to keep them in scope afterwards for use in other queries. The alternative of redeclaring them in each query separately would seem tedious, while individual queries can also
only return one variable each (be it a table/list).
I read in the M formula specification that it should be possible to global-scope a variable using the 'shared' keyword, though apparently this was only for use in the 'sections' part of the M specification unimplemented in Power Query itself. Am I missing
something? Might there be some other way to persist a variable to the shared (global) scope from within a query?

Thank you for the further clarification on sections; I didn't really know they are still kind of there in the background.
Reconsidering, I suppose my perceived issue isn't really so bad. I think what I wanted (using M functions from text files like an external library) is pretty well doable, so I've Github'd (https://github.com/tycho01/pquery) what I have for others to try;
perhaps that may help illustrate my use case a bit. I think I'm actually satisfied now, though I may as well explain better what I was trying.
What I'm imagining (as an analogy to my experience with Excel VBA) is basically having a larger library of user defined M functions to flesh out the built-in ones, with smaller functions for relatively basic tasks, and mid-level functions building upon those
and upon each other.
Considering the (current) effort in adding a bunch of functions to different workbooks, not to mention edit syncing concerns, keeping such all-purpose functions separate from individual workbooks (in analogy to VBA's 'personal' workbook) would seem sensible.
If that were to work out, eventually it may be preferable if things were to 'just work', in terms of all functions being in scope, so each such library function could freely call other such library functions.
At present, if you load multiple functions through Expression.Evaluate(), possible in batch through lists/records as you mentioned, they will all be available in the original scope.
However, with no effective way to pass this around (unless environments?), the loaded functions will not know of each other though. What I do now is to explicitly load used library functions in each function where they are needed. Under this limitation of losing
scope between functions, it might be ideal to have all available functions loaded only once.
Reloading in batch (i.e. load the whole library rather than the parts needed) within every new function scope may become less desirable in terms of unnecessary overhead.
I suppose for the most part my scenario is still largely hypothetical though, so I might as well try and see if the general idea would take off in the PQ community for now. In either case, thank you for your replies.

Similar Messages

  • Final variable with global scope?

    Hi,
    We are building a multi threaded server application. We have the need to use some constants (finals) across mutliple classes/threads. Is there a way to create a list of final vars with a global scope? We've considerd a class with static vars, but that would imply using the classname when using the vars. e.g. GlobalClass.VARNAME. We would like to use just VARNAME. Is there a way to do this?

    Hi,
    Here is the thread that addresses the same issue as yours.
    http://forum.java.sun.com/thread.jsp?forum=4&thread=242988
    Putting all these in an interface and let the classes that uses them implement it will be useful.
    Hope this helped,
    Roopasri Vittal
    Developer Technical Support
    Sun Microsystems
    http://sun.com/developers/support

  • Persistent variable in package

    Hey,
    I am not sure where exactly to ask about this, so if I posted in the wrong forum forgive me.
    My problem is this: I am writing an application which interacts with a remote server using the functions in the utl_tcp package. This works with no problems in testing, but after I put a web interface on it I discovered that what I thought were global variables (defined in the package spec) are being reset every time a new call is made to the server. The interface works by repeatedly calling a certian function in my package which checks the tcp stream (what I want to be my 'global' variable) for any new information coming downstream. When it does this though the stream is gone, the variable has been reset with every request.
    I tested this with a more simple variable too to make sure it just wasnt some quirk of the tcp connection type. What I want to happen in the code is everytime the procedure 'increment' is hit the variable would increase. This is that test code:
    PACKAGE test IS
       testNum number := 0;
       PROCEDURE increment;
    END test;
    PACKAGE BODY test IS
       PROCEDURE increment IS
       BEGIN
           testNum := testNum + 1;
           htp.prn('Current value: ' || testNum);
       END;
    END test;
    After hitting that procedure a few times the output was 1 every time, so it would seem what I had believed to be 'global' variables are actually local to the request, reset every time, and that is not going to work for me. I need some persistance.
    Someone mentioned something to me about storing variables in a session object, but I don't know anything about that (yet)...
    Any help would be appreciated.

    Hey,
    I am not sure where exactly to ask about this, so if I posted in the wrong forum forgive me.
    My problem is this: I am writing an application which interacts with a remote server using the functions in the utl_tcp package. This works with no problems in testing, but after I put a web interface on it I discovered that what I thought were global variables (defined in the package spec) are being reset every time a new call is made to the server. The interface works by repeatedly calling a certian function in my package which checks the tcp stream (what I want to be my 'global' variable) for any new information coming downstream. When it does this though the stream is gone, the variable has been reset with every request.
    I tested this with a more simple variable too to make sure it just wasnt some quirk of the tcp connection type. What I want to happen in the code is everytime the procedure 'increment' is hit the variable would increase. This is that test code:
    PACKAGE test IS
       testNum number := 0;
       PROCEDURE increment;
    END test;
    PACKAGE BODY test IS
       PROCEDURE increment IS
       BEGIN
           testNum := testNum + 1;
           htp.prn('Current value: ' || testNum);
       END;
    END test;
    After hitting that procedure a few times the output was 1 every time, so it would seem what I had believed to be 'global' variables are actually local to the request, reset every time, and that is not going to work for me. I need some persistance.
    Someone mentioned something to me about storing variables in a session object, but I don't know anything about that (yet)...
    Any help would be appreciated.

  • GetVariableData() usage with global-scope primitives (BPEL 2.0)

    My composite has a global scope variable named "length" that is defined as an integer.  When I attempt to access it at the same scope from an embedded Java using getVariableData() I get a funky error.
    My variable definition is:
        <variable name="length" type="xsd:integer"/>
    And my embedded Java looks like this:
    try {
    int pwdLen = getVariableData("length");
    }catch (Exception e) {
    addAuditTrailEntry("Exception occured in length: " + e);
    Can anyone see why this isn't working?

    getVariableData() doesn't return int. The following works:
    try {
    int pwdLen = Integer.parseInt((String)getVariableData("length"));
    }catch (Exception e) {
    addAuditTrailEntry("Exception occured in length: " + e);

  • Would like to declare a variable Public/Global in an IF statement

    Is there way to declare a variable as Public in an IF statement. My goal is to declare the variable as global (since this variable is used somewhere in the code and should not get initialized when there is loop back to the top of the code, hence using IF statement to control the initialization) based on the IF condition and then use it elsewhere in the code.
    I have it like this
    if (!sei_second_jsp.equals("1"))
    public int[] mecitem;
    public String[] sei_mfg_prod_cat;
    public String[] sei_part_number;
    public String[] sei_descrip;
    public String[] sei_price;
    public int[] sei_onhand;
    public int[] sei_demand;
    mecitem = new int[20000];
    sei_mfg_prod_cat = new String[20000];
    sei_part_number = new String[20000];
    sei_descrip = new String[20000];
    sei_price = new String[20000];
    sei_onhand = new int[20000];
    sei_demand = new int[20000];
    for (int i=0; i<=19999; i++)
    mecitem[i] = 0;
    sei_mfg_prod_cat[i] = " ";
    sei_part_number[i] = " ";
    sei_descrip[i] = " ";
    sei_price[i] = " ";
    sei_onhand[i] = 0;
    sei_demand[i] = 0;
    Your guess is right, I am using this code in JSP - since this is a Java related question, thought of posting it in JAVA forum.
    When I use the above code, I get the following error
    1809 }' expected. { 
    1811 Statement expected. public int[] mecitem;
    1827 Identifier expected. mecitem = new int[20000];
    1827 Can't specify array dimension in a declaration. mecitem = new int[20000];
    1827 Identifier expected. mecitem = new int[20000];
    1837 Can't specify array dimension in a declaration. sei_onhand = new int[20000];
    1837 Identifier expected. sei_onhand = new int[20000];
    1839 Can't specify array dimension in a declaration. sei_demand = new int[20000];
    1839 Identifier expected. sei_demand = new int[20000];
    3117 Class or interface declaration expected. }

    Please note the above code in the JSP is submitting to itself and I donot want it to get initialized if the IF statement is not successful..
    thnks a lot for your time.. !!!

  • Resolving session scoped component in global scope component.

    Hi,
    I am implementing batch process and i am need to resolve session scoped component in global scoped component.
    In global scope component (one of the component referred by my scheduler which also in global scope as usual) and i need to resolve session scoped "/atg/epub/workflow/WorkflowView" component in my scheduler.
    I tried all possibilities but nothing worked out. I do not have access to current request, because its batch process. following ways i tried,
    1. getResolveName("/atg/epub/workflow/WorkflowView") method of GenericService which is extended by my global scope component -- This returns null.
    2. Tried to get the current request on ServletUtils to use resolveName() method on request.
    ServletUtlis.getCurrentRequest() - This returns null as expected.
    Is there any way to resolve session scoped component in global scope component. Thanks in advance.
    Edited by: 938890 on Jun 30, 2012 4:59 AM

    Try below :
    If you want to resolve the name of a Nucleus component from Java code that is not itself a Nucleus service, you must first initialize Nucleus with this construct:
    Nucleus.getGlobalNucleus().resolveName("target component")
    where target component is the name of the component you are looking up. Note that this construct works only for components with global scope.
    You can also resolve names of Nucleus components using the Java Naming and Directory Interface (JNDI). The following example shows how you can use JNDI to access the Scheduler component:
    String jndiName = "dynamo:/atg/dynamo/service/Scheduler";
    Context ctx = new javax.naming.InitialContext ();
    Scheduler s = (Scheduler) ctx.lookup (jndiName);
    reference - oracle ATG docs.
    ~ Praveer

  • What is persistent variable?

    Hi!
    what is the correct definition for persistent variable in java?
    Thanx
    -Sasi

    what is the correct definition for persistent variable
    in java?In what context did you see this?
    The term "persistent" is used to refer to data which maintains state between runs of the applications. The data is stored in some fashion (database or file.)
    As an example the following two terms are equivalent (although the first is more general.)
    The customer will be persisted.
    The customer will be stored in the database.
    Normally a single variable is not stored. Although that might be the case for user preferences in a GUI for example.

  • What is the difference between Instance variable and Global variable?

    Hi folks,
    Could you please explain me, "what is the difference between Instance variable and Global variable?"
    Are they really same or not?
    --Subbu                                                                                                                                                                                                                                                                                                               

    Hi flounder,
    I too know that there is no such a term GLOBAL in java.
    generally people use to say a variable which is accessible throught out the class or file has global access
    and that will be called as a global variable...
    my point is very much similar to what Looce said.
    In simple that is not a technical term, but just a causual term.
    In technically my question is, "What is the difference between a instance variable and public variable?".
    Hi looce,
    Thanks for the reply. even thats what my understanding too....in order to confirm that i raised this question..
    Your reply has given a clear answer...... thanks again.
    --Subbu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Shared Variables vs Globals

       I started a large project recently and decided to make use of Shared Variables.  :I need some network communication between LV apps, so that is the main reason, but I decided to put them to the test by also using single-process Shared Variables instead of globals.  (Yeah, yeah, globals are evil.  blah blah blah.  I'm not really interested in dogma here.  Suffice it to say that, IMHO, there are still a few times and places where globals are appropriate and useful.)
       My project is fairly modular, and the main control program launches numerous other top-level programs.  The problem is that whenever one of these top--level programs (or the main program) is launched, the Shared Variable deployment window pops up and does its several second initialization.;  If this happened just once, when the top level program launched, it would probably be acceptable.  But having each dynamic VI go through this gets annoying.
       I'm using 8.2.1.  I haven't tried 8.5 much yet, but at least in 8.0 and 8.2, you can't search for Shared Variables.  That is also annoying and can lead to maintenance issues.
       So now I am considering replacing all the single-process Shared Variables with good-ole Globals.  A couple of the VIs in the system will still use networked Shared Variables, so they will still cause the deployment window to pop up, but it will be much less frequent.  And I'll be able to search for the globals and make sure I'm using them responsibly.
       Does anyone have any other ideas on how to minimize the deployment window?  Or ideas on development patterns using Shared Variables?  Preferences for Shared Variables vs Globals?
    Thanks,
        Dave
    David Thomson Original Code Consulting
    www.originalcode.com
    National Instruments Alliance Program Member
    Certified LabVIEW Architect
    There are 10 kinds of people: those who understand binary, and those who don't.

    Ben,
       Wow, you are quick.  And thanks.  Good catch.  Turning off the auto-deploy removes the dialog.  Nice, but now I have to figure out how the SV's are going to get deployed on each installation...  I haven't fully digested how SV's really work, especially how to best handle the deployment issues.  This project will be installed on a number of computersand used by scientists, not LV programmers.  So I need a reliable way of setting up the deployment.  Perhaps it is just one more step in the installation process..  That assumes that all the SV's are defined when the program is first installed  The program is very modular, so the end-user will be able to copy new modules into a certain directory and be able to use them right off the bat, no extra programming.  But if a new module contained a new SV, it wouldn't be deployed...
       Any suggestions for searching?  I haven't tried it yet, but it seems that deleting a SV from the project is the only way.  That causes an error to occur at each instance of the SV.  Assuming all the project VIs are in memory, you can then use the error finding to locate every instance of where the SV was.  Of course, it isn't there anymore.  Minor issue...
    Graziano,
       Thanks for the ideas.  I do use functional globals a lot as well.  Very nice tools.
       I was really trying to transition to SV's so that I could use the Networked version.  I was using Single Process SV's instead of globals just as an experiment and to potentially leverage other SV features for them in the future.
    Regards,
       Dave
    David Thomson Original Code Consulting
    www.originalcode.com
    National Instruments Alliance Program Member
    Certified LabVIEW Architect
    There are 10 kinds of people: those who understand binary, and those who don't.

  • Session Persistent Variables

    I am working on converting a legacy client/server application to JSP/ADF/Struts in JDeveloper 10g. (and learning Jdev and Java at the same time.) The client/server version maintained a list of variables that persisted during the users's session, and then at application close were posted to a user settings table in the database.
    I'm "assuming" that a similar approach is both possible and best in this new environment, but I haven't come across any examples of how to implement it.
    Does anyone know of any example projects or documentation that describe how to persist variables throughout a user's session?

    What I'd like to maintain are application-specific values, such as the primary key of the selected record, user preferences, etc. (Nothing that Oracle stores in views, unfortunately.) What I'm envisioning is some sort of java class that holds the values, and is maintained by the business tier for the duration of the user's session. Values will change during the session, but once the session is terminated, the values must be flushed to the database and then restored when the user logs in next. What I don't know how to do is how to implement this in the business tier. Is it possible to maintain variables like this and associate them with a specific user? Are there any example apps out there that do that? Alternatively, is there a better way to do this that I haven't thought of?

  • MyArray is not responding as GLOBAL scope?

    Hello
    I want to have a Array declared in the form, and that Array should VISIBLE to every where of the form.
    Meaning, i can use tthat aray in every page, every subform, every text field to append the elements
    And to loop that array in some button (on click event).
    PLs. let me know how can i declare a array that is GLOBAL in scope, really global? at what level i hv to declare it? at root node level (say, my form name is VISITORinfio, so, keeping curson on this node and declaring array in readDoc event? )
    I tried with these options but not working at all!!

    Pls. help me that let me know how to declare a GLOBAL SCOPE array(i did by using var, with out var key word, i did at TOP level, even i dont hv any functions!) - Thank you

  • Initialization of global/scope variables ONLY through ASSIGN?

    Is it only possible to initialize global resp. scope variables through an explicit ASSIGN?
    Or can I place e.g. a value="...." attribute inside the BPEL source code at the variable declaration
    to initialize it directly?
    Or even better: can I init the variable through JDeveloper GUI?
    Peter

    I looked this up on Oracle Support and there was one thread that it said that it could be resolved with a 11.1.1.6. to 11.1.1.6.2 patch update.
    We have one test environment on 11.1.1.6.6 to which we have uploaded the RPD to receive the same error, although it now additionally indicated a "Blacklisted Connection Pool". Here are the error details:\
    [2013-01-22T00:30:32.000-08:00] [OracleBIServerComponent] [ERROR:1] [] [] [ecid: 004osJjn__ADCgH_qt0FyY0006Py000000] [tid: e9c8a950] [nQSError: 17014] Could not connect to Oracle database. [[
    [nQSError: 17001] Oracle Error code: 12545, message: ORA-12545: Connect failed because target host or object does not exist
    at OCI call OCIServerAttach.
    [nQSError: 43059] Init block ‘XYZ’: Dynamic refresh of repository scope variables has failed.
    [2013-01-22T00:30:32.000-08:00] [OracleBIServerComponent] [ERROR:1] [] [] [ecid: 004osJjn__ADCgH_qt0FyY0006Py000000] [tid: e9c8a950] [43143] Blacklisted connection pool: 'ABC'
    This is the way I have defined the DSN for the OCI 10g/ 11g within the RPD connection pool:
    (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.53.36.93)(PORT=1541))(ADDRESS=(PROTOCOL=TCP)(HOST=10.53.36.94)(PORT=1541))(ADDRESS=(PROTOCOL=TCP)(HOST=10.53.36.95)(PORT=1541))(ADDRESS=(PROTOCOL=TCP)(HOST=10.53.36.96)(PORT=1541))(LOAD_BALANCE=yes)(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=a.b.c)))
    My next test would be to individually test each host and see which one causes it to error out.
    Any insights of what I could look to additionally do?
    PS: The DBA is yet to get back with the exact version of the Oracle 11g DB but it is greater than 11.1.0.7 since that was the version they were running 6 months back and might have upgraded.

  • Persistent variable ..

    Hi,
    I have a question related to user variables.
    The system here has user variable set as persistent in registry it is set to zero.How system will behave incase both routers are down.
    I am facing a issue wherein the emergency is triggered but I don't see ant records in TCD and RCD.
    What can be causes?Any clues?
    THX

    quote:
    Originally posted by:
    Suva1
    Thanks Dan,
    I was looking at scoped variables as well as caching earlier
    but was not sure that I was looking in the right direction. I'll
    have to do some more research to understand how to properly scope
    my variables so that this behaviour does not exist anymore.
    Off the top of my head, if I remember correctly, I would
    differentiate the scoping as form.var vs. url.var, is that right?
    Cheers
    That's correct.

  • How to assign local variable to global variable dynamically in adobe livecycle designer 7.1

    Hi All,
    i want to assign my textfield value to global variable dynamically.so that where ever i want , i will access my global variable.so it is possible in adobe livecycle designer 7.1. kindly suggest me method.Thanks in advance.
    Thanks & Regards
    Ganesh

    Please remove all adobe livecycle designer versions from your local pc.
    restart your pc to be sure, that all temp data is deleted.
    download the newest ald version from service.sap.com and install it.
    have fun with developing adobe forms with sap transaction sfp.

  • Help understanding Global scope

    I have a formula "Access plus modified"-
    Global recordcount;
    whilereadingrecords;
    recordcount = recordcount+1;
    if {SRMFILE.ACCESSTIME} < {?Last accessed } AND
    {SRMFILE.WRITETIME} < {?Last Modified}
    AND
    {SRMFILESYSTEM.FILESYSTEMDEVICE} IN filesystemdevice
    THEN
    (parentdir := {SRMFILE.PARENTDIR};
    accesstime := {SRMFILE.ACCESSTIME};
    writetime := {SRMFILE.WRITETIME};
    currentfilename := {SRMFILE.FILENAME};
    fileactualsize := {SRMFILE.ACTUALSIZE}/1024/1024;
    thisfilesystemdevice := {SRMFILESYSTEM.FILESYSTEMDEVICE};
    In a following formula i want to display the number of records (recordcount)
    Evaluateafter ({@Access plus Modified});
    recordcount;
    But in formula editor i get an error unless i define recordcount again as
    Global numbervar recordcount;
    and then the count is zero.
    I thought Global forces a variable to be visible throughout the report?

    Carl, the fields on m y report are the ones calculated in the IF logic :-
    parentdir := {SRMFILE.PARENTDIR};
    accesstime := {SRMFILE.ACCESSTIME};
    writetime := {SRMFILE.WRITETIME};
    currentfilename := {SRMFILE.FILENAME};
    fileactualsize := {SRMFILE.ACTUALSIZE}/1024/1024;
    thisfilesystemdevice := {SRMFILESYSTEM.FILESYSTEMDEVICE};
    recordcount := recordcount+1;
    Each variable in the IF logic is further defined by another formula i.e. :-
    EvaluateAfter ({@Access plus Modified});
    StringVar currentfilename;
    currentfilename;
    The formulas for each varioable are then  defined in the details section.
    This is a small sample of the report :-
    FilesystemDevice     Actual size(GB)     Access      ParentDir     Recordcount
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:36:30 PM     /db2/pdid322/sqllib/     1.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:36:30 PM     /db2/pdid322/sqllib/     1.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:36:30 PM     /db2/pdid322/sqllib/     1.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:36:30 PM     /db2/pdid322/sqllib/     1.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:36:30 PM     /db2/pdid322/sqllib/     1.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:36:30 PM     /db2/pdid322/sqllib/     1.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:36:30 PM     /db2/pdid322/sqllib/     1.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:36:30 PM     /db2/pdid322/sqllib/     1.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/19/2006  8:08:08 PM     /db2/pdid322/piris00q/dbbackup/     2.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:38:48 PM     /db2/pdid322/sqllib/hmonCache/pdid322/     3.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:38:48 PM     /db2/pdid322/sqllib/hmonCache/pdid322/     3.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:38:48 PM     /db2/pdid322/sqllib/hmonCache/pdid322/     3.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:38:48 PM     /db2/pdid322/sqllib/hmonCache/pdid322/     3.00
    /dev/vx/dsk/dvgy322/db2     0.00     7/15/2006  9:38:48 PM     /db2/pdid322/sqllib/hmonCache/pdid322/     3.00
    You will see that "recordcount" stays at 1 for many of the "duplicate" entries. Then moves to 2 for a single record, then 3 for many.
    Thanks John

Maybe you are looking for

  • Itunes crashing everytime I sync or try to update my iPhone....

    Im using windows vista and everytime I try to sync or update my itunes it says Itunes has stopped working windows is closing the program.... Anyone know a way to fix?

  • FICA- Payment advice and FPY1

    Hi, How payment advice in FICA  can be configured and form can be customized ? Is it possible to  create an idoc with FPY1 for transferring data from one environment to other. Regards, Saeed

  • Oc4j and ejb3.0 as web services

    Hi, I have deployed a ejb3.0 jar with following files. Interface : package samples.webservice; import javax.jws.WebService; *@WebService* public interface HelloRemote public String echo(String input); Bean package samples.webservice; import javax.ejb

  • IPad photo app or iPhoto

    Could someone please advise me on the fundamental differences between the iPad app "photo" and the iPhoto app Thank you in advance

  • Customer Exit for Deriving Current Fiscal Period, Period+1 and Period+2

    Hi all, I have created three customer exit variables in my query for custom info object ZFISCPER (Fiscal Year PEriod), Fiscal 1, Fiscal 2 and Fiscal 3. I want to write a customer exit to derive the current period, current 1 and current2 period's resp