Linq to oracle entities - convert decimal to string

hi ,
Im using entityframework beta for oracle
I need compare string to a decimal column in my linq to entities query so i need convert number column to varchar, but .toString is not supported nor Convert.ToString nor SQLFunction.ToVarchar(or something like that) so how can i achieve this? should i import db function or there is some other (easier) way?
Thx for answer

Hi,
I solved it by importing to_char builtin oracle function to my model:
in edmx file put this (to section where your other procedures/functions are ) (change schema attribute to yours):
<Function Name="to_char" ReturnType="varchar2" Aggregate="false" BuiltIn="true" NiladicFunction="false" IsComposable="true" ParameterTypeSemantics="AllowImplicitConversion" StoreFunctionName="to_char" Schema="TOPASFO_DEMO">
<Parameter Name="value" Type="number" Mode="In" />
</Function>
And make partial class of your entities class and put there this:
[EdmFunction("Store", "to_char")]
public string to_char(decimal value)
// don’t need to implement the function
throw new ApplicationException();
And you can call it just like your other imported functions/procedures.

Similar Messages

  • Converting decimal to String

    Hello,
    I want to handle a number stored in a MySQL database as a string. The database type is decimal(5,2). If the decimal portion is .00, then it only returns .0 (1 zero). Can someone help me out?
    Thanks!

    In our upcoming 10.1.3 (see preview) there is support for providing converters on the direct mapping. This will allow you to specify a specific converter for one mapping or share it across mappings with these same requirements.
    In 9.0.4 and earlier I would recommend using the TypeConversionMapping. This allows you to specify that you want your numeric values stored as strings. To control the format you can provide your own ConversionManager at system start-up (ConversionManager.setDefaultManager(new MyConversionManager()) - refer to docs and Java Docs for specific details. The only limitation is that the conversion will be the same for all Numeric-&gt;String conversions when writing to the database, instead of per mapping. This is fine for most scenarios I have seen.
    There are some additional solutions I have seen used if that does not meet your needs:
    - Use your own wrapper class for the numeric value. This wrapper would have a toString() that writes the values out as you expect. Populating it can be done in either the method accessor set method or again with a custom conversion manager.
    - In your MySQLDatabasePlatform (assuming you wrote one) you can customize how values are written. This would also limit you one format for all similar types.
    I recommend the TypeConversionMapping with the custom ConversionManager and then when you migrate to 10.1.3 you can switch to the more flexible converters on mappings.
    How-to on custom conversion: http://www.oracle.com/technology/products/ias/toplink/technical/tips/customconversion/index.html
    Doug

  • Oracle 10g - Convert decimal to HH:MM

    Hi
    How can I convert a decimal to Hours:Minutes format eg. 2.75 to 2 Hours and 45 Minutes
    Thanks in advance

    or perhaps
    SQL> SELECT TRUNC(2.75) || 'hrs:' ||
           SUBSTR(numtodsinterval(2.75, 'HOUR'), 15,2) || 'mins:' ||
           SUBSTR(numtodsinterval(2.75, 'HOUR'), 18,2) || 'secs' FROM dual
    TRUNC(2.75)||'HRS:
    2hrs:45mins:00secs
    1 row selected.
    SQL> SELECT TRUNC(129.657) || 'hrs:' ||
           SUBSTR(numtodsinterval(129.657, 'HOUR'), 15,2) || 'mins:' ||
           SUBSTR(numtodsinterval(129.657, 'HOUR'), 18,2) || 'secs' FROM dual
    TRUNC(129.657)||'HRS
    129hrs:39mins:25secs
    1 row selected.Or maybe better
    SQL> SELECT TRUNC(2.75) || 'hrs:' ||
           extract (minute from numtodsinterval(2.75, 'HOUR' )) || 'mins:' ||
           extract (second from numtodsinterval(2.75, 'HOUR')) || 'secs'
      FROM dual
    TRUNC(2.75)||'HRS:'||EXTRACT(MINUTEFROMNUMTODSINTERVAL(2.75,'HOUR'))||'MINS:'||E
    2hrs:45mins:0secs                                                              
    1 row selected.
    SQL> SELECT TRUNC(129.657) || 'hrs:' ||
           extract (minute from numtodsinterval(129.657, 'HOUR' )) || 'mins:' ||
           extract (second from numtodsinterval(129.657, 'HOUR')) || 'secs'
      FROM dual
    TRUNC(129.657)||'HRS:'||EXTRACT(MINUTEFROMNUMTODSINTERVAL(129.657,'HOUR'))||'MIN
    129hrs:39mins:25,2secs                                                         
    1 row selected.Regards
    Peter
    Edited by: Peter on Mar 2, 2009 12:52 AM

  • Converting a binary string to a number...

    Hi guys,
    I'm trying to convert a binary string into a decimal integer. I'm not sure if LabVIEW has a VI that does that. I haven't found one yet. Basically, say I have the string '0101'. I want to convert that to the value '5'. Or say I'm using hex, I want '10101111' to be converted to 'AF'. So that's my dilemma. I'm hoping I'm not going to have to make my own VI. Thanks a lot!
    -Mike

    LabVIEW has exactly what you want even if it can be hard to find it.
    To convert a binary text string like "0101" to a decimal value can easily be done using the Scan Value function found under the String/Number conversion section. If you provide the format %b to it (not mentioned in the manual) you will get the decimal value of your binary string.
    Also, on your front panel you can change the format of your numerical indicators by right clicking on it and selecting Format & Precision. If you have a numerical indicator you can set it do display the numbers in e.g. hexadecimal form.
    However, if you want to convert a number to a hexadecimal text string you can use the Number to Hexadecimal String function also found under the String/Number conversion section.
    I
    attached a simple example, Conversions.vi, that shows how it works. I hope this helps. /Mikael
    Attachments:
    conversions.vi ‏14 KB

  • Convert clob to string?

    hi all,
    i'm having a problem getting the returnvalue of a storedproc. i'm using oracle database and created an oracle function that returns a clob data. unfortunately in vb.net, it won't accept clob format. if i change the returnvalue to varchar2 format it works fine.
    is there a way to convert clob into string?
    thanks.
    p.s.
    i'm using clob datatype because i need to return a large amount of characters (basically DDL statements like Creating tables with about a hundred partition more or less, also for creating a view with a very large text).

    It should be possible since Value is a string type property. Say if your OracleClob object name is clob1 then it should be possible to write something like -
    string str = clob1.Value;//C# syntax
    If you are using OracleParameter's Value property then you will have to do ".Value" twice as shown below -
    OracleParameter paramHavingClobInIt;
    string str = (paramHavingClobInIt.Value as OracleClob).Value; //C# syntax

  • ORA-01830: date format picture ends before converting entire input string at OCI call OCIStmtFetch

    Hi all,
    We are trying to create a BIP Data Model based on an Answer, but after selecting report, it hangs when I try to Apply to create a query based on Oracle BI. When I try to open the query in aswers, going to results tab I'm getting this error (OBIEE 11.1.1.6.2):
    ORA-01830: date format picture ends before converting entire input string at OCI call OCIStmtFetch
    I suppose that BIP data model is not able to create it because of this error. But this answer is working fine inside dashboards, etc. It only does not work when editing it. Query is doing something like this: "USING "- Collection Attributes"."Due Date" >= TIMESTAMPADD(SQL_TSI_DAY, -30, CAST ('01/04/2009' AS DATE))"
    Any ideas?

    Solved watching date format in generated SQL and changing default date format in presentation variables default values inside criteria according to SQL format.

  • Hi I would like to know if you can convert decimal to binary using actionscript 3.0?

    Hi I would like to know if you can convert decimal to binary using actionscript 3.0?

    Hi thanks for the response Ive tried to implement the code as you stated but it is not outputting please if you could check the following code and let me know where Ive gone wrong that would be much appreciated Thanks!.
    miles_txt.addEventListener(KeyboardEvent.KEY_DOWN,convertKilometres);
    miles_txt.restrict ="0-9";
    function convertKilometres (k:KeyboardEvent):void {
    var miles:Number;
    var kilometres:Number;
    if (k.keyCode == Keyboard.ENTER){
    miles=Number(miles_txt.text);
    kilometres=miles* 1.609344;
    kilometres_txt.text = kilometres.toPrecision(2);
    kilometreConvert_txt.addEventListener(KeyboardEvent.KEY_DOWN,convertKiloToMile);
    kilometreConvert_txt.restrict = "0-9";
    function convertKiloToMile(k:KeyboardEvent):void{
    var kilometreConvert:Number;
    var milesAnswer:Number;
    if (k.keyCode==Keyboard.ENTER) {
    kilometreConvert=Number(kilometreConvert_txt.text);
    milesAnswer=kilometreConvert* 0.621371192;
    milesAnswer_txt.text = milesAnswer.toPrecision(2);
    binary_txt.addEventListener(KeyboardEvent.KEY_DOWN, checkEnterKey2);
    function checkEnterKey2(e:KeyboardEvent):void{
    if(binary_txt.text != '' && e.keyCode == Keyboard.ENTER){
    decimal_txt.text=binaryToDecimal(binary_txt.text).toString();
    function binaryToDecimal(s:String):Number{
    var n:Number = 0
    for(var i:int=0;i<s.length;i++){
    n+=Number(s.substr(i,1))<<(s.length-1-i)
    return n;
    function decimalToBinary(n:Number):String{
    return n.toString(2);
    return_btn.addEventListener(MouseEvent.CLICK, goBackToCalculator);
    function goBackToCalculator(e:Event):void
    mybuttonSound.play();
    gotoAndStop("Calculator");
    clear_btn.addEventListener(MouseEvent.CLICK,clearField);
    function clearField(e:MouseEvent):void{
      mybuttonSound.play();
      miles_txt.text ="";
      kilometres_txt.text ="";
      milesAnswer_txt.text ="";
      kilometreConvert_txt.text ="";
      binary_txt.text ="";
      decimal_txt.text ="";

  • Formatting decimal to string

    I am having a problem converting decimal to a string.  It used to work!!!
    My code:
                    If Microsoft.VisualBasic.Right(Format(nWork, ".000"), 4) = ".000" Then
                        txtIngrQuantity.Text = Format(nWork, "####")
                    Else
                        txtIngrQuantity.Text = Format(nWork, "###0.000")
                    End If
    sample code:
    MyStr = Format(334.9, "###0.00") ' Returns "334.90".nWork = 0.5DtxtIngrQuantity.Text is returned as "0,500"Why is it changing the decimal point to a comma?Thanks

    Hi Acamar,
    My mistake!!  It seems that
    AnonymousCoward1001 in the link
    https://social.technet.microsoft.com/Forums/itmanagement/en-US/dcc9f90d-66b9-492c-b44c-4bff7b7bbcdc/error-in-south-africa-regional-settings-in-windows-server-2012-and-windows-8?forum=winserver8gen
    summed it up perfectly
    It seems to me that, again, the people "in charge" don't pay any attention to the ACTUAL environment.
    Yes, they have "agreed" to change the decimal separator to a comma, without looking at what is REALLY used in the REAL world.
    So, it would seem that it is up to the developers in South Africa to circumvent the "experts" and do things in ways that people EXPECT.
    I have NEVER used a comma in decimals and I never will - it destroys CSV imports and exports and will never make sense at any level.
    My estimation of the so-called experts drops lower and lower when I bump into this kind of rubbish.
    The solution is simple: select British locale and change the currency symbol throughout.
    Idiotic solution to an idiotic problem caused by idiotic "experts."
    I guess that's what we've come to expect from our powers that be!! Another work-around it will have to be otherwise I'll be bumping my head against so many unnecessary problems.  Frustrating!
    Thanks,
    Sue

  • Converting Base64 encoded String to String object

    Hi,
    Description:
    I have a Base64 encoded string and I am using this API for it,
    [ http://ws.apache.org/axis/java/apiDocs/org/apache/axis/encoding/Base64.html]
    I am simply trying to convert it to a String object.
    Problem:
    When I try and write the String, ( which is xml ) as a XMLType to a oracle 9i database I am getting a "Cannot map Unicode to Oracle character." The root problem is because of the conversion of the base64 encoded string to a String object. I noticed that some weird square characters show up at the start of the string after i convert it. It seems like I am not properly converting to a String object. If i change the value of the variable on the fly and delete these little characters at the start, I don't get the uni code error. Just looking for a second thought on this.
    Code: Converting Base64 Encoded String to String object
    public String decodeToString( String base64String )
        byte[] decodedByteArray = Base64.decode( base64String );
        String decodedString = new String( decodedByteArray, "UTF-8");
    }Any suggestions?

    To answer bigdaddy's question and clairfy a bit more:
    Constraints:
    1. Using a integrated 3rd party software that expects a Base64 encoded String and sends back a encoded base64 String.
    2. Using JSF
    3. Oracle 10g database and storing in a XMLType column.
    Steps in process.
    1. I submit my base64 encoded String to this 3rd party software.
    2. The tool takes the encoded string and renders a output that works correctly. The XML can be modified dynamically using this tool.
    3. I have a button that is binded to my jsf backing bean. When that button is clicked, the 3rd party tool sets a backing bean string value with the Base64 String representing the updated XML.
    4. On the backend in my jsf backing bean, i attempt to decode it to string value to store in the oracle database as a XML type. Upon converting the byte[] array to a String, i get this conversion issue.
    Possibly what is happen is that the tool is sending me a different encoding that is not UTF-8. I thought maybe there was a better way of doing the decoding that i wasn't looking at. I will proceed down that path and look at the possibility that the tool is sending back a different encoding then what it should. I was just looking for input on doing the byte[] decoding.
    Thanks for the input though.
    Edited by: haju on Apr 9, 2009 8:41 AM

  • Problem with JTree converting Node to string

    I have a problem that I cannot slove with JTree. I have a DefaultMutalbeTreeNode and I need its parent and convert to string. I can get its parent OK but cannot convert it to string.
    thisnode.getParent().toString() won't work and gives an exception
    thisnode.getParent() works but how do I convert this to string to be used by a database.
    Thanks
    Peter Loo

    You are using the wrong method to convert it to a String array.
    Try replacing this line:
    String[] tabStr = (String[])strList.toArray();
    With this line:
    String[] tabStr = (String[])strList.toArray( new String[ 0 ] );
    That should work for you.

  • Is there an easy way to convert a long string into an array?

    I can convert a long string into a 1-d array by parsing and using build array, but I would like to know if there is a function to make this easier.
    For example:
    from/   aaaaaaaabbbbbbbbccccccccdddddddd         (string of ascii)
    to/       an array that is 1-d with each element having eight characters
              aaaaaaaa
              bbbbbbbb
              cccccccc
              dddddddd
    Thank you.
    Solved!
    Go to Solution.

    Try something like this:
    (If you can guarantee that the string length is an integer multiple of 8, you an drop the two triangular modes in the upper left. )
    Message Edited by altenbach on 03-14-2010 06:40 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    ChopString.png ‏9 KB

  • Need a function module to convert xstring to string in web dynpro applicati

    hi,
       need a function module to convert xstring to string in web dynpro application other than HR_KR_XSTRING_TO_STRING.
    Moderator message: please (re)search yourself first.
    Edited by: Thomas Zloch on Nov 17, 2010 5:31 PM

    Hi,
    Check the following link:
    FM to convert XString to String
    Regards,
    Bhaskar

  • Converting Datetime in String in map

    Hello all,
    I am reciving a message from a system A, in which I am receiving field DOB as datetime and I am sending same message to system B , problem is that system B not able to handle DOB at there end as datetime - I have checked at BizTalk side that DOB
    is going correct so issue is at system B side. now system B wants BizTalk system to send them DOB field as string.
    What could be the possible way's to do this ?
    1) We can change both schema System A schema and System B schema and map them is one way .
    2) Can we take datetime and convert it to string using some funtoid ? and send that string to system B ? How ?
    Is there other way for this ?
    Thanks,
    Nitin
    Thanks and Regards, Nitin.

    Hi Nitin,
    First find out how the destination system consumes the datatime value. Some system would consume the value in the datetime field as string. It could be the problem in the format of the datetime. Ask them about their expected datetime format. For example
    "2004-09-23T10:20:00.000-05:00" is the standard datetime format produced when you set a field as xssd:datetime. May be the destination system not able to handle this format.
    If the issue is in the datatype i.e. in the way client consume, the datatype of the destination schema matter:
    Then update the destination schema's to have string datetype. And simply map the value from the soruce's datetime field to destination schema's update string field. You don't need any scripting fuctiond to convert the data type. BizTalk's mapper would handle
    it.
    If the issue is in the date format  i.e. in the way client consume, the datatype of the destination schema doesn't matter, and if the actual problem is in the format:
    Then update the destination schema's to have string datetype. Use a scripting fuctiond as suggested by others and do the conversion in the script.
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Help with Sample on Converting an XML string to a byte stream

    Hello All,<br /><br />I am sure this is something simple, but I am just not figuring it out right now.<br /><br />I am following the sample - "Converting an XML string to a byte stream" from the developer guide since I want to prepopulate just 1 field in my PDF form.<br /><br />How do I reference my form field within my servlet code properly??<br /><br />I have tried a few things now, my field is within a subform, so I thought it would be <root><subformName><fieldname>My data</fieldname></subformName></root>  I have also tried adding <page1> in there too.<br /><br />I am following everything else exactly as given in the sample code.<br /><br />I do have an embedded schema within the form and the field is bound.<br /><br />Thanks,<br />Jennifer

    Well, if you have a schema defined in the form, then the hierarchy of your data must match what is described in the schema. So, can't really tell you what it would look like, but just follow your schema.
    Chris
    Adobe Enterprise Developer Support

  • CIN: Converting a C String to a LabVIEW String

    Hi all,
    I have been developing CINs in Microsoft Visual C++ 6.0 for LabVIEW as
    project needs. However, I am having a problem with converting a C String
    to a LabVIEW String in CIN.
    I used two ways to try to make the conversion work that were LStrPrintf
    and MoveBlock as stated as following:
    1. LStrPrintf
    #include "extcode.h"
    #include "hosttype.h"
    #include "windows.h"
    struct teststrct{
    const char* test;
    struct teststrct testinstance;
    typedef struct {
    LStrHandle test
    } TD1;
    CIN MgErr CINRun(TD1 *testcluster, LVBoolean *Error) {
    char *tempCStr = NULL;
    strcpy(tempCStr, testinstance.test); // this would cause LabVIEW crash!
    LStrPrintf(testcluster->test, (CStr) "%s", tempCSt
    r);
    // but if I assigned tempCStr as tempCStr = "test", the string value
    "test" could be passed to LabVIEW without any problems.
    2. MoveBlock
    #include "extcode.h"
    #include "hosttype.h"
    #include "windows.h"
    struct teststrct{
    const char* test;
    struct teststrct testinstance;
    typedef struct {
    LStrHandle test
    } TD1;
    CIN MgErr CINRun(TD1 *testcluster, LVBoolean *Error) {
    char *tempCStr = NULL;
    int32 len;
    tempCStr = (char *)&testinstance.test; //since strcpy didn't work, I
    used this way to try to copy the const char* to char*.
    len = StrLen(tempCStr);
    if (err = NumericArrayResize(uB, 1L, (UHandle*)&testcluster->test,
    len))
    *Error = LVFALSE;
    goto out;
    MoveBlock(&tempCStr, LStrBuf(*testcluster->test), len); // the string
    was able to passed to LabVIEE, but it was unreadable.
    out:
    Did I do anything wrong? Any thougths or suggestions would be very
    appreciated!

    Thank you so much for your response, Greg. However, I still have problem after making
    corresponding modification for LStrPrintf approach:
    int32 len;
    char tempCStr[255] = "";
    strcpy(temCStr, testinstance.test);
    len = StrLen(tempCStr);
    LStrPrintf(testcluster->test, (CStr) "%s", tempCStr);
    LStrLen(*testcluster->test) = len;
    LabVIEW crashes. Any ideas?
    Greg McKaskle wrote:
    > The LStrPrintf example works correctly with the "test" string literal because
    > tempCStr= "test"; assigns the pointer tempCStr to point to the buffer containing
    > "text". Calling strcpy to move any string to tempStr will cause
    > problems because it is copying the string to an uninitialized pointer,
    > not to a string buffer. There isn't anything wrong with the LStrPrintf
    > call, the damage is already done.
    >
    > In the moveblock case, the code:
    > tempCStr = (char *)&testinstance.test; //since strcpy didn't work, I
    > used this way to try to copy the const char* to char*.
    >
    > doesn't copy the buffer, it just changes a pointer, tempCStr to point to
    > the testinstance string buffer. This is not completely necessary, but
    > does no harm and is very different from a call to strcpy.
    >
    > I believe the reason that LV cannot see the returned string is that the
    > string size hasn't been set.
    > Again, I'm not looking at any documentation, but I believe that you may
    > want to look at LStrLen(*testcluster->test). I think it will be size of
    > the string passed into the CIN, and it should be set to len before returning.
    >
    > Greg McKaskle
    >
    > > struct teststrct{
    > > ...
    > > const char* test;
    > > ...
    > > };
    > >
    > > struct teststrct testinstance;
    > >
    > > typedef struct {
    > > ...
    > > LStrHandle test
    > > ...
    > > } TD1;
    > >
    > > CIN MgErr CINRun(TD1 *testcluster, LVBoolean *Error) {
    > >
    > > char *tempCStr = NULL;
    > >
    > > ...
    > >
    > > strcpy(tempCStr, testinstance.test); // this would cause LabVIEW crash!
    > > LStrPrintf(testcluster->test, (CStr) "%s", tempCStr);
    > > // but if I assigned tempCStr as tempCStr = "test", the string value
    > > "test" could be passed to LabVIEW without any problems.
    > >
    > > ...
    > > }
    > >
    > > 2. MoveBlock
    > >
    > > #include "extcode.h"
    > > #include "hosttype.h"
    > > #include "windows.h"
    > >
    > > struct teststrct{
    > > ...
    > > const char* test;
    > > ...
    > > };
    > >
    > > struct teststrct testinstance;
    > >
    > > typedef struct {
    > > ...
    > > LStrHandle test
    > > ...
    > > } TD1;
    > >
    > > CIN MgErr CINRun(TD1 *testcluster, LVBoolean *Error) {
    > >
    > > char *tempCStr = NULL;
    > > int32 len;
    > > ...
    > >
    > > tempCStr = (char *)&testinstance.test; //since strcpy didn't work, I
    > > used this way to try to copy the const char* to char*.
    > > len = StrLen(tempCStr);
    > >
    > > if (err = NumericArrayResize(uB, 1L, (UHandle*)&testcluster->test,
    > > len))
    > > {
    > > *Error = LVFALSE;
    > > goto out;
    > > }
    > >
    > > MoveBlock(&tempCStr, LStrBuf(*testcluster->test), len); // the string
    > > was able to passed to LabVIEE, but it was unreadable.
    > > ...
    > >
    > > out:
    > > ...
    > >
    > > }
    > >
    > > Did I do anything wrong? Any thougths or suggestions would be very
    > > appreciated!

Maybe you are looking for

  • Tax Amounts not Pulling into Order

    We are using Vertex Series Q tax software. When we have taxable line items for the state of Washington, we are get the tax rates back from Vertex but the tax amounts are not calculating. I have tested this for the state of Pennsylvania and I get both

  • Problem in executing beans in j2sdkee1.2.1

    I have an email application which uses a bean called webmailbean.java. I could successfully execute this mail application under java webserver2.0 but it fails under j2sdkee1.2.1 server. I have kept this bean in a package called test and placed this b

  • Advantage of Alternative UOM as supposed to changing the UOM of material

    Hi Friends, What are the advantages of using alternative unit of measure as supposed to changing the UOM of material? & what are the necessary activities in SAP if we change the unit of measure of the material? Any pointers. Regards Ashu Edited by: a

  • Webdynpro view design error in Develeoper Studio 7.1

    Hello Experts, i have problem with Develeoper studio 7.1. I installed it properly. But when  i tried to develop webdynpro projects. it is created all components without any error. but when i open the view for design. i got this error message "An erro

  • Database information encryption

    Hi all, I´m trying to know if there´s a way of storing encrypted data into CRM OD Database and then if there´s a function that decrypts that information when CRM OD presents it to the UI. If you know anyway for storing secured data into CRM OD Databa