Passing a CHAR type variable to to_date

I am loading and transforming some legacy main frame data that stores dates in a Julian format number field, roughly an Oracle RRDDD date format. Some date between 2000 and 2009 drop the leading 0s, for example in 2009, giving a data like 931, which could be Jan 1, 1993 or  Jan 31, 2009. I can stuff a leading zero(s) on the number field to give me '0931' in a char field, which my Oracle top_date will interpret as Jan 31 2009 with the correct mask 'RRDDD." BUT, I cannot find a way to pass my character sting '0931' which is a variable to my my Oracle to_date, which seems to want the enclosing single quotes, even from a character variable:
Thus
my_Julian_date = 345  --  Is February14  ,2003, leading 0's not available from legacy source |
                                                                                                                                                    |
SELECT TO_DATE('00345', 'RRDDD') FROM DUAL    returns 14-FEB-03    OK                     |
SELECT TO_DATE(345, 'RRDDD')      FROM DUAL    returns 14_FEB-03    OK too              |
                                                                                                                                                    |
but if I put my date as character into a variable,                                                                        |
DECLARE my_date VARCHAR2(5);                                                                                         |
BEGIN                                                                                                                                       |
    my_date   := '00345' ;                                                                                                           |
    SELECT TO_DATE(   my_date, "RRDDD') ... fail to read my_date                                     |          /* please ignore that this select from DUAL won't work */
    SELECT TO_DATE('|| my_date||', "RRDDD') ...                                                                  |            /* with the my_date variable, The issue is to_date accepting a variable value */
How can a pass a varchar2 or char VARIABLE  with a VALUE like '00345' to TO_DATE?

Thanks,
but maybe I wasn't good at my description. My source file has a field cit_dte which is a numeric 5 digit representation of a Julian year of form RRDDD. It drops leading zeros for years 2000 to 2009 and would have a value lke  332 for February 1, 2003, or 4365 for 04365, thus resolving to incorrectlly to 65th day of 1943 or 365th day of 2004 with the leading 0,
I need to pass a string like 0421  as a char variable value, my_date, rather than a hard coded string, to to_date like ...
                   TO_DATE(my_char_date,'RRDDD')
rather than TO_DATE('0421','RRDDD')
In your example, you are hard coding the '00345' into to the my_date VARCHAR2 (5) variable but I have to load my_date from a function call IN variable of numbere type, after converting the IN parameter number type to the my_date varchar2 (5) variable.
My flow is  (1.)    NUMBER --> (into function ny_date()  as a number type)
                  (2.)  --> convert parameter IN number type to my_date VARCHAR2(5) variable with leading 0s added as needed (in a case statement)
                  (3.) --> pass variable my_date [character string] to  TO _DATE()
BUT, TO_DATE only seems to accept hard coded character strings. likle '0421' an not a varchar2 variale with a value of 0421. I tried prepedning the parameter into to_date with
...to_date:'||my_date||' , RRDDD) to wrap some single quotes aroudnt he my_date variable value, but that does not work.

Similar Messages

  • What target property must be specified while passing a object type variable to child package in SSIS 2012

    What target property must be specified while passing a object type variable to child package in SSIS 2012???

    As shown below, there is variable strVar and it's Value property is selected. Likewise you have to select the property that you need to pass.
    Please refer:
    http://www.bidn.com/blogs/MikeDavis/ssis/155/passing-variable-values-from-parent-package-to-child-ssis
    -Vaibhav Chaudhari

  • How to pass one sapce to char type variable

    Hi,
    There is one import parameter in rfc "zstat" with char type and length 1. I want to pass value equal to one space in this variable during execution of RFC so that it passes the condition in code where it is not initial.
    But during runtime it doesnt store value equal to one space and become initial.
    So my question is how to pass value equal to one sapce to this variable.?
    Thanks in Advance!!!
    -Harkamal

    Hi!
    If it a char type, then its initial value is a SPACE character.
    If it confuses the program and you wanted to use it another way, then use numbers (type i - integer). It's initial value is "0".
    Or try to use other flag characters, like "T" for true and "F" for false values.
    Regards
    Tamá

  • How to pass table type variable into function from SQL*PLUS ?

    How to pass a table type variable from sql*plus prompt into a function ?
    Thanx in advance.

    Krishna,
    Do you mean like this?SQL> DECLARE
      2      TYPE t_tbl IS TABLE OF VARCHAR2(20);
      3      l_sample_tbl           t_tbl;
      4
      5      FUNCTION print_contents ( p_tbl IN t_tbl )
      6      RETURN VARCHAR2
      7      IS
      8          l_string            VARCHAR2(1000);
      9      BEGIN
    10          FOR i IN 1..p_tbl.COUNT LOOP
    11              IF (i = 1) THEN
    12                  l_string := p_tbl(i);
    13              ELSE
    14                  l_string := l_string || ', ' || p_tbl(i);
    15              END IF;
    16          END LOOP;
    17          RETURN (l_string);
    18      END print_contents;
    19
    20  BEGIN
    21      l_sample_tbl := t_tbl();
    22      l_sample_tbl.EXTEND;
    23      l_sample_tbl(1) := 'one';
    24      l_sample_tbl.EXTEND;
    25      l_sample_tbl(2) := 'two';
    26      l_sample_tbl.EXTEND;
    27      l_sample_tbl(3) := 'three';
    28      l_sample_tbl.EXTEND;
    29      l_sample_tbl(4) := 'four';
    30      l_sample_tbl.EXTEND;
    31      l_sample_tbl(5) := 'five';
    32      DBMS_OUTPUT.PUT_LINE(print_contents(l_sample_tbl));
    33  END;
    34  /
    one, two, three, four, five
    PL/SQL procedure successfully completed.
    SQL> HTH,
    T.

  • Pass PL/SQL Record variable to Stored procedure in Java

    Can some one please give me a code snippet for passing a Record Type variable returned by Stored Procedure. Following is the scenario.
    A record type variable REC_VAR is made of three columns of a table as follows
    EmpNo Number, Empname Varchar2(50), Zip_Code Varchar2(5).
    I am populating this variable in Java code and passing it to Stored Procedure.
    Can I referance Record Type variable in a Oracle package from Java code.
    How would I define these variables as per table’s column type and pass to SP in a java program.
    Thanks,

    58838,
    The following entry -- from the Ask Tom Web site may be helpful (assuming you haven't already seen it):
    how to access variable
    If it doesn't help, you can always search the site.
    Good Luck,
    Avi.

  • Transfer a char type varialble value to NUMC type variable

    Hi all,
    I have a BSEG-PROJK  type NUMC(8) variable and one xyz type CHAR(50)  variable.
    I have to pass value from xyz to BSEG-PROJK
    my e.g is that while I am passing
    xyz= 'M-000064'
    BSEG-PROJK  = xyz
    then the value of BSEG-PROJK is 00000064 but i need M-000064

    Hi,
    The value M-000064 is showing in field PROJK of BSEG, due to the conversion routine ABPSP attached in the domain level of this field.
    - To check the actual value stored in data base level
    - SE16 Give table name=>to see the table contents Press F7=>settings=>user parameters=> uncheck the check box check conversion exit.
    - now the value in field PROJK will show in numeric.
    Regards
    DKS

  • Forms: Oracle AS 10g R2 - parameter with "char" type only limit to 4k

    Hi,
    i have one forms with parameter ":parameter.whole_rights" (Datatype=Char, Length=32767) over design time.
    when i compiled and execute it in old server (Oracle AS 10g R1), it work perfectly but when compiled and execute it over the 10gr2, it always show ora-06502: pl/sql: numeric or value error.
    after some troubleshooting, i found out that the maximum length for "char" type parameter is only 4k. if i assign any string larger than 4k characters, it will show the error as per mentioned but it work on old server...
    anyone have this problem and how to resolve it???
    additional information:
    server is on unix environment.
    Edited by: cy82 on Jun 15, 2010 3:35 AM

    Hi there,
    the application does not use up all the 32k characters, the maximum length it use currently is around 6k.
    the parameter is used to store all the available access right (forms name, button/object name, read, write etc which is very customized & application specific design). every related access right in that parameter will be passed seperately into related form when the form is called to control the view, transaction nature etc.
    as the design involve other system who passed the data in, i not really plan to change it as it involve interface between 2 systems instead try other possible ways (simple and less impact).
    i think i should not say it use up all 32k, i just curious why the application declare the length as 32k over the forms design time but the actual length was only limited to 4k during forms execution time on Oracle AS r2.
    thanks for suggesting me to try the copy build in and i will try it & post the result tomorrow. i think it should work because i saw your quote for the documentation here:
    In Oracle Forms 10g, all parameters of datatype CHAR are limited to 4000 bytes when set or referenced using PL/SQL bind variable notation; for other usages no limit is imposed.
    as the "copy" build in does not use the parameter as PL/SQL bind variable, quite large posibilities it works...will try and update the result tomorrow....
    another question: where did you get the documentation for oracle forms?? i'm searching around and still cant find the quote that you copy from documentation. hopefully you can give me the link for my future reference.
    Edited by: cy82 on Jun 16, 2010 9:58 PM

  • How to Change Date-Type to Char-Type with Format?, When it.....

    I'd like to Change format Data from Date-Type Column to char-type
    especially, as 'YYYYMMDD' Format, But There are some Error Message.
    I already know, to_char(sysdate, 'yyyymmdd') from dual,
    But When it Applied my Table (has Date Type Column )....
    That SQL was Error...
    Table Description
    ===================
    GUBUN     NOT NULL     NUMBER(7)
    POLCD     NOT NULL     NUMBER(7)
    TITLE          VARCHAR2(200)
    VALUE          NUMBER(7)
    SIDATE          VARCHAR2(20)
    SQL
    ================================
    SELECT TO_CHAR(SIDATE,'YYYYMMDD') as V_SIDATE , -- <== Error
    TO_CHAR(SYSDATE,'YYYYMMDD') as V_TODAY -- <== Ok
    FROM T_POLL
    Error Msg
    ================================
    ORA-01722: invalid number
    .....I don't know Why... plz. help me, it's Urgent...-_-;
    ICQ : 40751557
    MSN : [email protected]
    Finally, sorry for my poor English...

    The reason for the error is you are applying a TO_CHAR function to a character datatype. SIDATE is a character. That field should be a date field. If for some reason, you need it to stay as a character field then you will need to change it to a date then change it back to a character.
    TO_CHAR(TO_DATE(SIDATE,'put format here'),'YYYYMMDD')

  • Record type variables in the SQL database trace file

    Hi,
    I turned on the trace with binds and waits in a ebusiness form and captured the database SQL trace file. It lists the values for the generic datatypes for the call, but does not list the values of record type variables. Is there a way to identify the values of record type variables? The below section lists the procedure call and the values passed. Thanks in advance.
    RPC CALL:PROCEDURE APPS.HZ_PARTY_SEARCH.FIND_PARTY_DETAILS(P_INIT_MSG_LIST IN VARCHAR2, P_RULE_ID IN NUMBER, P_PARTY_SEARCH_REC IN PARTY_SEARCH_REC_TYPE, P_PARTY_SITE_LIST IN PARTY_SITE_LIST, P_CONTACT_LIST IN CONTACT_LIST, P_CONTACT_POINT_LIST IN CONTACT_POINT_LIST
    , P_RESTRICT_SQL IN VARCHAR2, P_MATCH_TYPE IN VARCHAR2, P_SEARCH_MERGED IN VARCHAR2, X_SEARCH_CTX_ID OUT NUMBER, X_NUM_MATCHES OUT NUMBER, X_RETURN_STATUS OUT VARCHAR2, X_MSG_COUNT OUT NUMBER, X_MSG_DATA OUT VARCHAR2);
    RPC BINDS:
    bind 0: dty=1 bfp=2ae5927c13c8 flg=08 avl=01 mxl=01 val="T"
    bind 1: dty=6 bfp=2ae5927c13f0 flg=00 avl=02 mxl=22 val=8
    bind 2: dty=118 bfp=2ae593432e48 flg=00 avl=00 mxl=00 val=00
    bind 3: dty=251 bfp=2ae5929ac0b8 flg=00 avl=1944 mxl=00 val=00
    bind 4: dty=251 bfp=2ae592d85548 flg=00 avl=5336 mxl=00 val=00
    bind 5: dty=251 bfp=2ae592d84d58 flg=00 avl=4984 mxl=00 val=00
    bind 6: dty=1 bfp=2ae5927c1550 flg=08 avl=125 mxl=2000 val="exists (select 'x' from hz_parties where party_id =stage.party_id and party_type = 'ORGANIZATION') and party_id <>1002277174"
    bind 7: dty=1 bfp=2ae5927c1d50 flg=0a avl=00 mxl=00 val=""
    bind 8: dty=1 bfp=2ae5927c1d80 flg=08 avl=01 mxl=01 val="I"
    bind 9: dty=6 bfp=2ae5927c1da8 flg=02 avl=00 mxl=22 val=00
    bind 10: dty=6 bfp=2ae5927c1de0 flg=02 avl=00 mxl=22 val=00
    bind 11: dty=1 bfp=2ae5927c1e28 flg=0a avl=00 mxl=01 val=""
    bind 12: dty=6 bfp=2ae5927c1e50 flg=02 avl=00 mxl=22 val=00
    bind 13: dty=1 bfp=2ae5927c1e98 flg=0a avl=00 mxl=2000 val=""

    Hello,
    From the sounds of it, when you are adding a child the application is not maintaining the Company's reference to it. For instance, in a 1:M and M:1 relationship, the application seems to be setting only the M:1 part (child to parent) which will cause the database to be updated, but both sides need to be set to keep the cache in synch with the database.
    Setting the cache type to be none is not a good idea - it prevents any caching, which will hurt performance and object identity. What instead is recommended is disabling the shared cache using the
    toplink.cache.shared.<ENTITY>=false property. This still might not help though if the Company's reference to the child hasn't been set as mentioned above if you are reading Company from the same context you are adding the child.
    The Cache is described for TopLink Essentials in the blog at:
    http://weblogs.java.net/blog/guruwons/archive/2006/09/understanding_t.html
    Best Regards,
    Chris

  • Variable Decimal of Packed Type Variable: is this possible?

    Hi Experts,
    I'd like to ask if we can have a packed variable with the decimal declaration as variable also, like:
    DATA p_pack_var TYPE p DECIMALS g_var_decimal.
    The scenario is there is a field qamv-toleranzun which I want to be displayed like in the output in QP03. The display in QP03 has variable decimals according to the value in qamv-masseinhsw.
    So for example: qamv-masseinhsw = 3 and qamv-toleranzun is a floating type value, the output in QP03 is format with 3 decimals.
    Or if this is not possible, are there any approach to pass the value of the floating point variable to a decimal type variable with an indefinite decimal places.
    Please Help. Points will be rewarded for valid answers.
    Thanks!

    Is this what you want?
    searchComponents( Class a_class) {
    // browse components
    if (a_class.isInstance(component)) {
    // do something
    }

  • Converting CHAR type to other data types

    Dear SDN users,
    would any of you know how to convert a CHAR data type to other data types for example hexadecimal etc., and convert them back? I suspect there must be some standard FMs available.
    Thankyou for your responses.
    Regards,
    Smitha

    Hello smitha ,
        I suppose you are assigning some  variable of char type to a variable of integer type it will automaticaly (implicitly ) convert the type .
    in some case we need to change the type explicitly like the above mentiioned .
    Thanks and regards ..
      Priyank

  • Can we move char type data to packed decimal

    Hi
    can we move char type data to packed decimal??
    Thanks
    Devi

    Hi..
    that depends on the data in the character variable..
    if that character variable contains onli numbers then it is possible.
    <b>data c type c value '1'.
    data p type p.
    p = c.
    write p.</b>
    here the output is  1.
    If it contains even a single Alphabet , then it goes for a dump.
    <b>data c type c value 'A'.
    data p type p.
    p = c.
    write p.</b>
    here u will get a short dump.
    hope u understood.
    regards,
    sai ramesh

  • Error passing in RECORD type into API

    Gurus,
    Getting the following error when I try and pass a RECORD type into an API. Am I passing it in properly?
    Any help is appreciated.
    Thanks,
    -Scott
    Here's my error:
    fnd_descr_flex_col_usage_pkg.load_row
    ERROR at line 21:
    ORA-06550: line 21, column 4:
    PLS-00306: wrong number or types of arguments in call to 'LOAD_ROW'
    ORA-06550: line 21, column 4:
    PL/SQL: Statement ignored
    Here's my anon block:
    declare
    TYPE who_type IS RECORD
    created_by NUMBER,
    creation_date DATE,
    last_updated_by NUMBER,
    last_update_date DATE,
    last_update_login NUMBER
    v_who_type who_type;
    v_sysdate date;
    begin
    select sysdate
    into v_sysdate
    from dual;
    v_who_type.created_by := 0;
    v_who_type.creation_date := v_sysdate;
    v_who_type.last_updated_by := 0;
    v_who_type.last_update_date := v_sysdate;
    v_who_type.last_update_login := 0;
    fnd_descr_flex_col_usage_pkg.load_row
    (x_application_short_name => 'SPL',
    x_descriptive_flexfield_name => 'HR_LOCATIONS' ,
    x_descriptive_flex_context_cod => '441',
    x_application_column_name => 'ATTRIBUTE5',
    x_who                          =>  v_who_type,
    x_end_user_column_name => 'District',
    x_column_seq_num => 10,
    x_enabled_flag => 'Y',
    x_required_flag => 'N',
    x_security_enabled_flag => 'N',
    x_display_flag => 'Y',
    x_display_size => 50,
    x_maximum_description_len => 50,
    x_concatenation_description_le => 25,
    x_flex_value_set_name => '50 Characters',
    x_range_code => '',
    x_default_type => '',
    x_default_value => '',
    x_runtime_property_function => '',
    x_srw_param => '',
    x_form_left_prompt => 'District',
    x_form_above_prompt => 'District',
    x_description => '');
    ...

    I followed Tubby's advice and called the package to which the RECORD type was defined, however, I'm getting a "no data found" error in the called package. The purpose of "internally" definining the record type inside my Anon block was so that I could assign variables locally.
    Help from you gurus would be greatly appreciated!
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at "APPS.FND_DESCR_FLEX_COL_USAGE_PKG", line 508
    ORA-06512: at line 21
    Please do not refer me to any more EBS forums or links.  This is a coding question, not an EBS question.
    For the guy who asked, here is the procedure definition:
    PROCEDURE load_row
    (x_application_short_name IN VARCHAR2,
    x_descriptive_flexfield_name IN VARCHAR2,
    x_descriptive_flex_context_cod IN VARCHAR2,
    x_application_column_name IN VARCHAR2,
    x_who IN fnd_flex_loader_apis.who_type,
    x_end_user_column_name IN VARCHAR2,
    x_column_seq_num IN NUMBER,
    x_enabled_flag IN VARCHAR2,
    x_required_flag IN VARCHAR2,
    x_security_enabled_flag IN VARCHAR2,
    x_display_flag IN VARCHAR2,
    x_display_size IN NUMBER,
    x_maximum_description_len IN NUMBER,
    x_concatenation_description_le IN NUMBER,
    x_flex_value_set_name IN VARCHAR2,
    x_range_code IN VARCHAR2,
    x_default_type IN VARCHAR2,
    x_default_value IN VARCHAR2,
    x_runtime_property_function IN VARCHAR2,
    x_srw_param IN VARCHAR2,
    x_form_left_prompt IN VARCHAR2,
    x_form_above_prompt IN VARCHAR2,
    x_description IN VARCHAR2)

  • Changing itab to char type

    hi mates,
    im having an itab which has int, char, decimal types fields in it. now i need to translate the itab to uppercase. when i use the statement " translate itab to uppercase." im getting error stating itab should be of type char.
    how can i make the itab of type char. any help will be appreciated...
    regards
    mano

    Hi,
    consider you have the workarea of you output table structure.
    after assigning all the field value u will do append to internal table.
    declare a string type variable
    l_string type string.
    clear l_string.
    l_string = 'abcd'.
    translate l_string to uppercase.
    wa_output -field1 =  l_string.
    append wa_output to t_output.
    clear wa_output.

  • Assigning value to array type variable in a loop

    Hi
    I have a scenario in which i am assigning value from a array type variable(x) to the invoke variable of a database adapter. The variable x is exact replica of the invoke variable.
    My copy operation in assign activity looks like this-
    <copy>
    <from variable="Var" part="InputParameters"
    query="/ns7:InputParameters"/>
    <to variable="Invoke_call_XXDPI_EDI_852_PKG_InputVariable"
    part="InputParameters"
    query="/ns7:InputParameters *(* bpws:getVariableData('iterator') *)* "/>
    </copy>
    It is inside a while loop activity.
    PS *()* are square brackets
    But it is erroring out at run time.
    Does anybody has an alternate idea to assign value to an array type?.
    i have seen that while extracting value from an array type variable it works fine
    A similar kind of operation is shown below.
    <copy>
    <from variable="Var" part="InputParameters"
    query="/ns7:InputParameters *(* bpws:getVariableData('iterator') *)* "/>
    <to variable="Invoke_call_XXDPI_EDI_852_PKG_InputVariable"
    part="InputParameters"
    query="/ns7:InputParameters"/>
    </copy>
    Thanks
    Ayush
    Edited by: Ayush fujitsu on Aug 14, 2009 4:36 AM

    Hi Ayush
    I suppose you are getting some error like "source node returns multiple elements".
    In second case there is no problem because you are assigning *InputParameters[bpws:getVariableData('iterator')]* (+suppose InputParameters[1]+) to target. Here it works fine because you are fetching oonly 1 value from source and assigning it to the target.
    Now in first case you are saying copy InputParameters to target[1] suppose. You know that source is an array which contains multiple index so which index field from the source will be assigned to the target.
    Try your process with only 1 source value it will work but when multiple values will be there it will fail. You have to merge both the cases and it will look like
    *<copy>*
    *<from variable="Var" part="InputParameters"*
    query="/ns7:InputParameters ( bpws:getVariableData('iterator') ) "/>
    *<to variable="Invoke_call_XXDPI_EDI_852_PKG_InputVariable"*
    part="InputParameters"
    query="/ns7:InputParameters ( bpws:getVariableData('iterator') ) "/>
    *</copy>*
    And the easiest way to do this is by the transform activity as said above.
    Regards
    Suryaveer
    Edited by: Suryaveer on Aug 15, 2009 11:19 PM

Maybe you are looking for

  • 2-PC's - with 1-Itunes account?

    I have a PC at home with Itunes, which I use to sync my IPhone.  I have an extensive library of music and movies in Itunes.  I have a netbook for travel and would like to put the itunes library on that as well?  (easier to watch my movies on)-I will

  • HT5071 Can I publish my work produced with iBooks Author and make it available (free of charge) for my students only?

    Can I publish my work produced with iBooks Author and make it available (free of charge) for my students only?

  • I need help with a Muvo 2 fm (

    I recently bought a muvo 2 fm(5g) from a friend, and by mistake i entered the recovery mode and i think i erased the firmware. When i reboot from the recovery mode a message apears " firmware error"! and the recovery mode opens! I don't have any soft

  • OT: site hacked or what?

    My site is hosted over at HostMySite and since around the middle of Jan I have noticed that its not doing that well with google search. Checked Webmaster tools for top searches and noticed it listing some dodgy phrases When I do a search for that phr

  • Stack protecion under Arch ?

    I found an article on the Internet here about stack protection testing, and found that Arch lack that feature.  I would like to know how easy or difficult stack protection can be added to Arch Linux, and if it's a good thing to have it, or a waste of