I can't pass empty string as column of Table Valued Parameter.

Hello.
I have stored procedure which accept TVP with columns of 'sql_variant' type. And I have C++ application which call this stored procedure.
When i pass some non-empty string as sql_variant from my application - all works fine.
But when I need to pass empty string ("") as sql_variant - I get following error:
"OLEDB hr = 0x80040e14
 #0:  OLEDB provider error 3621  "The statement has been terminated."
 #1:  OLEDB provider error 8062  "The data for the table-valued parameter 1 doesn't conform to the table type of the parameter."
 #2:  OLEDB provider error 8046  "The incoming tabular data stream (TDS) remote procedure call (RPC) protocol stream is incorrect. Table-valued parameter 0 (""), row 1, column 1: The supplied length is not valid for data type sql_variant.
Check the source data for invalid lengths. An example of an invalid length is data of nchar type with an odd length in bytes."  
Could you please help me deal with that issue?
Thanks,
Vitaliy

Dear Vitaliy,
Thank you for your question.
Based on my understanding of your question, the issue is related with passing SQL_VARIANT data type in C++ application using Microsoft OLE DB Provider.
As we can see from http://msdn.microsoft.com/en-us/library/ms173829(v=sql.100).aspx:
ODBC does not fully support sql_variant. Therefore, queries of sql_variant columns are returned as binary data when you use Microsoft OLE DB Provider for ODBC (MSDASQL). For example, a sql_variant column that contains the character string data 'PS2091'
is returned as 0x505332303931.
According to above statement, as you are using OLEDB provider for ODBC with sql_variant in your application, it is not fully support. Seems there are some conversion failure within the Stored Procedure calling. You may consider to adjust your application
slightly to use other commonly supported data types which also fits your application requirements.
I listed some more information regarding sql_variant below for your reference:
A column of type sql_variant may contain rows of different data types such as int, binary and char values.
A sql_variant data type must first be cast to its base data type value
before participating in operations such as addition and subtraction. You can find the conversion details in "Comparings sql_variant Values" part.
Below types of values cannot be stored by using sql_variant:
varchar(max)
varbinary(max)
nvarchar(max)
xml
text
ntext
image
timestamp
sql_variant
geography
hierarchyid
geometry
User-defined types
Hope it will be helpful.
Thank you!
Best Regards,
SQL Team - MSFT

