Chr function

CREATE TABLE TEST
(NAME_NUM               CHAR (8)      DEFAULT (LPAD(CHR(0),008,CHR(0))),
ZAP_NAME               CHAR (2)      DEFAULT (LPAD(CHR(0),002,CHR(0))),
SYSC_VARIABLE          VARCHAR (230) DEFAULT (LPAD(CHR(0),230,CHR(0))),
);in above create table command what does "(LPAD(CHR(0),008,CHR(0)))" means ?

user511621 wrote:
CREATE TABLE TEST
(NAME_NUM               CHAR (8)      DEFAULT (LPAD(CHR(0),008,CHR(0))),
ZAP_NAME               CHAR (2)      DEFAULT (LPAD(CHR(0),002,CHR(0))),
SYSC_VARIABLE          VARCHAR (230) DEFAULT (LPAD(CHR(0),230,CHR(0))),
);in above create table command what does "(LPAD(CHR(0),008,CHR(0)))" means ?The chr(0) is the equivalent of a NULL, and what this function is doing is when a new record is created if there is no data supplied for the name_num, zap_name,sysc_variable then they will be filled with nulls ie NAME_NUM will have 8 nulls in it.
The function is using LPAD "left pad" to pad on the left a single null character with enough nulls to fill the field.
hope this is clear enough.
Edited by: DavidGD on Feb 9, 2009 9:58 PM

