Variable-length string

Hello.
I need pl/sql function with a parameter, it should looks like:
 
CREATE OR REPLACE FUNCTION GenerateStringOfZeroes( Length IN NUMBER ) 
return VARCHAR2 AS
BEGIN
return ...
END
It must return a string of zeros with a length as it incoming parameter.
for example
GenerateStringOfZeroes (9);

"should return: ' 000000000";

What is the best way to do it?
Thank you!

return lpad ('0', '0', length);

Concerning

Tags: Database

Similar Questions

  • Stuck on query Substr() for variable length strings

    I have these sample data:
    GET sampledata
    WITH sampledata AS
         (SELECT '/customizations/ams/apps/oracle' v1 FROM DUAL
          UNION ALL
          SELECT '/customizations/webui/main/repository/developer/cz/apps/oracle' FROM DUAL
          UNION ALL
          SELECT '/customizations/webui/audit/oie/ap/apps/oracle' FROM DUAL)
    SELECT sampledata.v1 aa
      FROM sampledata;
      
    AA
    ------------------------------------------
    /customizations/ams/apps/oracle
    /customizations/webui/main/repository/developer/cz/apps/oracle
    /customizations/webui/audit/oie/ap/apps/oracle
    What I would really like to do is to extract the value between the slashes appearing before "/ apps/oracle /.

    If in the examples above, I want to extract:
    ams
    cz
    ap
    The problem is that the position of this element varies. In the sample data "AMS" appears after the 2nd slash, 'cz' after the 6th and "ap" after the 5th.

    I can get the value by one simple example:
    GET sampledata
    WITH sampledata AS
         (SELECT '/customizations/ams/apps/oracle' v1
            FROM DUAL)
    SELECT sampledata.v1 aa
         , substr(sampledata.v1,17, instr(substr(sampledata.v1,17),'/')-1) aj
    from sampledata;  
    
    AA                              AJ
    ------------------------        ---------------------
    /customizations/ams/apps/oracle ams
    But of course, it is useless, that the segment I want to put the hand isn't always in the same place.

    Any advice much appreciated!

    Thank you

    Hello

    If you're on g 10 (or higher), try regular expressions:

    SELECT sampledata.v1 aa,
           regexp_replace(v1, '^.*/([^/]+)/apps/oracle.*$', '\1') aj
    FROM sampledata;
    
  • Format analysis of the measurement data of variable length for Newport THP/N

    I try to analyse the response of a sensor of zED-THP/N of Newport. The answer is back with ID SEQ TYPE TEMP C HUMD %.

    ID = 1, SEQ is constantly changing, TYPE = 15, temperature = nnn.n

    I am trying to capture the Temp, and this presented a challenge. (The humidity is easy, I'm reading after the C - 5 has 'C')

    The SEQ number starts as n and evolves to nnnn... so using 7x4a does not work due to the changing length of the SS.

    When I use '15' 4, because the Type is still 15, and SEQ contains a 15 in the number, which also becomes a problem.

    Everything that I have which is constant is that there are spaces between each value and the value of temperature I'm looking begins after the 3rd space.

    Any help would be great

    David Sandelman

    Great... progress is good.

    If you use the single command, tol ERDG00A return all my sensors in a given request:

    The request channel data that must be completed is channel 0. All other channels should be empty. Not \r, just empty. I should have mentioned that in the original post. Then configure the channels as before, ensure that each channel of moisture is a\r\n. The next channel group must be a\x20.

    To explain, just one tells DASYLab to find the number of variable length, and he still needs a delimiter to put end. many devices use a comma, but they use a space. The hexadecimal ASCII for space is 20, so say us DASYLab to find numbers in a string of ASCII and stop when he finds a space, using the notation of DASYLab to hexagonal \x20.  notation for the carriage return character (\r isor hex 15), and \n is the notation for the line break ( or hex 12).

    15 84 0 18.5 C 64.5%
    1 50 15 C 18.4, 64.2%
    2 214 15 18.5 C 64.7%
    3 237 15 18.3 C 64.3%

    I like the idea of a single data request command for all four channels - less necessary communication protocol. In interpreting the device number, you will be able to ensure that the analysis works correctly.

    CH 0: a\x20

    CH 1: a\x20

    CH 2: a\x20

    CH 3: a\x20

    CH 4: a\r\n

    CH 5: a\x20

    CH 6: a\x20

    CH 7: a\x20

    CH 8: a\x20

    CH 9: a\r\n

    CH 10: a\x20

    CH 11: a\x20

    CH 12: a\x20

    CH 13: a\x20

    CH 14: a\r\n

  • Record and play variable a string will not copy

    I have a variable of string - serialization of an xml variable result - in a process.

    It has a length of 'unlimited '.

    When I opened the recording and playback, there is text indicating the beginning of sequenced xml:

    < node_x

    That's all that I can see.

    Unfortunately, the option 'copy value' in the menu contextual is dimmed, just at the moment where I most need!

    This is normal behavior for a scenario like this?

    Is there anyway that I can get to copy...

    Thanks in advance!

    At least try to open and close the variable perspective.

  • Get the bind variables name string SQL or the cursor

    Hello

    Is there way to get of the bind variables name string SQL or the cursor?

    Example of
    DECLARE
      l_sql VARCHAR2(2000);
      desctab DBMS_SQL.DESC_TAB;
      curid   PLS_INTEGER;
    BEGIN
    
      l_sql := 'SELECT * FROM emp WHERE mgr = :X and deptno = :Y';
    
      curid := dbms_sql.open_cursor;
      dbms_sql.parse(curid, l_sql, dbms_sql.NATIVE);
      ....
    END;
    What I mean with the SQL string:
    I love to get using some functions from above code variable l_sql all the bind variable.
    In this case the function should return array where is for example: X and: Y

    Back to bind the cursor variable names, I mean same but rather string I pass number of cursor.

    Y at - it sucks ready function or some may share a code customized for this purpose?

    Thanks

    Kind regards
    Jari

    http://dbswh.webhop.NET/dbswh/f?p=blog:Home:0Regards,

    Published by: jarola December 19, 2011 02:44

    I found there are wwv_flow_utilities.get_binds of the function not documented in APEX packages that do what I want.
    Usage example
    set serveroutput on
    DECLARE
      binds DBMS_SQL.varchar2_table;
    BEGIN
      binds := wwv_flow_utilities.get_binds('select :P1_TEST from dual');
      FOR i IN 1 .. binds.count
      LOOP
        dbms_output.put_line(binds(i));
      END LOOP;
    END;
    /
    
    anonymous block completed
    :P1_TEST
    But I would not use these functions without papers as those who can change or there is no future versions APEX.
    Is there a documented function or the custom function that do the same thing as wwv_flow_utilities.get_binds?

    Some old basic example code of my friends. Also the media getting the bind variable of PL/SQL code blocks anon.

    SQL> create or replace function GetBindVariables( statement varchar2 ) return TStrings is
      2          --// bind variables names are terminated by one the following special chars
      3          SPECIAL_CHAR    constant TStrings := TStrings(' ',')','+','-','>','<','*',',','=',';',CHR(10),CHR(13));
      4
      5          --// max size of a bind var name
      6          MAX_VARSIZE     constant integer := 100;
      7
      8          pos     integer;
      9          pos1    integer;
     10          occur   integer;
     11          varName varchar2(100);
     12          varList TStrings;
     13  begin
     14          varList := new TStrings();
     15
     16          --// looking for the 1st occurance of a bind variable
     17          occur := 1;
     18
     19          loop
     20                  pos := InStr( statement, ':', 1, occur );
     21                  exit when pos = 0;
     22
     23                  varName := SubStr( statement, pos, 100 );
     24
     25                  --// find the terminating char trailing the
     26                  --// bind variable name
     27                  pos1 := Length( varName );
     28                  for i in 1..SPECIAL_CHAR.Count
     29                  loop
     30                          pos := InStr( varName, SPECIAL_CHAR(i) ) - 1;
     31                          if (pos > 0) and (pos < pos1) then
     32                                  pos1 := pos;
     33                          end if;
     34                  end loop;
     35
     36                  --// extract the actual bind var name (without
     37                  --// colon char prefix)
     38                  varName := SubStr( varName, 2, pos1-1 );
     39
     40                  --// maintain a unique list of var names
     41                  if not varName member of varList then
     42                          varList.Extend(1);
     43                          varList( varList.Count ) := varName;
     44                  end if;
     45
     46                  --// look for the next occurance
     47                  occur := occur + 1;
     48          end loop;
     49
     50          return( varList );
     51  end;
     52  /
    
    Function created.
    
    SQL>
    SQL> select
      2          column_value as BIND_VAR
      3  from TABLE(
      4          GetBindVariables('select * from foo where col=:BIND1 and day = to_date(:B2,''yyyy/mm/dd'')')
      5  );
    
    BIND_VAR
    ------------------------------
    BIND1
    B2
    
    SQL> 
    

    PS. just realize this code is case-sensitive, while variable bind is not. Should throw a upper() or lower() by adding the name of the var to the list - never really a problem for me because I'm pretty tense when it use cases correctly in the code. ;-)

    Published by: Billy Verreynne, December 19, 2011 06:19

  • Pass arguments of variable length to an another variable length arguments

    Do not pass an argument of variable length to another argument of variable length

    For example

    public void call(name:String,..._params):Object

    {

    ExternalInterface.call("saveglobalscore",score) (name, params);
    }

    call ("test", "param1");

    "param1" is considered to be an argument with the type of array in the second function of «call», but is what I want to treat it as an argument as a string.

    The result is:

    < call name = 'test' returntype = "xml" > < arguments > <table > <property id = '0' > < name String > < / string > < / property > </ array > </ arguments > < / call >

    But what I want is

    < call name = 'test' returntype = "xml" > < arguments > < String > name < / String > < / arguments > < / call >

    I have to do is:

    public void call(name:String,..._params):Object

    {

    If (params.length == 1)

    {

    ExternalInterface.call("saveglobalscore",score) (name, params [0]);

    } Else if (params.length == 2)

    {

    ExternalInterface.call("saveglobalscore",score) (name, params [0], params [1]);

    } Else if (params.length == 3)

    {

    ExternalInterface.call("saveglobalscore",score) (name, params [0], params [1], [2] params);

    } else

    throw new Error ("I'm crazy");

    }

    This is a terrible solution, if it no work around?

    The compiler must can handle this situation.

    Try:

    public void call(name:String,..._params):Object

    {

    params.unshift (Name);

    ExternalInterface.call.apply (ExternalInterface, params);

    }

    Alex Harui

    Flex SDK Developer

    Adobe Systems Inc..

    Blog: http://blogs.adobe.com/aharui

  • What is the right way of javadoc a variable-length argument list

    What is the right way of javadoc a variable-length argument list?

    Let's say I have the following function:
    public void foo(Integer... intArray){
    //...
    }
    I'm not sure how I would want doc this, well, is there something special, I want to point out?

    Thank you for your time,
    Brandon

    Identical to another argument. Name it and say what's the point.

  • JavaScript: Cannot load more than 4093 bytes in variable. String is truncated. In IE, everything works fine.

    I have request data from the server.
    Server returns XML data. Processing these data. When the variable size exceeds 4093, the string is truncated. Code:

    function handleGetVars (data) {
    var xmlResponse = data;
    if (xmlResponse == null) return;
    xmlRoot = xmlResponse.documentElement;
    if (!xmlResponse || !xmlRoot)
    throw ("Wrong XML document structure:\n" + xmlHttp.responseText);
    if (xmlRoot.nodeName == "parsererror")
    throw ("Wrong XML document structure:\n" + xmlHttp.responseText);
    numArray = xmlRoot.getElementsByTagName ("num");
    nameArray = xmlRoot.getElementsByTagName ("name");
    valueArray = xmlRoot.getElementsByTagName ("value");
    var html = "<table>";
    var num = 0;
    var value = "";
    if (numArray.length)
    {
    for (var i=0; i<nameArray.length; i++)
    {
    num = numArray.item(i).firstChild.data;
    html += "<tr><td align='left'>";
    html += nameArray.item(i).firstChild.data + "</td>\n";
    html += "<td align='left'><div id=variable_" + num + ">";
    value = valueArray.item(i).firstChild.data;
    html += value + "</div></td>\n";
    html += "<td><div id = 'btnBlock_" + num + "'>";
    html += btnBlock (num);
    html += "</div></td></tr>\n";
    } // for
    } // if
    html += "</table>";
    $('#variables').html(html);
    } // handleGetVars

    This forum focuses on the care of the end user. You can find more help web development on the mozillaZine Web Development Council. That Council handles also better than that of the special characters (using code BBCode tags).

  • Analysis of the variable format string

    Question, I have a string I need to analyze in separate string variables. Analysis errors out string if the string is parsed cannot fill every type defined in the string format. The problem I have is that the string length varies depending on multiple strings separated by spaces up to 13 different string types sometimes and sometimes only 6. Is there another way to scan the string in different channels with the command of token or something and not use this as the format varies?

    I've attached an example of what I'm trying to do.

    Thank you.

    Here you go...

  • Global Variable length problem

    Hi all

    I'm moving a group of a pll key values.
    I'm holding all the key values in a text field that can contain up to 10000 bytes and I'm assigning the text field values to a global variable.
    This value of the global variable is read by pll and fetch the records using these key values.

    But I'm getting ORA-06502 error. This is a question about the length of the variable.
    Form builders help I got to know that this global variable can hold only up to 5000 bytes.

    Suppose that
    New_id is a text field that has more than 7000 bytes values separated by comma

    New_id is that a text field of type char length is 10000,

    +: global .new_cust_id: = Block.new_id +;

    On this line, I get ORA-06502 error, because this value is used by other packages.

    Can someone help how do I fix this

    Use forms [32 bit] Version 11.1.1.4.0 (Production) and Oracle database 11 g R2

    Thank you
    malandain

    Citing the Globals online documentation:

    A global variable is a variable of Oracle Forms whose value is available for the triggers and the subprogrammes in any module that is active in the current session. In previous versions of Oracle Forms, a global variable stores a string of length, for all uses up to 255 bytes. In Oracle 10g form, global variables are now limited to 4000 bytes when they are set or referenced using PL/SQL bind variable notation. for other uses, no limit is imposed.

    This means: If you access the global variable like this:

    :global.variable := value;
    

    You can store up to 4000 bytes in length. If you use the copy and name_in built ins you should be able to store up to 32767 bytes in a global variable.

    see you soon

  • Can join us variable liquids with other variables or/strings of data in the declarations of liquids

    Can join us liquid variable with other channels for use in conditions or other liquid or variable methods?

    For an example simple Assembly variable/data with a string:

    {% assign newVar = globals.get.id + "#anchor" %}

    to get the result:

    newVar = / page-name #anchor

    or two variables in a conditional Assembly:

    {% assign var1 = "xy" %}

    {% assign var2 = 'z' %}

    {% If xyz is var1 + var2 %}     (but not + as in addition to math, actually join the 2 resulting from the chains of var1 and var2)

    so the if statement would be true.

    You don't need to capture Robert

    Adam,

    First is the sign + - in a liquid, it is 'more '.

    {{500 | more: 20}}

    And combine a string:

    {% assign var1 = "xy" %}

    {% assign var2 = 'z' %}

    {% assign combine = var2 | append: var1 %}}

    {{combine}}

    Capture is a double pass less effective.

  • Name of variable lengths and function affect the processing time?

    Hello

    I was wondering if I should make an effort to reduce the size of my var names and func, especially those referred within loops?

    See you soon

    name lengths have no significant impact.  on the other hand, unnecessary creation/gc ' g of the names of the variables has little impact.

  • using the session variable in init. variable init string of session. block

    Hi, experts,

    is it permissible to use a session variable loaded (A) in the initialization string in the block of the initialization of the session to another variable (B).

    for example,.
    in execution, priority of the initialization of B block, added the initialization of a block

    then in the initialization string in the initialization of B block,

    the likes of sql:

    Select a clause where a.xxx = yyy ' valueof (nq_session. (A)'

    What is the correct syntax?

    Thank you very much!

    This is the correct format. If it does not work for you then you need to give more information than what is happening, how fill you your Init blocks etc.

  • Distinction between variables and strings...

    Hi all
     
    INSERT INTO PERSONEL.DPTRANSLATIONS (TID,SCRIPT_NAME,TAG,TR,EN,LOCAL) 
    VALUES (PERSONEL.SQX_TID.NEXTVAL ,'DELPHI.OGIS.frmmain.Akademik1','Akademik1','&Genel','&Genel_eng','&Genel_loc');
    I'm processing and insert the forms of delphi. In fact '& Genel' = > is a string, but during insertion operation oracle interprets it as a variable and inserts its value which is obviously 'null '. How can I tell oracle that a string is NOT a variable and must be inserted as given.

    Thank you.

    Published by: USS on September 11, 2009 07:31

    set define off

  • premium variable length emulator

    Using the first emulator "solve the digital function", I noticed that my veriable names were being cut after 4 characters. Is it possible to see all the name of the variable? Or am I limited to only 4 characters?

    Thank you

    The size of the return of the name is limited at present. The variable works very well, cut it to 4.

Maybe you are looking for