Similar Messages

  • How can we pass the entire rows of a table to a web service in a VC model ?

    Hi,
    On the click of the submit button, I have to pass the rows of two tables into an enterprise service. This service also takes other fields of a form as an input.
    How can we pass the entire rows of a table into a service ?
    Regards,
    Nitin

    Hi Nitin,
    It seems that you have two or three different structures to pass data using your webservice. In your main question, two tables, you can join both in one table and from there call the webservice. In order to pass the entire table you need:
    1. Draw a line between your joinned table and your service,
    2. Map the fields,
    3. Create a 'SUBMIT' in your table tool bar. Right click on your table and choose 'Create Toobar', '+', name and choose 'Submit' as your event.
    4. Go to Configure Element (Table View) 'Multiple' at Selection Mode.
    Reward points if helps you to solve your question.
    Regards,
    Gilson Teixeira

  • How can i pass a variable instead of a table name in the Select statement.

    Dear all
    how can i pass a variable instead of a table name in a select statement ?
    Example :-
    Begin
    P_get_procedure_tname (aap_name,otable_name);--It will take an application name and will return a table name
    Select col1 into ocol1
    from  ---- here i want to pass the variable OTABLE_NAME
    End;How can i pass this ?

    Hi,
    You can use dynamic sql.
    EXECUTE IMMEDIATE 'SELECT COL1 INTO ' || OCOL1 || ' FROM " || OTABLE_NAME;
    {code}
    cheers
    VT                                                                                                                                                                                                                                                                                                   

  • Selecting multiple rows a table according to rows passed with a table valued parameter

    Ive got a table, which looks like this:
    CREATE TABLE MyTable (
    MyChars CHAR(3) NOT NULL,
    MyId INT NOT NULL,
    CONSTRAINT PK__MyTable_MyChars_MyId PRIMARY KEY (MyChars, MyId),
    CONSTRAINT FK__MyOtherTable_Id_MyTable_MyId FOREIGN KEY (MyId) REFERENCES MyOtherTable (Id)
    Records look like i.e.:
    Chars | Id
    'AAA' | 1
    'BBB' | 1
    'CCC' | 1
    'AAA' | 2
    'BBB' | 2
    'CCC' | 2
    'DDD' | 2
    'EEE' | 3
    'FFF' | 3
    'AAA' | 4
    'DDD' | 4
    'FFF' | 4
    Now I have a SP, which takes a table valued parameter like:
    CREATE TYPE dbo.MyTVP AS TABLE ( MyChars CHAR(3) )
    This SP should return a set of Ids, which match all the rows of the parameter.
    I.e.:
    if the TVP contains 'AAA', 'BBB' & 'CCC', i get as result 1 & 2
    if the TVP contains 'AAA' & 'FFF', i get as result 4
    if the TVP contains 'BBB' & 'EEE', i get an empty result
    What my SP is currently doing, is to build a query with string concatination, which is then executed with the EXEC statement. If we take my first example, the built query would look like this:
    SELECT DISTINCT t0.MyId
    FROM MyTable t0
    INNER JOIN MyTable t1 ON t0.MyId = t1.MyId
    INNER JOIN MyTable t2 ON t1.MyId = t2.MyId
    WHERE t0.MyChars = 'AAA' AND t1.MyChars = 'BBB' AND t2.MyChars = 'CCC'
    It works, but I'm not very fond of building the query. Maintaining such things is always a pain. And it also might not be the most efficient and elegant way to do this.
    Since I can't think of any other way of doing this, I wanted to ask, if someone of you got an idea, if there is a better way to accomplish this.

    Let me give you a "cut and paste" I use in the SQL Server groups:
    1) The dangerous, slow kludge is to use dynamic SQL and admit that any random future user is a better programmer than you are. It is used by Newbies who do not understand SQL or even what a compiled language is. A string is a string; it is a scalar value like
    any other parameter; it is not code. Again, this is not just an SQL problem; this is a basic misunderstanding  of programming principles. 
    2) Passing a list of parameters to a stored procedure can be done by putting them into a string with a separator. I like to use the traditional comma. Let's assume that you have a whole table full of such parameter lists:
    CREATE TABLE InputStrings
    (keycol CHAR(10) NOT NULL PRIMARY KEY,
     input_string VARCHAR(255) NOT NULL);
    INSERT INTO InputStrings 
    VALUES ('first', '12,34,567,896'), 
     ('second', '312,534,997,896'),
     etc.
    This will be the table that gets the outputs, in the form of the original key column and one parameter per row.
    It makes life easier if the lists in the input strings start and end with a comma. You will need a table of sequential numbers -- a standard SQL programming trick, Now, the query, 
    CREATE VIEW ParmList (keycol, place, parm)
    AS
    SELECT keycol, 
           COUNT(S2.seq), -- reverse order
           CAST (SUBSTRING (I1.input_string
                            FROM S1.seq 
                             FOR MIN(S2.seq) - S1.seq -1) 
             AS INTEGER)
      FROM InputStrings AS I1, Series AS S1, Series AS S2 
     WHERE SUBSTRING (',' + I1.input_string + ',', S1.seq, 1) = ','
       AND SUBSTRING (',' + I1.input_string + ',', S2.seq, 1) = ','
       AND S1.seq < S2.seq
     GROUP BY I1.keycol, I1.input_string, S1.seq;
    The S1 and S2 copies of Series are used to locate bracketing pairs of commas, and the entire set of substrings located between them is extracted and cast as integers in one non-procedural step. The trick is to be sure that the right hand comma of the bracketing
    pair is the closest one to the first comma. The relative position of each element in the list is given by the value of "place", but it does a count down so you can plan horizontal placement in columns. 
    This might be faster now:
    WITH Commas(keycol, comma_seq, comma_place)
    AS
    (SELECT I1.keycol, S1.seq,
    ROW_NUMBER() OVER (PARTITION BY I1.keycol ORDER BY S1.seq)
    FROM InputStrings AS I1, Series AS S1
    WHERE SUBSTRING (',' || I1.input_string || ',' 
    FROM S1.seq 
    FOR 1) = ',' 
    AND S1.seq <= CHARLENGTH (I1.input_string))
    SELECT SUBSTRING(',' || I1.input_string || ','
    FROM C1.comma_place +1
    FOR C2.comma_place - C1.comma_place - 1)
    FROM Commas AS C1, Commas AS C2
    WHERE C2.comma_seq = C1.comma_seq + 1 
    AND C1.keycol = C2.keycol;
    The idea is to get all the positions of the commas in the CTE and then use (n, n+1) pairs of positions to locate substrings. The hope is that the ROW_NUMBER() is faster than the GROUP BY in the first attempt. Since it is materialized before the body of
    the query (in theory), there are opportunities for parallelism indexing and other things to speed up the works. 
    Hey, I can write kludges with the best of them, but I don't. You need to at the very least write a routine to clean out blanks, handle double commas and non-numerics in the strings, take care of floating point and decimal notation, etc. Basically, you must
    write part of a compiler in SQL. Yeeeech!  Or decide that you do not want to have data integrity, which is what most Newbies do in practice altho they do not know it. 
    A procedural loop is even worse. You have no error checking, no ability to pass local variables or expressions, etc. 
    CREATE PROCEDURE HomemadeParser(@input_string VARCHAR(8000))
    AS
    BEGIN
    DECLARE @comma_position INTEGER;
    CREATE TABLE #Slices
    (slice_value INTEGER);
    SET @input_string = @input_string + ','; --add sentinel comma
    SET @comma_position = CHARINDEX(',', @input_string); 
    WHILE @comma_position > 1
      BEGIN
      INSERT INTO #Slices (slice_value)
      VALUES(CAST(LEFT(@input_string, (@comma_position - 1)) AS INTEGER)); 
      SET @input_string = RIGHT(@input_string, LEN(@input_string)-@comma_position)
      SET @comma_position = CHARINDEX(',', @input_string)
      END;
    END;
    Better answer:
    http://www.simple-talk.com/sql/learn-sql-server/values()-and-long-parameter-lists/
    http://www.simple-talk.com/sql/learn-sql-server/values()-and-long-parameter-lists---part-ii/
    Do this with a long parameter list. You can pass up to 2000+ parameters in T-SQL, which is more than you probably will ever need. The compiler will do all that error checking that the query version and the procedural code simply do not have unless you write
    a full parser with the standard error codes. You can now pass local variables to your procedure; you can pass other data types and get automatic conversions, etc. In short, this is just good software engineering. 
    CREATE PROCEDURE LongList
    (@p1 INTEGER = NULL,
     @p2 INTEGER = NULL,
     @p3 INTEGER = NULL,
     @p4 INTEGER = NULL,
     @p5 INTEGER = NULL)
      x IN (SELECT parm
              FROM (VALUES (@p1), (@p2), (@p3), (@p4), (@p5)) AS X(parm)
            WHERE parm IS NOT NULL;
    You get all the advantages of the real compiler and can do all kinds of things with the values. 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Whats the difference betweeen passing the table variable and table valued parameter?

    Hi Everbody
      Can someone one tell me what's the difference between passing a table variable and table valued parameter to a stored procedure or function? Can both be used to pass a table to a stored procedure/function?
    Regards
    Regards

    They are essentially the same. What we call a table variable is a local
    variable. A table-valued parameter is an incoming parameter to the
    procedure. The only difference is that the parameter is readonly.
    When you call a stored procedure, you can pass a table variable as the
    actual parameter. Or a table-valued parameter that you pass on.
    CREATE PROCEDURE nisse_sp @tvp sometype READONLY AS
    DECLARE @local someothertabletype
    EXEC pelle_sp @tvp, @local
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How can I pass empty value in URL Parameter

    Hi,
    I am passing different URL parameters to one page, to filter
    the recordset on that page. How can I pass an empty value in the
    URL parameter so that the recordset in unfiltered?
    The URL parameter is based on one field of the database:
    ContentType. So, the link would be to
    default.asp?ContentType=Event
    and then all records that have the ContentType field in the
    DB as Event are displayed. Is it possible to use this system to
    pass an empty parameter so that all records are displayed?
    Thanks
    Ian

    ?ContentType=All
    <% if (ContentType == "All")
    Build recordset w/o filtering
    ASP is rusty, but those are the basics.
    "iandobie" <[email protected]> wrote in
    message
    news:e8im80$q7m$[email protected]..
    > Hi,
    > I am passing different URL parameters to one page, to
    filter the recordset
    > on
    > that page. How can I pass an empty value in the URL
    parameter so that the
    > recordset in unfiltered?
    > The URL parameter is based on one field of the database:
    ContentType. So,
    > the
    > link would be to
    > default.asp?ContentType=Event
    > and then all records that have the ContentType field in
    the DB as Event
    > are
    > displayed. Is it possible to use this system to pass an
    empty parameter so
    > that
    > all records are displayed?
    > Thanks
    > Ian
    >

  • How can I pass a String by reference in java?

    Hello!
    My question is how to pass a String by reference in java.
    I tried to declare my variable, instead of using "String xxx = "f";", I used "String xxx = new String ("f");" :
    public static void main (String []args)
    String xxx = new String("f");
    StatusEnum result2 = getErrorPointStr(xxx);
         public StatusEnum getErrorPointStr(String text)
              StatusEnum testStatus = StatusEnum.PASS;
              StringBuffer buffer = new StringBuffer();
    buffer.append("123");
              text = buffer.toString();
              return testStatus;
    After calling to getErrorPointStr(String text) function, xxx = "f"
    So it does not work.
    How can I solve this? It is very important, the function will receive String and not something else.
    Thanks!

    Tolls wrote:
    Which is why I said:
    Which is why you only managed to change what 'text' referred to in the methodExcept that's not why. Even if String was mutable, doing text = whatever; would have the same effect; it would change what that variable refers to in the method, but it would not change the object's state.
    I meant that, since there was no way to actually change the data (ie the char[] or whatever) within the object 'text' referred to, the OP was attempting to change what 'text' referred to and hoping it would be reflected outside the method...which we know won't happen as Java is pass-by-value.\Ah, now I see.
    These by-value/by-reference threads tend to get confusing, because usually the person is passing a String, so the immutability of String tends to get in the way and just muddy the waters.

  • How can I pass a String to a mxml?

    I am trying to pass a string to mxml file.
    following are the part of codes:
    var renderPDFForm:RenderPDFForm=new RenderPDFForm();
    mx.core.Container.addChild.addChild(renderPDFForm);
    The RenderPDFForm is actually a mxml file, I want to do something like when creating the instance, a string can be called.
    Since we can't create constructor for mxml file, how I can do it?
    Thanks,

    So within your mxml file for the RenderPDFForm component:
    <mx:Script>
        <![CDATA[
            private var _myData:String;
            public function set myData(str:String):void{
                _myData = str;
          public function get myData():String{
                return _myData;
        ]]>
    </mx:Script>
    Then in your main app:
    <comp:RenderPDFForm myData="My nice string"/>
    where comp is your namespace name.

  • Can I pass a string value to a double numeric indicator?

    I am doing a sequence of tests and saving each tests datas. When I bypass one of the tests, I need the string value 'BP' to get saved ( in the double numeric indicator ) for that particular test. Is there any possible way to do that?
    Solved!
    Go to Solution.

    The numeric indicator works like a "Format into String" function with a hardwired numeric input.
    So it really is a string indicator in the end.
    You can use the "Format String" property node to modify how the numeric is displayed.
    (Also available in Display Format ... --> Advanced Edit Mode.)
    I don't think you can avoid displaying the numeric value, but you can add text.
    So you could, for example, display: "0  BP".
    Format string normal = "%#.2f";
    Format string adding "  BP" text  = "%#.2f  BP";
    Some of the suggestions by others on this thread might be easier to manage and give a better result.
    (You have to swap Format Strings around and still have the numeric displayed.)
    *Note however, that this technique can be used to do interesting things like add Units to your numeric indicator.*
    steve
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.

  • How can I pass an object to a function by value?

    Hi
    I have a function with an argument. this argument is an object. I don't want to alter this object. But java passes this object by reference and some fields in this object are altered after function return.
    How can I pass this object by value and keep my original data unbroken?
    thanks for any help

    a.toraby wrote:
    I have a function with an argument. this argument is an object. I don't want to alter this object. But java passes this object by reference and some fields in this object are altered after function return.
    How can I pass this object by value and keep my original data unbroken?How you approach it is likely to depend on how much control you have over the code in question. If it's legacy code and has been badly designed, there's probably very little you can do to protect existing code short of a complete refactoring.
    What you could do as an interim measure is:
    1. Create an immutable wrapper to your existing mutable class.
    2. Create new methods that replicate the existing ones, but take the immutable class instead.
    3. Deprecate the old methods.
    This won't break client code, but they will now get warnings when they compile and you can add documentation to point them to the new class/methods.
    If you are in control of the code (especially if you're still in the design stages), you've got several options:
    1. As Dr.Clap says, make your class immutable (probably best).
    2. If this isn't possible, create mutable and immutable variants of your class. This is often best achieved by hanging them both from an interface.
    Winston

  • How can i pass sql string in proc as in parameter and use in cursor forloop

    Dear Experts ,
    Please help me in below code.
    create or replace PROCEDURE Sample_Spool_Data (SQLSTRING IN VARCHAR2, FILENAME in VARCHAR2) IS
    v_spool_file UTL_FILE.FILE_TYPE ;
    SQLSTRING VARCHAR2(1000);
    BEGIN
    v_spool_file := UTL_FILE.FOPEN('MPLD_DQMT',FILENAME,'w');
    UTL_FILE.PUT_LINE(v_spool_file,'Start: '||to_char(sysdate,'dd/mm/yyyy hh:mi s'));
    FOR c1_rec in SQLSTRING
    LOOP
    UTL_FILE.PUT_LINE(v_spool_file,c1_rec.rec);
    end loop;
    UTL_FILE.PUT_LINE(v_spool_file,'End: '||to_char(sysdate,'dd/mm/yyyy hh:mi s'));
    SQL String is having like select col1, col2, col3 from table_name;

    Looks like you're tring to write a generic way of outputting the results of a query to a file.
    You won't do it the way you're trying to, because your dynamic SQL means that you don't know the resultant columns of the query so that you can output them. To do that you need to use the DBMS_SQL package to describe the query and fetch the returned columns by position e.g.
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.

  • REST API - Can't expand Title of lookup columns "System.ArgumentException : Value does not fall within the expected range"

    I have a list that has more than 12 columns of type lookup with more than 5000 items and I am using a date field as an indexed column so I can restrict the results to meet the list view threshold.  I am also using $select to restrict the columns to
    meet the lookup column threshold.
    If I run the query below it all works as expected:
    _api/web/Lists/MyList/items/?$Filter=Created gt '2015-03-10T05:00:00.000Z' and Created lt '2015-03-17T18:25:00.712Z'&$select=Lookup1/Id&$expand=Lookup1
    If I run this query it does not work:
    _api/web/Lists/MyList/items/?$Filter=Created gt '2015-03-10T05:00:00.000Z' and Created lt '2015-03-17T18:25:00.712Z'&$select=Lookup1/Title&$expand=Lookup1
    Error:
    <m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <m:code>-2147024809, System.ArgumentException</m:code>
    <m:message xml:lang="en-US">Value does not fall within the expected range.</m:message>
    </m:error>
    The lookup column "Lookup1" is using Title as the column's information and this should be working.  What is interesting is that changing the lookup threshold has no effect on this but raising the list item view limit does make it work.  The
    date range is selecting less than 5000 items.  So what am I missing here? I just want the Title for the lookup column and my query has about 10 items in it.

    Looking through the logs the error is thrown due to the following error messages:
    03/19/2015 08:26:12.12 w3wp.exe (0x6D34)
    0x7F38 SharePoint Foundation
    Fields 84h8
    High Field with internal name 'LookupFieldName_x005f_Title' already exists in the field cache
    3446f49c-f2d2-d0a2-89f4-59dee19b2f45
    03/19/2015 08:26:12.12 w3wp.exe (0x6D34)
    0x7F38 SharePoint Foundation
    Fields ki9p
    High Unable to add join related fields to the Query.[Error 0x80070057]
    3446f49c-f2d2-d0a2-89f4-59dee19b2f45
    03/19/2015 08:26:12.12 w3wp.exe (0x6D34)
    0x7F38 SharePoint Foundation
    General xxpm
    High Unable to execute query: Error 0x80070057
    3446f49c-f2d2-d0a2-89f4-59dee19b2f45
    03/19/2015 08:26:12.12 w3wp.exe (0x6D34)
    0x7F38 SharePoint Foundation
    General 8e2s
    Medium Unknown SPRequest error occurred. More information: 0x80070057
    3446f49c-f2d2-d0a2-89f4-59dee19b2f45
    03/19/2015 08:26:12.12 w3wp.exe (0x6D34)
    0x7F38 SharePoint Foundation
    General aix9j
    High SPRequest.GetListItemDataWithCallback2: UserPrincipalName=<removed>, AppPrincipalName= ,pSqlClient=<null> ,bstrUrl=siteUrl ,bstrListName=<removed> ,bstrViewName=<null> ,bstrViewXml=<View
    Scope="RecursiveAll"><Query><Where><Eq><FieldRef Name="ID" /><Value Type="Counter">5481</Value></Eq></Where></Query><ViewFields><FieldRef Name="LookupFieldName"
    LookupId="TRUE" /><FieldRef Name="LookupFieldName_x005f_Title" /></ViewFields><ProjectedFields><Field Name="LookupFieldName_x005f_Title" Type="Looku ,fSafeArrayFlags=SAFEARRAYFLAG_DATES_IN_UTC
    3446f49c-f2d2-d0a2-89f4-59dee19b2f45
    The very first message states that it is unable to add join related fields, what could be the possible cause of this?  As you can see rather than specifying a date range which I know contains less than 5000 items, even filtering based on ID gives the
    same result.

  • How Can i Store photo (image) in column of table

    Dear Experts,
    I need to store a employee photo in column so how can i do tha same.

    This assumes that the images in question currently reside on the database server. If you want to upload images into the database from a client machine, you will need an extra step where you move the files to the appropriate directory or directories on the server. This example will store the images in a BLOB column, rather than a much more flexible interMedia ORDImage column. A BLOB column is fine if you only want to store and retrieve the image, but interMedia gives you significantly more flexibility to manipulate the image, extract metadata, etc.
    Create the directory
    First, you will want to tell Oracle where it can find the images you want to insert into the database. The easiest way to do this is to create a directory object. In this case, I will be loading images from 'c:\temp\img\'.
    CREATE DIRECTORY images AS 'c:\temp\img\'
    If you don't have the CREATE DIRECTORY privilege, you will need to have someone else, like your DBA, create the directory and grant you READ access to it.
    GRANT READ ON DIRECTORY images TO scott;
    Create the Table to Hold the Images
    CREATE TABLE images (
    image_name VARCHAR2( 100 ),
    mime_type VARCHAR2( 100 ),
    content BLOB
    Create a Stored Procedure to Load the Image
    CREATE OR REPLACE PROCEDURE load_image( file_name VARCHAR2 )
    AS
    file_lob BFILE;
    binary_lob BLOB;
    mime_type images.mime_type%type;
    extension_pos NUMBER;
    BEGIN
    -- Use the extension of the file name to determing the MIME-type
    -- The MIME-type for a .JPG file will be image/jpg
    extension_pos := INSTR( file_name, '.' );
    mime_type := 'image/' || SUBSTR( file_name,
    extension_pos + 1,
    LENGTH( file_name ) );
    -- Insert a new row into the images table. Get the LOB locator
    -- for the newly inserted row-- we will be using that to insert
    -- the content from the file.
    INSERT INTO IMAGES( image_name, mime_type, content )
    VALUES( file_name, mime_type, empty_blob() )
    RETURNING content INTO binary_lob;
    -- Open up the file in the IMAGES directory named file_name,
    -- load that file into the newly created LOB locator, and
    -- close the file
    file_lob := BFILENAME( 'IMAGES', file_name );
    dbms_lob.fileOpen ( file_lob, dbms_lob.file_readOnly );
    dbms_lob.loadFromFile( binary_lob,
    file_lob,
    dbms_lob.getLength( file_lob ) );
    dbms_lob.fileClose ( file_lob );
    END;
    Load the Image
    scott@jcave > exec load_image( 'sample.jpg' );
    PL/SQL procedure successfully completed.
    scott@jcave > column image_name format a30;
    scott@jcave > column mime_type format a15;
    scott@jcave > column length format 999999;
    scott@jcave >
    1 SELECT image_name, mime_type,dbms_lob.getLength( content ) length
    2 FROM images;
    no rows selected
    Elapsed: 00:00:00.00
    scott@jcave > /
    IMAGE_NAME MIME_TYPE LENGTH
    sample.jpg image/jpg 9894
    Regards
    Lakmal

  • How can I pass the gt_outtab for cl_salv_table via a form parameter?

    Hello,
    I have put everything displaying the alv into a form routine and want to pass the gt_outtab-table, which contains the data to be displayed, as a table parameter. Then I receice the error CX_SY_DYN_CALL_ILLEGAL_TYPE regardless if it is a typed parameter (the actual structure, table) or untyped parameter.
    Does anyone have an idea, what to do? Of cause refering to a global variable will do, but the readability of the programm I want to have it as a parameter.
    Thank you,
    Peter

    Hi,
    you must use your table as a global object in the program. If you try to pass the values to the subroutine as a parameter with TABLES, then you´re altering the properties of the output table; that´s why you get the exception.
    .... and don´t worry about the readability of your program.

  • SQLLDR - how to set a default value for an empty string

    I'm using SQLLDR to load data from a flat file on Oracle 10g 10.2.0.4 EE, Linux RHEL 4 update 6. Seems like my question is simple, but darned if I can't find the solution.
    My source file (comma delimited extracted form a different RDBMS) has some (not all) rows where the output for a string is "", and not NULL. How do I check for empty string and add a default value in the control file? The target column is non-nullable
    Here's my current control file - however, the column attributeName where sometimes the source record is "" does not get evaluated as NULL.
    load data
    infile 'mydata.del'
    badfile 'mydata.bad'
    discardfile 'mydata.dsc'
    into table mydata
    fields terminated by "," optionally enclosed by '"'
       TRAILING NULLCOLS           
    (l_metadata,
    company,
    className,
    attributeName "decode(:vc_attributeName,null, 'none')",
    attributeDefault)
    {code}
    When I tried decode with "", I received the following error:
    {code}SQL*Loader-350: Syntax error at line 11.
    Expecting "," or ")", found ", 'none')".
    attributeName "decode(:vc_attributeName,"", 'none')", {code}
    This does not work either:
    {code}
    load data
    infile 'mydata.del'
    badfile 'mydata.bad'
    discardfile 'mydata.dsc'
    into table mydata
    fields terminated by "," optionally enclosed by '"'
       TRAILING NULLCOLS           
    (l_metadata,
    company,
    className,
    attributeName NULLIF attributeName = BLANKS ,"decode(:vc_attributeName,null, 'none')",
    attributeDefault) I get the following in the log:
    Table COMPANYMETADATA, loaded from every logical record.
    Insert option in effect for this table: INSERT
    TRAILING NULLCOLS option in effect
       Column Name                  Position   Len  Term Encl Datatype
    L_METADATA                          FIRST     *   ,  O(") CHARACTER
    COMPANY                            NEXT     *   ,  O(") CHARACTER
    CLASSNAME                         NEXT     *   ,  O(") CHARACTER
    ATTRIBUTENAME                     NEXT     *   ,  O(") CHARACTER
        NULL if ATTRIBUTENAME = BLANKS
        SQL string for column : "decode(:attributeName,null, 'none')"
    ATTRIBUTEDEFAULT                  NEXT     *   ,  O(") CHARACTER
    Record 1: Rejected - Error on table COMPANYMETADATA, column ATTRIBUTENAME.
    ORA-01400: cannot insert NULL into ("SRV5"."COMPANYMETADATA"."ATTRIBUTENAME")
    {code}
    Any help is appreciated -
    Edited by: kpw on Feb 9, 2009 11:10 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hello,
    I just loaded following data successfully in my_data table using the same control file I posted. Yes it will evaluate "" as null and replace with none, remember in control file you have this option, "optionally enclosed by '"'.
    #my_data.dat
    "myname1", "attribname1"
    "myname2", "attribname2"
    "myname3", "attribname3"
    "myname4", ""
    #my_data.ctl
    load data
    into table my_data
    fields terminated by "," optionally enclosed by '"'
    TRAILING NULLCOLS           
    my_name char(30),
    vc_attributeName "decode(:vc_attributeName,null, 'none', :vc_attributeName)"
    {code}
    Here is the output log file
    {code}
    Control File:   my_data.ctl
    Data File:      mydata.dat
      Bad File:     mydata.bad
      Discard File:  none specified
    (Allow all discards)
    Number to load: ALL
    Number to skip: 0
    Errors allowed: 50
    Bind array:     64 rows, maximum of 256000 bytes
    Continuation:    none specified
    Path used:      Conventional
    Table MY_DATA, loaded from every logical record.
    Insert option in effect for this table: INSERT
    TRAILING NULLCOLS option in effect
       Column Name                  Position   Len  Term Encl Datatype
    MY_NAME                             FIRST    30   ,  O(") CHARACTER           
    VC_ATTRIBUTENAME                     NEXT     *   ,  O(") CHARACTER           
        SQL string for column : "decode(:vc_attributeName,null, 'none', :vc_attributeName)"
    Table MY_DATA:
      4 Rows successfully loaded.
      0 Rows not loaded due to data errors.
      0 Rows not loaded because all WHEN clauses were failed.
      0 Rows not loaded because all fields were null.
    Space allocated for bind array:                  18560 bytes(64 rows)
    Read   buffer bytes: 1048576
    Total logical records skipped:          0
    Total logical records read:             4
    Total logical records rejected:         0
    Total logical records discarded:        0
    Run began on Mon Feb 09 18:17:35 2009
    Run ended on Mon Feb 09 18:17:36 2009
    Elapsed time was:     00:00:00.98
    CPU time was:         00:00:00.10
    {code}
    Hope this helps clearing your dobuts
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for