Similar Messages

  • Equivilent of Visual Basic Chr() function?

    What is an equivilent function in Java to the Chr() function of Visual Basic?
    Cheers

    How can you assume that we know what that function does? From some experience in basic 7.0 on my old C128D i remember that chr returns the ascii value of a character or the character from an ascii value - in Java "char c = (char) i;" or "int i = c;".

  • Regarding chr() function

    I am using function chr(13) in the form to get one Line(to move the remaining contents to next line). Instead of moving to next line, function is displaying some special character.
    I am using 10g forms. Whether chr(13) is supported by form or not??
    Edited by: user648759 on May 29, 2009 2:33 AM
    Edited by: user648759 on May 29, 2009 2:35 AM

    Hello,
    As well as I know chr(13) for new line is used in HTML (When we display strings in Html page).
    Regards
    Danish

  • CHR function for 18 times space?

    hi,
    Is there any function if i want 18 time space in my dbms output messages.
    I am using CHR(32) as
    DBMS_OUTPUT.PUT_LINE(chr(32)||chr(32)||chr(32)||chr(32)'** End Time ** : '||systimestamp );
    or
    DBMS_OUTPUT.PUT_LINE(' ** End Time ** : '||systimestamp );

    Like say Frank Kulash
    By default, SQL*Plus trims spaces from the beginning of each output line. To override that default, and allow spaces there, use FORMAT WRAPPED when you SET SERVEROUTPUT ON.
    SET  SERVEROUTPUT ON   FORMAT WRAPPED
    may i use also LPAD(' ',18)
    Yes
    can u explain,which 1 is good manner of programming?
    It is the same, chr(32) is ' '.
    I prefer chr(32) because is most visual. With it i understand better the code, but it is the same

  • Java equivalent to VBScript functions/operators

    I need to re-write some VBScript code to j2me code. I'd like to know if there is an equivalent to the following VBScript functions in j2me.
    Function Chr(): The Chr function converts an ANSI character code value to a character. I think I can just use char x = (char) myCharValue. correct?
    Function Asc(): The Asc function returns the ANSI character code value for the first character in a string.
    Operator Xor: The Xor operator can be used a "bitwise operator" to make a bit-by-bit comparison of two integers. If both bits are the same in the comparison (both are 0's or 1's), then a 0 is returned. Otherwise, a 1 is returned. For example: Xor performs a bitwise comparison on the 3 (in binary 011) and the 5 (in binary 101), and returns a 6 (in binary 110).

    Function Chr(): The Chr function converts an
    ANSI character code value to a character. I think I
    can just use char x = (char) myCharValue. correct?Yes
    Function Asc(): The Asc function returns the
    ANSI character code value for the first character in
    a string.
    String abc = "ABC";
    char firstchar = abc.charAt(0);
    Operator Xor: The Xor operator can be used a
    "bitwise operator" to make a bit-by-bit comparison of
    two integers. If both bits are the same in the
    comparison (both are 0's or 1's), then a 0 is
    returned. Otherwise, a 1 is returned. For example:
    Xor performs a bitwise comparison on the 3 (in binary
    011) and the 5 (in binary 101), and returns a 6 (in
    binary 110).A simple google search will give you that "^" is an xor.

  • Chr()

    What is the number for a tab for the chr() function?

    hi,
    Is 9
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL>
    SQL> SET SERVEROUTPUT ON
    SQL> BEGIN
      2     dbms_output.put_line('hi' || chr(9) || 'you');
      3  END;
      4  /
    hi     you
    PL/SQL procedure successfully completed
    SQL> Regards,

  • Creating a print button to call a Report Query and pass filters

    If i use the REPORT QUERY option in APEX 4 to create an statement that is the same one used in an interactive report, can I create a link or button to the REPORT QUERY and pass all the session and filter information from the interactive report to the report query?
    This way I can have the interactive report screen where the user can do all sorts of modifications and such and then pass those to the REPORT QUERY so I can call that from a custom link or button.
    You may ask "why does he need another print button?"
    Answer: I am using a view that has some embedded HTML tags to format the output really nicely. The HTML download version created by the interactive reports works beautifully. The customer also wants a PDF version (meh) which does not render the HTML tags and actually echos them as part of the text. I found that I can create another view that uses the CHR function to create all the breaks and such I was doing with HTML and these do render properly in PDF. So, I figured just have 2 reports: 1 Interactive and 1 using a REPORT QUERY. I just want to call the REPORT QUERY version but use the Interactive Search form to set all the parameters.
    Or, am I over thinking this and there is an easier method?
    I made a previous post where I showed how I got the APEX printing to work and i hoped that helped someone out - fixing this issue would put the whole thing to rest.
    Thanks

    Is BI Publisher desktop (MS Word add-in) a possibility? This would allow you to use MS Word to create your output template (RTF) that would result in a properly formatted PDF. Of course, you'd have to right an updated version of the query without HTML embedded. Just thinking outside of the box.

  • UTL_FILE, Extra CRFL's, possible OS interpretation problem.

    Greetings,
    DISCLAIMER:
    I am an oracle noob so if I make a mistake in forum etiquette or have not checked all available documentation or have made an assumption that is incorrect ( or noobish ) or am unaware of a tool better suited to the task I am trying to accomplish..
    Please don’t flame me, I am learning. Give me constructive replies and I will learn, I promise.
    My environment: 10G XE DB running on Server 2k3. Developing in SQLDEV 1.54
    I am attempting to dump the contents of a CLOB to a file on the OS disc. Due to formatting restrictions, the contents of the file written to disc must be EXACTLY the contents of the CLOB, character per-per character, verbatim.
    Here is an example anon block that will give you the essentials of the way I am attempting to accomplish this:
    DECLARE
    l_clob CLOB ;
    l_output_file utl_file.file_type;
    BEGIN
    l_clob := 'Hello my name is George!' || chr(13) || chr(10) ;
    l_clob:= l_clob || 'Would you like to play a game?' || chr(13) || chr(10);
    l_clob := l_clob || 'It will be fun, I promise..' || chr(13) || chr(10);
    dbms_output.put_line( dbms_lob.getlength(l_clob));
    l_output_file := utl_file.fopen( TEST_DIR' , 'test.txt' ,'W', max_linesize=> 32767 );
    utl_file.put( l_output_file , l_clob );
    utl_file.fflush( l_output_file);
    utl_file.fclose( l_output_file );
    utl_file.fclose_all;
    END;
    Here you can see where I put a few lines into my clob, I manually append the CRLF using the CHR function, since I cant accurately reproduce a non-printable character in a string value. This is important because the Clob I am attempting to write to disc contains CRLF’s as part of its data, these must be preserved. Also note that I am writing this to the file using utl_file.PUT not PUT_LINE, again, because the disk file must be the clob verbatim, I cant use put_line because it adds a “new line character” at the end of the data it writes.
    Ignore the DMBS_OUTPUT line , I will get back to that in a bit.
    I execute this bit of code and get a file text.txt. What I expected to see was:
    “'Hello my name is George!
    Would you like to play a game?
    'It will be fun, I promise..”
    What I actually got was:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp001.jpg!
    Looking at this in notepad++ we can expose the non-printable chars:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp002.jpg!
    Using notepad ++ we can see that an extra CR ( CHR(13)) has been pre-pended to the CRLF. We can confirm this is not an artifact of viewing this in notepad by looking at the file size of the output file and comparing it to the size of the clob.
    The DBMS_OUTPUT line indicates ( in my test case) clob size of 87 characters. If you take the time to count you will see this is correct. 81 printable characters that we see, and the 6 non-printable chars to accomplish the CRLF’s.
    However if we look at the file size:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp003.jpg!
    So that’s 87 + our 3 “ninja ” CR’s.
    For my purposes this is a deal-breaking problem. The contents of my output file must be exactly the contents of my clob, byte for byte. So this extra CR is a big big problem.
    Where is it coming from? I started thinking about the “new line character” that the PUT_LINE procedure uses and, had a hunch that perhaps since the DB is OS independent, it might be passing one of the non-printable chars to the OS as “new line” and letting the os worry about what that means on disk. With that in mind I did some further testing:
    DECLARE
    l_clob CLOB ;
    l_output_file utl_file.file_type;
    BEGIN
    l_clob := 'Incoming lf->'|| chr(10) ;
    l_clob:= l_clob || 'Incoming cr->' || chr(13);
    clob:= lclob || 'Incoming CRLF->' || chr(13) || chr(10);
    l_output_file := utl_file.fopen( TEST_DIR' , 'test.txt' ,'W', max_linesize=> 32767 );
    utl_file.put( l_output_file , l_clob );
    utl_file.fflush( l_output_file);
    utl_file.fclose( l_output_file );
    utl_file.fclose_all;
    END;
    This code results in:
    !http://i594.photobucket.com/albums/tt22/GargleSpam/Temp004.jpg!
    Looking at this it becomes obvious that the CHR(10) is being written to disc as TWO characters ( CR LF). So my assumption must be correct, that the DB is passing CHR(10) to the OS as “newline” and the OS ( Windows in my case ) is interpreting this as ‘CRLF.’
    This makes sense since it seems to be widely known ( though not to me , I am shaky on this part ) that “newline” in unix is just CHR(10), and in windows its CHR(10)||CHR(13).
    So I seem to have isolated my problem. Now finally my question.. How to I get around this?
    Google searches and searches on this forum yeilded only marginal help, something about passing this file through an FTP server.. ?. The only marginal help was in post # 3298335. Nothing that really answers my question though.
    Is there a setting my DBA can set to change this behavior? Is there a different way ( PLSQL) to write the file that might mitigate this? Don’t say put the DB on unix, that’s not an option.
    Let me know what you think…
    -VAF

    Hi,
    Also you should check that the directory name is enclosed between '. TEST_DIR is an Oracle directory object that maps a real directory path in the filesystem (check privileges).
    Like:
    DECLARE
        l_clob CLOB;
        l_output_file utl_file.file_type;
    BEGIN
        l_clob := 'Hello my name is George!' || CHR(13) || CHR(10);
        l_clob := l_clob || 'Would you like to play a game?' || CHR(13) || CHR(10);
        l_clob := l_clob || 'It will be fun, I promise..' || CHR(13) || CHR(10);
        dbms_output.put_line(dbms_lob.getlength(l_clob));
        l_output_file := utl_file.fopen('TEST_DIR', 'test.txt', ' W', max_linesize => 32767);
        utl_file.put(l_output_file, l_clob);
        utl_file.fflush(l_output_file);
        utl_file.fclose(l_output_file);
    END;Tip: to post formatted code you must enclose it between {noformat}{noformat} tags (start and end tags are the same).
    Regards,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to insert some special Characters  in a table

    Dear All
    I have a value with some italian Characters ..
    Like :- )
    e l’attivazione - Here the ' symbol is not single quote , it is some ITALIAN characters .
    So how can i insert .
    I have value like :- e l’attivazione "Trasloco Linea Telefonica”, disponibili sul portale TUO, sezione Accessi/Traslochi"
    Insert into ABC values ('e l’attivazione "Trasloco Linea Telefonica”, disponibili sul portale TUO, sezione {code}Accessi/Traslochi"');                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Hey,
    You can run below command to insert such value in single column of the table.
    INSERT INTO ABC VALUES ('e l’attivazione "Trasloco Linea Telefonical, disponibili sul portale TUO, sezione Accessi/Traslochi"');
    or you need to get ascii value of the character '’'
    e.g.
    SELECT ASCII('’') FROM dual;
    O/P
    14844057
    then use this ASCII value in CHR function while inserting data into table
    INSERT INTO ABC VALUES ('e l'||CHR(14844057)||'attivazione "Trasloco Linea Telefonical, disponibili sul portale TUO, sezione Accessi/Traslochi"');
    When you will query the data from table you be get below value for that column.
    e l’attivazione "Trasloco Linea Telefonical, disponibili sul portale TUO, sezione Accessi/Traslochi"
    Regards,
    Nisarg

  • How to search for a new line character in sql

    hi..i am using oracle 10g.
    basically i am looking for usage of columns.I want to see which all columns are used in
    joins.
    this is the quey i have written.
    but
    if there a new line between WHERE ,AND those scenarios are ignored.how to take care of these new line characters?
    SELECT DISTINCT s.TYPE, s.NAME, s.owner, table_name, column_name --,line,text
    FROM all_source s, cols c, all_dependencies d
    WHERE s.NAME = d.NAME
    AND d.referenced_name = c.table_name
    AND c.table_name = 'WSF_EDUCATION_ORGUNIT'
    AND column_name ='ORGUNIT_TYPECODE_OID'
    AND d.TYPE = s.TYPE
    AND d.TYPE <> 'PACKAGE'
    AND d.owner = s.owner ---FOR OVERLOADED OBJECTS
    AND ( (UPPER (text) LIKE
    '%' || 'AND' || '%' || column_name || ' ' || '=%'
    OR (UPPER (text) LIKE
    '%' || 'AND' || '%=' || ' ' || '%' || column_name
    || '%'
    UNION ---if there is where
    SELECT DISTINCT s.TYPE, s.NAME, s.owner, table_name,
    column_name ----,line,text
    FROM all_source s, cols c, all_dependencies d
    WHERE s.NAME = d.NAME
    AND d.referenced_name = c.table_name
    AND c.table_name = 'WSF_EDUCATION_ORGUNIT'
    AND column_name ='ORGUNIT_TYPECODE_OID'
    AND d.TYPE = s.TYPE
    AND d.TYPE <> 'PACKAGE'
    AND d.owner = s.owner ---FOR OVERLOADED OBJECTS
    AND ( (UPPER (text) LIKE
    '%' || 'WHERE' || '%' || column_name || ' ' || '=%'
    OR (UPPER (text) LIKE
    '%' || 'WHERE' || '%=' || ' ' || '%' || column_name
    || '%'
    )

    Hi,
    Not sure if I get it, but you can look for characters using the ascii and chr functions.
    You can change them using replace:
    A new line:
    SQL> select ascii('
      2  ') from dual;
    ASCII('')
            10(Just press enter between the quotes)
    Example how to replace it with a space:
    SQL> with t as ( -- generating test string:
      2  select 'this string has
      3  a new line' str from dual
      4  )
      5  --
      6  -- actual query:
      7  --
      8  select str
      9  ,      replace(str, chr(10), chr(32))
    10  from   t;
    STR                        REPLACE(STR,CHR(10),CHR(32
    this string has            this string has a new line
    a new lineIf that isn't clear of when I'm missing the point then please post some narrowes down examples of what you get now and your desired output. Remember to put the tag around any code example you're posting.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Filtering out field which include 2 underscores

    I was wondering if anyone has an example of code which you can exclude data which includes 2 underscores next to each other.
    Here is my query which doesn't work:
    SELECT i.interface_id,
    i.interface_name,
    s.site_id,
    s.site_name,
    s.database_server_id
    FROM interfaces i,
    sites s,
    companies c
    WHERE i.site_id = s.site_id
    AND s.company_id = c.company_id
    AND c.company_id = :company_id
    AND s.site_name NOT LIKE '%__%';
    I was thinking of using the CHR() function in the where clause but can find no example of this being done.
    Any help would be appreciated.
    Thanks
    ReedK

    Hi Reed,
    you can specify an escape character (preferably one that doesn't exist in your site_names).
    SELECT i.interface_id,
           i.interface_name,
           s.site_id,
           s.site_name,
           s.database_server_id
    FROM   interfaces i,
           sites s,
           companies c
    WHERE  i.site_id = s.site_id
    AND    s.company_id = c.company_id
    AND    c.company_id = :company_id
    AND    s.site_name NOT LIKE '%\_\_%' escape '\';Jens

  • Filtering out rows which include 2 underscores

    I was wondering if anyone has an example of code which you can exclude data which includes 2 underscores next to each other.
    Here is my query which doesn't work:
    SELECT i.interface_id,
    i.interface_name,
    s.site_id,
    s.site_name,
    s.database_server_id
    FROM interfaces i,
    sites s,
    companies c
    WHERE i.site_id = s.site_id
    AND s.company_id = c.company_id
    AND c.company_id = :company_id
    AND s.site_name NOT LIKE '%__%';
    I was thinking of using the CHR() function in the where clause but can find no example of this being done.
    Any help would be appreciated.
    Thanks
    ReedK

    Hi Reed,
    don't confuse the SQLPlus "escape", with the escape in SQL LIKE clauses.
    This is the ANSI syntax for LIKE regardless whether your are using PL/SQL, SQLPlus or something else.
    SELECT i.interface_id,
           i.interface_name,
           s.site_id,
           s.site_name,
           s.database_server_id
    FROM   interfaces i,
           sites s,
           companies c
    WHERE  i.site_id = s.site_id
    AND    s.company_id = c.company_id
    AND    c.company_id = :company_id
    AND    s.site_name NOT LIKE '%\_\_%' escape '\';Jens

  • Where clause and Dates

    I am creating a coditional query for one of my data blocks.
    What I need to do is build a where clause on the fly and pass
    that back to my block using the Set_BLock_Property built in. I
    am able to do this but I am having problems with the fact that I
    don't know how to correctly pass a date back. It seems when
    specifying a date in a where clause it needs to have single
    quotes around this. But when ever I try to embed the quotes in
    the string I am not successful. I have even tried appending the
    quotes using the chr function doing something like.
    Where_Clause := 'Birthday <= '

    Spencer,
    I think chr(39) will give you the correct character. For example,
    Where_Clause := 'Birthday <= '

  • Need to find out extended ASCII characters in database

    Hi All,
    I am looking for a query that can fetch list of all tables and columns where there is a extended ASCII character (from 128 to 256). Can any one help me?
    Regards
    Yadala

    yadala wrote:
    Hi All,
    I am looking for a query that can fetch list of all tables and columns where there is a extended ASCII character (from 128 to 256). Can any one help me?
    Regards
    YadalaThis should match your requirement:
    select t.TABLE_NAME, t.COLUMN_NAME from ALL_TAB_COLUMNS t
    where length(asciistr(t.TABLE_NAME))!=length(t.TABLE_NAME) 
    or length(asciistr(t.COLUMN_NAME))!=length(t.COLUMN_NAME);The ASCIISTR function returns an ASCII version of the string in the database character set.
    Non-ASCII characters are converted to the form \xxxx, where xxxx represents a UTF-16 code unit.
    The CHR function is the opposite of the ASCII function. It returns the character based on the NUMBER code.
    ASCII code 174
    SQL> select CHR(174) from dual;
    CHR(174)
    Ž
    SQL> select ASCII(CHR(174)) from dual;
    ASCII(CHR(174))
                174
    SQL> select ASCIISTR(CHR(174)) from dual;
    ASCIISTR(CHR(174))
    \017DASCII code 74
    SQL> select CHR(74) from dual;
    CHR(74)
    J
    SQL> select ASCII(CHR(74)) from dual;
    ASCII(CHR(74))
                74
    SQL> select ASCIISTR(CHR(74)) from dual;
    ASCIISTR(CHR(74))
    J

  • IN Operator Query

    Hi all,
    I have table origin which contains city name,which is of datatype varchar2;
    Am running the query on oracle 10g
    WITH t
    AS
    SELECT 'BANGALORE,BELLARY,SIRSI,HUBLI' colnm
    FROM dual
    select colnm from tand am getting output as
    BANGALORE,BELLARY,SIRSI,HUBLIBut the desired output to be displayed in singe quotes for each of the city
    Expected Output
    'BANGALORE','BELLARY','SIRSI','HUBLI'Please suggest a approach to acheive the desired result. Is this possible to acheive the result by using collections???
    Regards,
    Achyut

    Another way can be to use CHR function to give you single quote which can be concatenated to rest of string:
    WITH t
            AS (SELECT    CHR (39)
                       || 'BANGALORE'
                       || CHR (39)
                       || ','
                       || CHR (39)
                       || 'BELLARY'
                       || CHR (39)
                       || ','
                       || CHR (39)
                       || 'SIRSI'
                       || CHR (39)
                       || ','
                       || CHR (39)
                       || 'HUBLI'
                       || CHR (39)
                          COLUMNS
                  FROM DUAL)
    SELECT *
      FROM t;Result:
    Columns
    'BANGALORE','BELLARY','SIRSI','HUBLI'

Maybe you are looking for

  • Help needed in implementing Cisco Unity SSO using SAML

    Hello, I am aware that Cisco Unity 8.x  has a SSO checklist that requires: - Cisco Unity - MS AD on Win2003/8 - Open AM - Apache Tomcat 7.0 We already have a single sign-on solution at our organization that uses the Novell Access Manager (NAM). Would

  • How to set "embed icc Profile" option  to export document as JPEG

    Hi All, While exporting the document as jpeg, through File->Export, there is an option "Embed ICC Profile" as figure shows. How to set it if I am exporting the document through my program in which I rasterize the document and used  the sAIImage->AsJP

  • Sender IDoc

    Hi All, I have aquick question on sender IDoc Scenarios. I have done by WE20 settings in Sender R3 System for a given IDoc. Also I have done the IDX1 setings in XI system. The configurations are also done in XI. So when I trigger thr IDoc from the R3

  • Need Advice on improving script processing and ensuring completion

    Hi, I have a program in which I am running a number of for loops which are doing a number of different things.  I pull in data from an xml file and then step through that data to dynamically create arrays, populate the arrays, and create and modify m

  • Debugging Personalization Issues

    Hi, While trying to hide some columns in an advanced table, I set their rendered property to FALSE at the responsibility level. At that time, it gave me an error message Setting rendered to false may hide this item and its children. The application m