Datatype conversion and Range

Ok here i am back again..
I am creating a database upgrade tool,
the column types are also subject to change.
I use the CAST(col_name AS newtype) function to cast types,
this often works. But not for all cases.
@see http://download-west.oracle.com/docs/cd/A91202_01/901_doc/server.901/a90125/functions15.htm
For example a change from VARCHAR(255) to CHAR(3) does not work if the row currently
contains a row with more than 3 character.
A simple conversion that solves this problem is:
CAST(CAST(col_name AS VARCHAR(3)) AS CHAR(3))
I tested it using the following statement:
select CAST(CAST('wtfomgbbq' AS VARCHAR(3)) AS CHAR(3)) from dual;
Does this always work?
Some type changes can be done directly on a table like this:
ALTER TABLE table_name MODIFY ( col_name <NEWTYPE>)
But this only works if the range is either the same or increased,
or the table does not contain any rows, or the columns has only null values.
(i checked the reference)
But is there a way to always use this MODIFY statement and force the data to be transformed to the new type?
My current approach is to create a temporary table, drop the current table, and recreate the current (with correct schema) and put the old data in the new table using the CAST function as described above.
Maybe you experts now some way to do this faster?
And how can i handle range decreases without getting oracle errors?
(the update process may take several hours, so the DBA does not want an error message when updating the database)

It would be easier as you still have to convert the output of SUBSTR to CHAR(3), else you are doing an implicit type conversion... Which is not bad, but i really want to be explicit:
CAST(SUBSTR(col1, 1, 3) AS CHAR(3))
Note that the sql code that does the type conversions is automatically generated, so it doesnt matter if it looks more complex.
Anyway the main problem question is:
Can i always use ALTER TABLE MODIFY to modify the data types of columns or do i have to use temporary cols, or temporary tables?
Isnt there an option to force data type conversions and let oracle handle the casting (ans loss of data if the data-range is decreased) ?
Thanks in advance

