Writing variable as a string

im trying to write variable as a string and i get weird errors.
this is the query:
select *
from [ebs-DB2].ebenefits_Repl.dbo.TBL_Enrollment
where enr_enrollmentid in (select EnrollmentID 
from FileTransfer.dbo.StLukes_Wellness_DataRecord_V1
where Employee_Status in ( 'E' )) and  Con_IPE_StatusId in ( 'APPR' )
and when i write it this way:
declare 
@string varchar (100) = N'[ebs-DB2].ebenefits_Repl.dbo.'
,@e varchar (4) = 'E'
,@APPR varchar(4) = 'APPR'
,@SQLSplit1 varchar (700)
,@SQLstatement nvarchar (max)
set @SQLStatement=N'
select *
from '+@string+'TBL_Enrollment
where enr_enrollmentid in (select EnrollmentID 
from FileTransfer.dbo.StLukes_Wellness_DataRecord_V1
where Employee_Status in ('+@E+')) and Con_IPE_StatusId in ('+@APPR+')
print @SQLStatement
EXEC sp_executesql @SQLStatement
it generates error saying " Invalid column name 'E'. " " Invalid column name 'APPR'. "
 

set @SQLStatement=N'
select *
from '+@string+'TBL_Enrollment
where enr_enrollmentid in (select EnrollmentID
from FileTransfer.dbo.StLukes_Wellness_DataRecord_V1
where Employee_Status in ('''+@E+''')) and Con_IPE_StatusId in ('''+@APPR+''')
Tweak it as above and see
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Assigning a node value from an XML variable to a String type  in Weblogic Process Integrator

    Hi,
    Is there any way to assign a node value from an XML variable to a String variable
    in Weblogic Process Integrator...
    Thanx.
    Narendra.

    Nerendra
    Are you talking about using Xpath on the XML document and assigning to a
    variable, it is unclear what you are asking
    Tony
    "Narendra" <[email protected]> wrote in message
    news:3bba1215$[email protected]..
    >
    Hi,
    Is there any way to assign a node value from an XML variable to a Stringvariable
    in Weblogic Process Integrator...
    Thanx.
    Narendra.

  • How to store serval char variables into a string variable?

    I have serval char variables, but i don't know how to put them together (without using arrays). I am thinking to store these char variables into a string variable but i don't know how to do it. For example,
    char letter1 = 'a', letter2 = 'b', letter3 = 'c';
    String letters;
    then how can i do to make letters = "abc" from using letter1,2,3?
    I am just a beginner of Java, if anyone can help me, i will appreciate that very much!!!

    String letters=""+leter1+letter2+letter3;is fine and dandy. What it actually compiles to is
    String letters = new StringBuffer().append(letter1).append(letter2).append(letter3).toString();Which ofcourse is much more code to write, but still good to know.
    So do see the API for java.lang.StringBuffer.
    Heikki

  • Variable name to string

    Hi, I'm really new to TestStand, so this is probably an easy question:
    I'm using TestStand 4.5 and I'm trying to convert the name of a variable, Locals.MaxArrayIndex, which is a numeric variable, into a String, Locals.VarString.
    I know that the Str() function can be used to convert a numeric into a String, but how can I store the actual words "Locals.MaxArrayIndex" in a string?
    Thanks! 

    Hmmm...it works great for Parameters that are arrays, but for me it won't work if the Parameter is a numeric variable. Maybe I'm making a mistake somewhere else that I'm not picking up; so I attached the sequence file if you want to take a look at it.
    The issue arises in the 'Else' statement. I'm pretty sure the syntax in my function and popup are correct, but the String (ParamName) that is supposed to hold the value of the Parameter variable name (DataSelect) doesn't seem to ever be filled and outputted in the error message.
    I would really appreciate it if any of you guys could have a look at the file (I'm sure I'm making some kind of really rookie mistake)
    Thanks! 
    Attachments:
    GenerateError.seq ‏9 KB

  • Variable or Substitution String in Interactive Report Filter

    Background: I have an application that has a number of customized Interactive Reports where the Filter on the reports is set to a custom company name. When I install the application, I do not want to go through the reports and change the filter for the new company's name. The filters I need to change are all set by LOVs.
    Question: Is there a way that I can do one of the following:
    - associate a Filter with a Variable or Substitution String such that I can set that variable or string on login and then the user always sees the correct Filter displayed in the Interactive Report?
    - or is there a code method to update a sql apex table behind the scenes to reset the Filter to the new value. So that I could run that after installation as part of a customization / set-up time?
    System Info: 4.1.0.00.32
    Thanks,
    Stephen
    I used the IR_FILTER function, and while it allowed for a new filter to be set. It did not save the filter after logout or for other users accessing the Primary report. I could not find a SAVE Interactive Report function. So, my question still stands on looking for a method to set and save Filters programatically.
    Edited by: slsmith on Apr 19, 2012 8:07 PM

    Hi,
    I don't have access to an Apex 3 environment to check this, but I think that the Apex 4 Interactive Reports save the filters slightly differently and an attempt to mimic that functionality using IR conditions would fail.
    The only alternative I can think of right now is to have an additional column that returns 0 or 1 - eg:
    SELECT FIELD1,
    FIELD2,
    FIELD3,
    CASE WHEN (FIELD1 IS NULL OR FIELD2 IS NULL OR FIELD3 IS NULL) THEN 1 ELSE 0 END INCLUDE_NULLS
    FROM YOURTABLEand then apply a filter to INCLUDE_NULLS = 1
    Andy

  • Geting a variable from a String

    Hi, i need to get a variable from a string. For example:
    int test1;
    int test2;
    int test3;
    int test = getvariablefromstring("test"+3);
    ..................

    Reflection will work for member variables, not locals. It'sprobably not the right solution for you though.
    If you just want test1, test2, test3, ... testN, then you want an array or a List.
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html
    http://java.sun.com/docs/books/tutorial/collections/

  • Javascript variable names in strings

    This should be easy, but i can't find any info on how to do
    it!
    It's easy to put the contents of a variable into a string but
    how does one place the name of a Javascript variable into a
    string??
    The only solution i have found is to store the name
    separately as a string, but this isn't very neat.

    OK, simple statement first:
    Integer does not equal string.
    You also seem to be tossing around "runtime" and "static" somewhat liberally. Once you wire an integer (be it a control or block diagram constant) to the case structure's selector, the cases can only take on integer values. This is by design. If you wire a string, the case items take on string values. If you wire an enum, the case items take on the enumeration values. Once you've defined a case structure's cases you can't change them at "runtime". This, by definition, is different code.
    That said, it seems to me that you're looking for an enum.

  • Good practice to initalize all instance variables with type String to emptr

    Is it a good practice to initalize all instance variables with
    type String to emptry string?
    #1 approach:
    public class A
    { private String name = "";
    private String address ="";
    //etc...
    rather than
    #2 approach:
    public class A
    { private String name;
    private String address;
    //etc...
    When I read Java books, the examples don't usually do #1 approach.
    The problem is if we don't initialize to empty string, when we call
    the getter method of that instance variable, it will return null.
    Please advise. Thanks!!

    Please advise. Thanks!!It depends on your coding style. If you can avoid lots of checks for null Strings in the rest of the code then why not initialize to "".
    You have the same situation when a method returns an array. If you under circumstances return a null array reference then you have to always check for this special case, but if you return a zero length array instead you have no special case. All loops will just run 0 iterations and everything will work fine.
    So in general I guess the return of zero objects instead of null references really boils down to whether it simplicates the rest of your code by removing lots of extra checks for the special null case. This usage is especially favourable in the zero length array case. See Effective Java by Bloch, item 27.

  • Bizarre Question - Accessing Variables w/ a String

    Im obsessed with finding a way to do this, haha, but i dont know
    if its remotely possible.
    Instead of explaining it i will post some pseudo-code...
    class HackClass{
    int AVar = 1;
    int BVar = 2;
    int CVar = 3;
    // ...use some arbitrary method of getting user input
    String input = // user's input, in this case it is = "AVar"
    // and then what im trying to achieve...
    // im looking for something like this ---> (variable)input = 5;
    System.out.println("Avar = " + AVar); // this would output 5
    Note, this is very oversimplified. So though it would be easy in this example, i am not looking to register every
    variable in some table and then use some elaborate lookup function with the string, rather, is there a way to refer to a variable in code with a string?
    I cant imagine there is, but that would be WICKED.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Wow. Thanks for the code.
    Im writing test code now.
    You said this was "java-beanish"... is it reflection?
    Because the only way it compiles is if i import...
    import java.lang.reflect.*;also, in your code you never defined the variable 'object' in
    method.invoke(object, invokeParam);and for anyone else interested in the code - here is my test class:
    import java.lang.reflect.*;
    public class HackThis{
    public static void main(String[] args) {
         String var = "Var1";
         Integer value = new Integer( 1234 );
         HackThis ht = new HackThis();
         Class[] param = new Class[1];
         param[0] = value.getClass();
         Method method = ht.getClass().getMethod("set" + var, param);
         Object[] invokeParam = new Object[1];
         invokeParam[0] = value;
         method.invoke(object, invokeParam);
    public HackThis(){
    public Integer getVar1(){
         return Var1;
    public void setVar1(Integer i){
         Var1 = i;
         Integer Var1 = new Integer(99);
    }...but note it wont compile because 'object' hasnt been defined yet

  • Writing a large xml string to a file

    Hi,
    I get a large xml file, into a String (It might be around 8 MB also). After this, I need to write this to a file. Which java method I can use for the same.
    I am getting confused by the various classes for writing a file.
    I want to use the best, efficient way of doing this. Can any one please help?
    public static void writeStringToFile( String fileName, String content,
              boolean append )
              throws FileNotFoundException, IOException
              FileOutputStream fos = null;
              File file = new File (fileName);
              try {
    //++  fos = new FileOutputStream( file);     
          fos = new FileOutputStream( file, append );                 //++
                   fos.write(getBytes(content));
              } catch (FileNotFoundException fne) {
                   throw fne;
              } catch (IOException ioe) {
                   throw ioe;
              } finally {
                   try {
                   if(fos != null)
                        fos.close();
                   } catch (Exception _ex) {
         }

    hi_all wrote:
    But is there any any particular reason for using the encoding specific to xml?Yes, because that's what the XML specification says you're supposed to do. If you don't do that then you may produce malformed XML.
    Will there be any perf degrade or truncation of the large string, while writing to the file, if we use,
    out.write(sigUpdateString);Compared to what? You're just writing the data out to a file, the quickest way to do that is to just write the data out. The two things you should do are: (1) use a BufferedWriter (2) stop obsessing about performance.

  • Naming a variable from a string

    Hi,
    I am trying to convert a String into a variable name.
    for example "namevariable" is converted to the variacle name and then used like below:
    namevariable = new classname( );
    any ideas ?
    thanks

    I am trying to convert a String into a variable name.This kind of programing using information about the program is called reflection.
    You can create an instance of a certain type by
       Class�t�= Class.forName("java.lang.Thread")This works only for getting a new instance, or the instance, in case you have a static class.
    Regards,
    Marc

  • Using variable in connection string returns 0 for variable.

    hi all- I am pulling data from a visual forxpro database and the connection string is as follows: 
    Data Source=\\ServerName\FolderName\AR;User ID=Domain\svcAct;Provider=VFPOLEDB.1;Persist Security Info=True;
    I created a variable called CurrentARPath and stored the path
    \\ServerName\FolderName\AR
    I then tried using this variable in the Expression property of the connection string as follows:
    "Data Source="+(DT_WSTR, 20)@[User::CurrentARPath] + ";User ID=Domain\\svcAct;Provider=VFPOLEDB.1;Persist Security Info=True;"
    However, the above expression is evaluating the variable to 0 as shown below; this is causing the connection in connection manager to go down(offline) and the OLED data source is complaining.
    Data Source=0;User ID=Domain\svcAct;Provider=VFPOLEDB.1;Persist Security Info=True;
    any idea what i am doing wrong here? thanks in advance!

    What datatype is CurrentARPath? Are there any
    configurations on the connection string or variable?
    Which
    package protection level are you using?
    CurrentARPath data type - Char
    there are no configurations on the connection string. one thing that i should mention is that i have created a variable  called ArPath of type object and using it in the for each loop container. this variable gets populated using an execute SQL statement.
    i am then mapping the vale from ArPath to CurrentARPath in the loop container.
    Package protection level is default(encrypt sensitive)
    thanks for the help.

  • Stored Procedure - variable name inside string [EXEC]

    Hi everyone
    I'm looking for a solution for this problem:
    I've created a stored procedure, in which i need to insert a record in a table.
    The point is i don't know the exact column to put my values and which values to save: it depends from the input data.
    I've created a function wich creates (concats) my query.
    The result is similar to:
    SET @myquery = 'INSERT INTO MyTable (columnABC, columnDEF) VALUES (@valueABC, @valueDEF)'
    This query is the value of a varchar.
    I want to execute this query, so I thought to use: EXEC(@myquery)
    The problem is that SQL can't find the variables @valueABC or @valueDEF if thery're inside a nvarchar.
    Is there some particular syntax in order to replace the value of variables?
    I hope it's clear!!
    Thank you in advance!!!!!
    Federica

    You need to create an entire SQL string without the variables.
    SET @myquery = 'INSERT INTO MyTable (columnABC, columnDEF) VALUES (''' + @valueABC + ''', ''' + @valueDEF + ''')'
    Please, please don't post such bad solutions!
    If you use dynamic SQL, you should use a parameterised statement:
    SET @myquery = 'INSERT INTO MyTable (columnABC, columnDEF) VALUES (@valueABC, @valueDEF)'
    EXEC sp_executesql @myquery, N'@valueABC int, @valueDEF int',
         @valueABC, @valueDEF
    However, I would prefer not to use dynamic SQL at all, but do:
    INSERT tbl(keycol, col1, col2, col3, ....)
       VALUES (@keyval,
               CASE @coltoinsert WHEN 'col1' THEN @val END,
               CASE @coltoinsert WHEN 'col2' THEN @val END,
    Although the entire idea of not knowing the columns before sounds spooky to me. A column in a table is supposed to model a unique attribute.
    Erland Sommarskog, SQL Server MVP, [email protected]
    sp_Executesql worked for me, than you very much!!!

  • Include a variable in message string

    Hi,
    I want to include a variable in the message string like:
    wa_log-msg = 'Length for material number should be ' (here I want to iclude variable holding the length).
    How to do this?
    Thanks in advance...
    Regards,
    Sriram

    Hi, Sriram
    Hope following will solve out your problem,
    DATA: msg TYPE string,
          vlen(2).
    vlen = 19.
    CONCATENATE: 'Length for material number should be ' vlen INTO msg SEPARATED BY space.
    Best Regards,
    Faisal

  • Using session variable in init. string of session variable init. block

    hi, experts,
    is it allowed to use a loaded session variable (A) in the initialization string in the initialization block of another session variable (B).
    for example,
    in the execution precedence of initialization block of B, added the initialization block of A
    then in the initialization string in the initialization block of B,
    the sql likes:
    select yyy from a where a.xxx = 'valueof(nq_session.A)'
    what is the correct syntax?
    thank you very mucH!

    That's the correct format. If it is not working for you then you need to give more information as what's happening, how you populate your Init Blocks etc.

Maybe you are looking for

  • ERROR AT 1st step

    hello experts, i am getting the below error at the very 1st step of the process chain. 21.01.2011     00:15:20     NO_MORE_SPACE: Can not create MTE: no more space: no more MESSAGE_CONTAINER slots available     S     RSAR     51 please suggest what i

  • Best RAM configuration for Macbook (mid 2007)

    Hi, I have a Macbook (mid 2007) with 1 GB ram and I would like to upgrade. Currently I have 2x512MB, so both of my memory slots are taken. Is it a good idea to have one 512MB card and a 2GB card in the other slot? Otherwise, what is the best RAM conf

  • Why won't my camera appear?

    When I was charging my iPod touch via USB iTunes opened up and automatically started restoring my iPod. I have the newest software. But after the iPod was done restoring and cut back on, my camera isn't appearing on the home page. I already reset my

  • Wireless How-To

    Please visit the following webpage for tutorials and how-to before posting a question related to Wireless. http://tablet.sel.sony.com/1/1/SGPT112USS/Settings/WiFi Sony Community Manager Sr. Software Engineer Peter Tat

  • How to Enable All rows in Table

    Hi Friends, I have to create table in firstview. My requirement is I will give 4 or 5 inputs at a time then click on save button that input data will be saved in ECC system So in First View I have to create table by using apply template that time I h