Similar Messages

  • Difference between datatype NUMBER and NUMBER(38)

    Difference between datatype NUMBER and NUMBER(38)

    From
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#i54330
    NUMBER Datatype
    The NUMBER datatype stores zero as well as positive and negative fixed numbers with absolute values from 1.0 x 10-130 to (but not including) 1.0 x 10126. If you specify an arithmetic expression whose value has an absolute value greater than or equal to 1.0 x 10126, then Oracle returns an error. Each NUMBER value requires from 1 to 22 bytes.
    Specify a fixed-point number using the following form:
    NUMBER(p,s)
    where:
    p is the precision, or the total number of significant decimal digits, where the most significant digit is the left-most nonzero digit, and the least significant digit is the right-most known digit. Oracle guarantees the portability of numbers with precision of up to 20 base-100 digits, which is equivalent to 39 or 40 decimal digits depending on the position of the decimal point.
    s is the scale, or the number of digits from the decimal point to the least significant digit. The scale can range from -84 to 127.
    Positive scale is the number of significant digits to the right of the decimal point to and including the least significant digit.
    Negative scale is the number of significant digits to the left of the decimal point, to but not including the least significant digit. For negative scale the least significant digit is on the left side of the decimal point, because the actual data is rounded to the specified number of places to the left of the decimal point. For example, a specification of (10,-2) means to round to hundreds.
    Scale can be greater than precision, most commonly when e notation is used. When scale is greater than precision, the precision specifies the maximum number of significant digits to the right of the decimal point. For example, a column defined as NUMBER(4,5) requires a zero for the first digit after the decimal point and rounds all values past the fifth digit after the decimal point.
    It is good practice to specify the scale and precision of a fixed-point number column for extra integrity checking on input. Specifying scale and precision does not force all values to a fixed length. If a value exceeds the precision, then Oracle returns an error. If a value exceeds the scale, then Oracle rounds it.
    Specify an integer using the following form:
    NUMBER(p)
    This represents a fixed-point number with precision p and scale 0 and is equivalent to NUMBER(p,0).
    Specify a floating-point number using the following form:
    NUMBER
    The absence of precision and scale designators specifies the maximum range and precision for an Oracle number.
    And
    2
    NUMBER[(precision [, scale]])
    Number having precision p and scale s. The precision p can range from 1 to 38. The scale s can range from -84 to 127
    Sybrand Bakker
    Senior Oracle DBA

  • Aperture RAW conversion and noise

    I've been using Aperture for many years and have recently learned something useful about how to tweak the RAW conversion settings.  Until recently I just left them at the default settings for my camera, a Panasonic GH2.
    Anyhow I've not been entirely happy with shadow noise (otherwise I reckon it's a great camera).  Many web sites say that a degree of shadow noise is normal for this camera, so I didn't figure mine was any different.  I tried a variety of noise reduction approaches but none really made a worthwhile improvement.
    Until a few days ago when I tried tweaking the 'Raw Fine Tuning' settings - and I found a way to make things *much* better.
    Please note that the following comments may only be relevant to Panasonic RAW files, and maybe only for the GH2.  I don't know if they apply to other cameras (though I think they may.
    It turns out that for the GH2, the default 'Raw Fine Tuning' setting includes 'Sharpening' of 0.78 and 'Edges' of 0.79.  This is fairly aggressive sharpening, but I didn't really realise what it was doing to noise until I  discovered that was significantly increasing shadow noise -even at base ISO!
    If I set these both the sharpening sliders in the Raw Fine Tuning section to '0', the 'grain' in the shadows is much smoother - a massive improvement.
    But, of course, the image is a bit less 'sharp'.  Well, this isn't much of a problem with 16+ megapixel cameras.  Unless you are making huge enlargements from originals, and really look closely at the finest details at 100%, it makes very little difference if you give up this 'sharpness'.  But the reduction in noise is actually very obvious indeed.  It's much better! 
    Most of the sharpness I need on these less noisy images can easily be added by including the 'Edge Sharpen' adjustment, either at the defailt settings, or marginally toned down a bit.  I'm currently using Intensity 0.7, Edges 0.3 and Falloff 0.4.  This leaves most smooth areas untouched, so the 'noise' or 'grain' in smooth areas is as it comes from the sensor.  By toggling the Edge Sharpen on and off, I can easily confirm no change in 100% or 200% loupe views. 
    That level of edge sharpening is a bit subtle, but actually achieves most of what I got from the Raw Fine Tuning sharpening sliders.  It will be applied only to in-focus contrasty things like eyelashes or hairs or other defined edges, and very nicely.
    So I'm sharing this in case other people also find it helpful.  I strongly suggest removing the default sharpening entirely, and only using the Edge Sharpening slider in a cautious manner if you want to enhance sharpness.
    Some related web pages:
    http://www.jonroemer.com/blog/2011/01/aperture-3-too-sharp-tweak-the-default/
    http://www.twin-pixels.com/raw-processors-review-aperture-bibble-capture-one-dxo -lightroom/
    PS - there is a different issue with the default Raw Fine Tuning 'Boost' and 'Hue Boost' sliders, both of which are set to 1' by default.  It turns out that these introduce a very large amount of contrast and exposure gain - turn them down to zero and the image goes quite dark and flat!  The Aperture user guide says something about Hue Boost changing colours when Boost is set to '1' and this is the case.  So I've experimented with turning them both to zero, and instead using a custom curves adjustment to achieve a similar level of exposure and contrast to the default conversion and the camera's default JPG image.  By fine-tweaking the curves one can get better control of blown highlights and the overall contrast.  I'm not sure if the colours are 'better', but I think so.  I am fairly sure that I get smoother transitions in the mid-tonal ranges with this approach rather than just using Apple's default settings.  Maybe they are a but strong for my liking.  Certainly I can make curves that rarely require the 'Recovery' slider to fix over-boosted highlights.  Anyhow, you may also find that this tweak helps a bit.  Interestingly on a Canon RAW file the effect is not nearly as great in exposure terms, but there is also a definite colour change.
    PSS - the end result is that I have set my camera preset for RAW fine tuning to zero settings for boost, hue boost, sharpening and edges.  I then add contrast as needed using curves, and sharpen only with a little edge sharpening.  I've then saved a few Presets with slightly different contrast curves and all with a little edge sharpening.  I can very quickly select the level of contrast needed, and I am very confident that my results are quite a bit better, with better tonal gradations and much less noise.
    Hope this helps
    Chris.

    Nice observations, Chris.  I think the RAW Fine Tuning is often overlooked, even though it's a vital first step in RAW processing, and really the whole point of shooting RAW in the first place.  Too much boost yields horrible skin tones in my experience.  I have a default of .50 Boost and Hue Boost, Sharpening and Edges at .25, Moire .50, Radius 12.0 and Denoise .25.  I've found these are "mid range" settings for the Canon 5Dii, and first make small adjustments to the Fine Tuning brick before moving on to exposure adjustments. 

  • How to create a table with datatype blob and insert a pdf file (ravi)

    how to create a table with datatype blob and insert a pdf file,
    give me the explain asap
    1.create the table?
    2.insert the pdffiles into tables?
    3.how to view the files?
    Thanks & Regards
    ravikumar.k
    Edited by: 895044 on Dec 5, 2011 2:55 AM

    895044 wrote:
    how to create a table with datatype blob and insert a pdf file,
    give me the explain asapPerhaps you should read...
    {message:id=9360002}
    especially point 2.
    We're not just sitting here waiting to answer your question as quickly as possible for you.

  • Why can I no longer click on a conversation and st...

    Not so "instant" messaging....
    I used to be able to click on a conversation from my taskbar and immediately start typing an IM.  Since updating, I cannot tell you how many times i have clicked on a conversation and started typing only to realize i have to reach for my mouse and click on the conversation (that is popped up right in front of me) AGAIN before I can start typing a message.  This is extrememly frustrating and is slowing me down at work. 
    Please tell me if there is a setting I can modify this with or if there is a way to revert back to the old version of skype.

    Is the Zotero extension still enabled?
    *Firefox/Tools > Add-ons > Extensions
    Ar other installed extensions still working properly?
    You can try to uninstall and reinstall the Zotero extension.
    See also "Corrupt extension files":
    *http://kb.mozillazine.org/Unable_to_install_themes_or_extensions
    *https://support.mozilla.org/kb/Unable+to+install+add-ons
    Delete the extensions.* files (e.g. extensions.sqlite, extensions.ini) and compatibibility.ini in the Firefox profile folder to reset the extensions registry.
    *https://support.mozilla.org/kb/Profiles
    New files will be created when required.

  • Select-options and ranges

    Hi all,
    Belated Happy Holi.
    Can u  explain me the difference between
    Select-options and ranges?
    When, where and how to use them ?
    I know the basic differences, but i need to know in deep .
    could u give me the informatin with a scenario please ?
    Thanks in advance
    Ravi

    HI
    <u>SELECT-OPTIONS:</u> Declare an internal table that is also linked to input fields on a selection screen
    <u>RANGES:</u> Declare an internal table with the same structure as in select-options, but without linking it to a selection screen.
    FOR FURTHER DOCUMENTATION PLEASE GO THROUGH THE LINK
    <a href="http://72.14.203.104/search?q=cache:btyoj86smhEJ:www.sap-img.com/abap/difference-between-select-options-ranges.htmSelect-optionsandrangesIN+ABAP&hl=en&gl=in&ct=clnk&cd=1">Difference Between Select-Options & Ranges</a>
    <a href="http://72.14.203.104/search?q=cache:EJgiHLpghDEJ:help.sap.com/saphelp_nw04/helpdata/en/fc/eb3034358411d1829f0000e829fbfe/content.htmSelect-optionsandrangesIN+ABAP&hl=en&gl=in&ct=clnk&cd=4">Statical Declaration</a>
    <a href="http://72.14.203.104/search?q=cache:VWS1erlabRIJ:help.sap.com/saphelp_nw04/helpdata/en/9f/dba71f35c111d1829f0000e829fbfe/content.htmSelect-optionsandrangesIN+ABAP&hl=en&gl=in&ct=clnk&cd=5">Selection tables</a>
    REGARDS
    ANOOP
    Message was edited by: ANOOP R.S

  • Using currency conversion and text variable at the same time

    Hi all,
    In a 3.5 bex query, i am applying currency conversion on a key figure with a variable of 0currency.
    as i know, to be able to apply currency conversion, variable of currency should not be in Free characteristics or in Filter.
    it has to be selected only on the key figure.
    but now, i want to use text variable for selected currency (with type replacement path). But as i know, to be able to use text variable, variable of currency has to be
    in Free characteristics or in Filter.
    Can you please advise, how to both use currency conversion and text variable on currency?
    Thanks in advance.
    Sancho

    Sancho,
    I'm not 100% sure about this, but I'm thinking that if you are pulling the text variable from a selection in a structure, you should not need it in the free characteristic or filter. Try creating a structure, placing the currency in it as a selection, and creating a text variable as the title for the selection that is based on the currency. This may help.
    Cheers,
    Rusty

  • What are Conversions and Extensions

    Hey ,
         I want to know what are Conversions and Extensions. Can i get any material where i can get information on these.
    Thanks in advance

    The conversion programs were used to take the extract data from the legacy system and re-format for SAP and load the data into SAP.
    Conversions are one-time programs used to transfer data from the legacy system into SAP. For example, you can transfer master data like vendors, customers etc.
    SAP provides enhancement to BAPIs thru EXTENSION IN AND EXTENSION OUT .these are structure parameters.suppose example: one BAPI released to update the mara table.then u modified the table mara thru append structure.this changes will not be reflected in BAPIs.So thats why in that case we have to use EXTENSION IN AND EXTENSION OUT structures to fill and work.

  • Difference between select-option and range

    Hi,
      wat are the difference between  select-option and range
    where u have to use those and give the syntax for the range option.
      if u use range option in report programming there is any advantages ?
      pls reply for this ..
    thanks
    rams

    Hi,
    Not much of a difference,
    A Select-Option could be like,
    SELECT-OPTIONS sel FOR f
    And a Range could be like,
    DATA: BEGIN OF sel OCCURS 10,
             SIGN(1),
             OPTION(2),
             LOW  LIKE f,
             HIGH LIKE f,
          END   OF sel.
    Here they both function the same. But then the Select-Options has numerous options associated with it than the RANGE option.
    Hope it helps,
    Pradip Parmar.

  • Iphone5s messaging. I delete a conversation and then that contact stays at top of my message list. How do I get rid of these so I can see active conversations easily?

    Iphone5s messaging. I delete a conversation and then that contact stays at top of my message list. How do I get rid of these so I can see active conversations easily?

    Thanks!  So much better

  • Business Rule Currency Conversion and Carry Forward

    Hello Guys,
    I have a question related to the Business Rules Currency Conversion and Carry Forward
    I configured the business rule "Currency Conversion" and I selected "Apply to Periodic". What this rules does with the flag selected  is to get the value of the previous month converted and add the factor (Local Currency previos month - Local Currency Actual month) * Exchange Rate of Current Month
    For Example: USD previos month +
    This rule applies perfectly from FEB to DEC but if I run it for January, it does not consider the value of USD previos month and LC previous month for calculations so the result I get is:
    (and of course it´s because it only applies to periodic)
    I need to include into my results this amounts and factor so the question is: Is not a flag I can activate to force the system to act as it does for FEB to DEC periodic ??
    I also set up the Business Rule "Carry Forward" so with this rule Im able to bring values converted in USD from DEC to JAN for example from a Data Source Input, but the problem is that it erase any other value I have in other Data Source members and I need to keep that info.
    Hope you can come with a suggestion.
    Im working with SAP BPC NW 7.5 SP08

    Hello guys,
    Yes, my fiscal year is from JAN to DEC and Im using a YTD app,
    As you mentioned for P&L accounts the rule works fine; but we want to carry forward LEQ accounts. Is there a way to use or configure the currency conversion rule with the flag "Apply to Periodic" to carry forward LEQ accounts for the next following year?
    Here is how we configured our Carry Forward Business Rule
    Source and Destionation account = 4111
    Source and destionation Flow= FCLO
    Reverse Sign= False
    Data Source Type= ALL
    Same Period= False
    Apply to Periodic=False
    Opening Data Source=DatosBase
    Source Data Source = AJ_AC
    Regards

  • How do I set domain and range in grapher.app?

    Hey, I'm brand new to this program, and i can't figure out for the life of me how to set the domain and range of an equation.
    For example, if i had the equation y=x^2 , how would i go about setting the x values>0?
    Any quick replies are very appreciated! Its rather urgent.

    Apple's Grapher does, in fact, have this capability. It's a shame that Apple's documentation is very poor. Grapher is a wonderful application. In any case, here is how to do it:
    The general syntax is:
    y = condition(s) ? expression
    So for example, if you only wanted to graph the positive x values of x^2, you would enter:
    y = x > 0 ? x^2
    You can also have multiple conditions, separated with an ampersand (&). For example, the sinx graph from -pi to pi:
    y = x > -π & x < π ? sinx
    You can even limit the range. Example:
    y = y < 5 ? x^2
    This only shows the parabola up to the y = 5 line.
    Again, you can mix and match any set of conditions you desire with the ampersand, including limits on the domain and range within the same set of conditions. Example of x^2 only showing positive x values up to the y = 5 line:
    y = y < 5 & x > 0 ? x^2
    Hope this helps.

  • Having to leave the conversation and re-enter to read iMessage.

    My iMessages aren't coming through while 'in' conversaton, i have to leave the conversation and load again to see the new message.
    My friend on her 3GS is not having to do this and all my iMessages are coming through automatically with the the conversation open.
    How can I make it 'auto-detect' / 'auto update'?
    Thanks

    Try force-closing it again followed by resetting your phone (hold the on/off and home buttons at the same time until you see the Apple logo, ignoring the off slider that appears first, then release).  If the problem persists you may have to back up your phone and restore it as described here: http://support.apple.com/kb/HT1414.   Before restoring be sure to sync with iTunes and back up your phone.  It's also a good idea to import your photos to your computer (see http://support.apple.com/kb/HT4083) and back up your contacts (by syncing them with iCloud, Google or another cloud service, or to a supported program using iTunes.

  • In IOS7; I am trying to delete a picture from an old text message conversation, and it keeps coming back in a second. Why?

    In IOS7; I am trying to delete a picture from an old text message conversation, and it keeps coming back in a second. Why?

    Turn off, and on your device again; and how are you deleting the picture?b From where :O

  • What is the relation between FetchSize and Range Size

    Hi
    What is the relation between FetchSize ("in batches of" field) and Range Size in view object tuning section? What would happen if, for example, I set the fetch size to 10 and range size to 5?
    Ferez

    Timo,
    From oracle’s documentation we learn that RangeSize attribute of the Iterator “controls the number of records ADFm requests from the BC layer simultaneously”
    RangeSize Tuning
    This parameter controls the number of records ADFm requests from the BC layer
    simultaneously. The default RangeSize is 25 records. Consider setting this value to
    the number of records to be displayed in the UI simultaneously for the View Object so
    that the number of round-trips between the model and BC layers is reduced to one.
    This is configured in the Iterator attribute of the corresponding page's page
    definition XML.
    and the purpose of FetchSize  is now clear for me but let me ask another question about VO’s rangeSize which you told is used when we use range paging. You mean that when we use range paging so the rangeSize of VO is used to fetch data from database and the FetchSize is ignored in this case? Please correct me if I am wrong.
    Ferez

Maybe you are looking for