PL/SQL insert new string in the string specified to a specific Position

Hello

I would like to know the way to insert the new string into the used rope to the specific position. Is there a syntax for the same thing?

Example:

Old rope: D100

New string:APPROX100 D

Thank you

Something like that

DECLARE
  L_VARIABLE          VARCHAR2 (100) := 'D100';
  L_POSITION          NUMBER := 2;
  L_APPENDED_STRING  VARCHAR2 (100) := 'ENV';
  L_NEW_VARIABLE      VARCHAR2 (100);
BEGIN
  SELECT    SUBSTR (L_VARIABLE, 1, L_POSITION - 1)
          || L_APPENDED_STRING
          || SUBSTR (L_VARIABLE, L_POSITION)
    INTO L_NEW_VARIABLE
    FROM DUAL;

  DBMS_OUTPUT.PUT_LINE ('INITIAL VALUE IS ' || L_VARIABLE);
  DBMS_OUTPUT.PUT_LINE ('REQUIRED VALUE IS ' || L_NEW_VARIABLE);
END;

Tags: Database

Similar Questions

  • 2 PL/SQL insert new string in the string specified to a specific Position

    Hello

    PL/SQL insert new string in the string specified to a specific Position

    Continuing the previous thread has answered, I would like to know how to cut the data after the underscore ("_").

    Example:

    Old chain: D100_RT

    New string:APPROX100 d.

    Here after, what is there after that execution should be deleted.

    Thank you

    Suppose that the string = D100_RT

    select substr('D100_RT', 1, instr('D100_RT','_')-1 )
    from dual
    
  • Problem with PL/SQL insert query

    Hello to all the genius... Vikram im, Im new in the world of the apex and pl/sql... I need everything that you guys help... This is my first application user (for example)

    name of the table - form
    name of the column - f_no number, name varchar2, number of salary.
    Apex page n - p1_f_no, p1_name, p1_sal

    Now my problem is the query that is below works in the workshop of sql (insertion of data in the table in shape) and can be seen using the select query... but when I implement this in the apex... It shows - in all areas:

    declare
    v_no number (3);
    v_Name varchar2 (20);
    v_sal number (10);
    Start
    Insert in the form values (: v_no,: v_name,: v_sal);
    end;

    IM using this query in the Process button,

    Thank you

    -Best regards,.
    Vikram

    Mahir M. Quluzade have already responded.

    Published by: Gokhan Atil on 03.May.2011 12:45

  • CreateInsert puts the new line at the top or second to last

    Dear all,

    Just a question, is possible to configure when you create a new line in a
    editable table, it will be at the end of the rows in the table?

    Use case:
    I have a view from the Departments of the HR schema table object.
    Then I gave up this page as an editable table and allowed the selection of lines.

    To add the new line, I drag the option create an insert in the form of button.
    <af:form id="f1">
    <af:panelStretchLayout id="psl1">
      <f:facet name="bottom">
         <af:panelGroupLayout id="pgl1">
           <af:commandButton text="Add Row" id="cb1"
                                  actionListener="#{bindings.CreateInsert.execute}"/>
           <af:commandButton actionListener="#{bindings.Commit.execute}"
                                  text="Commit" id="cb2"/>
           <af:commandButton actionListener="#{bindings.Rollback.execute}"
                                  text="Undo" immediate="true" id="cb3">
              <af:resetActionListener/>
           </af:commandButton>
         </af:panelGroupLayout>
      </f:facet>
      <f:facet name="center">
         <af:table value="#{bindings.DepartmentsView1.collectionModel}"
                     var="row" rows="#{bindings.DepartmentsView1.rangeSize}"
                     emptyText="#{bindings.DepartmentsView1.viewable ? 'No data to display.' : 'Access Denied.'}"
                     fetchSize="#{bindings.DepartmentsView1.rangeSize}"
                     rowBandingInterval="0"
                     selectedRowKeys="#{bindings.DepartmentsView1.collectionModel.selectedRow}"
                     selectionListener="#{bindings.DepartmentsView1.collectionModel.makeCurrent}"
                     rowSelection="single" id="t1" partialTriggers="::cb1">
           <af:column sortProperty="DepartmentId" sortable="false"
                         headerText="#{bindings.DepartmentsView1.hints.DepartmentId.label}"
                         id="c4">
              <af:inputText value="#{row.bindings.DepartmentId.inputValue}"
                               label="#{bindings.DepartmentsView1.hints.DepartmentId.label}"
                               required="#{bindings.DepartmentsView1.hints.DepartmentId.mandatory}"
                               columns="#{bindings.DepartmentsView1.hints.DepartmentId.displayWidth}"
                               maximumLength="#{bindings.DepartmentsView1.hints.DepartmentId.precision}"
                               shortDesc="#{bindings.DepartmentsView1.hints.DepartmentId.tooltip}"
                               id="it4">
              </af:inputText>
           </af:column>
           .
           .
           .
           <af:column sortProperty="LocationId" sortable="false"
                         headerText="#{bindings.DepartmentsView1.hints.LocationId.label}"
                         id="c1">
              <af:inputText value="#{row.bindings.LocationId.inputValue}"
                               label="#{bindings.DepartmentsView1.hints.LocationId.label}"
                               required="#{bindings.DepartmentsView1.hints.LocationId.mandatory}"
                               columns="#{bindings.DepartmentsView1.hints.LocationId.displayWidth}"
                               maximumLength="#{bindings.DepartmentsView1.hints.LocationId.precision}"
                               shortDesc="#{bindings.DepartmentsView1.hints.LocationId.tooltip}"
                               id="it2">
              </af:inputText>
           </af:column>
         </af:table>
      </f:facet>
      <f:facet name="start"/>
      <f:facet name="end"/>
      <f:facet name="top"/>
    </af:panelStretchLayout>
    But I noticed that when I clicked on the createinsert button, the new row is added at the top of the table.
    Then I tried to click on the last row, but when I click on the CreateInsert, it is added before the last line.

    How can I set this up so that it will show at the bottom?

    Thank you.

    JDEV 11G PS 3
    /**
    * Insert new Rows at the end of RowSet.
    * @param row
    */
    @Override
    public void insertRow(Row row) {
    //go to the end of Rowset if it has rows
    Row lastRow = this.last();
    if (lastRow != null) {
    //insert new row at the end and make it current
    int indx = this.getRangeIndexOf(lastRow) + 1;
    this.insertRowAtRangeIndex(indx, row);
    this.setCurrentRow(row);
    } else { // empty Rowset
    super.insertRow(row);
    }
    }     
    

    The line will be added to the end. In fact, you override this method in your voImpl.

  • [Oracle] [ODBC SQL Server driver] String truncation on the right {01004} data

    When importing data from SQL Server 2005 to Oracle 11 g Release2 gateway, I get following error:

    insert into CSDescr select * from CSDescr@sqlserver
    *
    ERROR on line 1:
    ORA-28500: connection between ORACLE and a non-Oracle system has sent this message:
    [Oracle] [ODBC SQL Server driver] string data, right truncation + {01004} +.
    ORA-02063: preceding 2 lines from SQLSERVER

    Oracle database characterset is AL32UTF8
    SQLServer database characterset is SQL_Latin1_General_CP1_CI_AS

    Here is the configuration file for the gateway settings:

    HS_KEEP_REMOTE_COLUMN_SIZE = LOCAL
    HS_NLS_LENGTH_SEMANTICS = CHAR

    I think that the definition of the parameter HS_LANGUAGE must correct the error, but I want to know what should be the value of this setting?

    HS_LANGUAGE must be set to a character set used by the foreign database

    Try: HS_LANGUAGE = american_america. WE8MSWIN1252
    Also specify HS_NLS_NCHAR = UCS2 nvarchars of SQl Server are stored in the UCS2 character set

  • Can anyone tell how to insert a string between the two another string...?

    Can anyone tell how to insert a string between the two another string...?
    For example: String1 = 'ABC '.
    String2 = "XY".

    I want that the chain of output like "AXYBC".

    If you have the Position where you want to place your chain, this might work:

    SQL> r
      1  declare
      2    vStr1 varchar2(20) := '123456789';
      3    vStr2 varchar2(20) := 'aa';
      4    nInsertPos number := 3;
      5    vResult varchar2(20);
      6  begin
      7    vResult := substr(vStr1, 0, nInsertPos) || vStr2 || substr(vStr1, nInsertPos+1);
      8    dbms_output.put_line(vResult);
      9* end;
    123aa456789
    

    If you want to insert it after a special character, you can search for the position of your character with the help of instr

    concerning

  • 13-inch early 2011 macbook pro. light green mag extremely shoddy security cordon, macbook pro stopped charging bought new magsafe. and the led does not illuminate or strings. SMC reset now mac does not recognize battery. unplugged

    13-inch early 2011 macbook pro. light green mag extremely shoddy security cordon, macbook pro stopped charging bought new magsafe. and the led does not illuminate or strings. SMC reset now mac does not recognize battery. disconnected the battery and security cordon mag, maintained hold button / stop for 5 seconds, nothing. Another SMC reset and it is the only way Mac powered on that she has no back light for the keyboard and the fan works on high all the time, please can someone HELP, thanks.

    This is the Office Mac Pro forum. I asked that your post be moved to the MacBook Pro laptop forum.

  • ORA-13754: 'SQL Tuning Set' 'string' does not exist for the user "sysman."

    ORA-13754: 'SQL Tuning Set' 'string' does not exist for the user "sysman."

    Hello
    in 10g R2 when I run the following in isqlplus I error of the United Nations:
    SELECT * FROM TABLE(DBMS_SQLTUNE.SELECT_SQLSET(
    'my_sql_tuning_set',
    '(disk_reads/buffer_gets) >= 0.05'));
    
    ORA-13754: "SQL Tuning Set"'my_sql_tuning_set" does not exist for user "sysman". 
    No problem if I run it as sys to sqlplus.

    Thanks for the help.

    How to activate for sys isqlplus?

    You are logged in as sysman,

    Check the user from the sql prompt.

    show user
    
  • Problem inserting new line in a VO with SQL functions and subqueries

    Hello

    I use JDeveloper 10.1.3.4 and and stuck with insertion of a new line when the values to insert into some fields of the new line are returns of SQL functions and subqueries.

    At the sqlplus prompt, the following sql statement is tested and developed successfully:
    insert into VALIDATIONS values (
       '111223333', 'JANE', 'DOE',
       SYSDATE,
       (select to_char(sysdate, 'yymmdd') from dual)||
       (select to_char(count(TRANSACTION_DATE)+1,'fm0999') from VALIDATIONS
          where trunc(TRANSACTION_DATE) = to_char(sysdate))
    );
    Note that the values for the fields of 4th and 5th are returns of subqueries and SQL functions.

    Ideally, it would be simple to assemble a SQL and executed him as he did to the old way of servlet:
    String sql = "insert into VALIDATIONS values ('" + id + "', '" + firstName + "', '" + lastName + "', SYSDATE, (select to_char( ......)))";
    statement.executeUpdate(sql);
    I'm not sure it can be done in JDeveloper, and it was not found in the developer's guide. What I found was rather:
    // 1. Find the ServiceRequests view object instance.
    ViewObject svcReqs = am.findViewObject("ServiceRequests");
    // 2. Create a new row and insert it into the row set
    Row newSvcReq = svcReqs.createRow();
    svcReqs.insertRow(newSvcReq);
    // 3. Show effect of entity object defaulting for Status attribute
    System.out.println("Status defaults to: "+newSvcReq.getAttribute("Status"));
    // 4. Set values for some of the required attributes
    newSvcReq.setAttribute("CreatedBy",308); // Nancy Greenberg (user)
    Date now = new Date(new Timestamp(System.currentTimeMillis()));
    newSvcReq.setAttribute("RequestDate",now);
    newSvcReq.setAttribute("ProdId",119); // Ice Maker
    newSvcReq.setAttribute("ProblemDescription","Cubes melt immediately");
    // 5. Commit the transaction
    am.getTransaction().commit();
    In my case, it would be OK for the first three fields as shown below (in the code of transactionsRecords is a display object). But what about the 4th and 5th fields?
    Row newTransaction = transactionsRecords.createRow();
    transactionsRecords.insertRow(newTransaction);
    newTransaction.setAttribute("StudentId", id);
    newTransaction.setAttribute("FirstName", firstName);
    newTransaction.setAttribute("LastName", lastName);
    
    newTransaction.setAttribute("TransactionDate", <how to put "SYSDATE" here?>);
    newTransaction.setAttribute("ConfirmNumber", <how to put subqueries here?>);
    A big thank you to those who know or have experience before!


    Newman

    Newman,
    You can do this via a procedure call. This technique is described here
    I guess you can't do this directly in the EO or VO.
    You can do it the old way to create a prepared directly query and call it as you described. To get the declaration use getDBTransaction () .createPreparedStatement (...) method available in the module of your application.
    Be aware of the implications using the given solution. The framework doesn't know anything of what you are doing. So to see the changes that you used to update the tables that you change.

    Timo

  • Insert new page Unix tank into the Oracle table.

    Hi all

    "I need to insert new page for unix = hex char in result table ' 0x0C ', don't know how Oracle manages this, do I have to use any convert for this function? as HEXTORAW, etc... or there is a direct way to the State which is hexagonal.
    I can't find any specific identifier for HEX Strings, something like hex'0x0C ' or X'0x0c '.


    Insert value X rt_result '0xOC ';? -column of the table defined as varchar2 (100).


    Thank you
    Trent

    Well, you can also simply do:

     new_page := chr(12);
    

    Much shorter ;)

  • How to get the string (specified by row and column) of txt file with labview

    Hello world

    How to get the string (specified by row and column) of txt file with labview

    THX

    As far as I know, a text file has no column.  Be more specific.  Do you mean something like the 5th word on line 4, where the words are separated by a space, and lines are separated by a newline character?  You can read from the spreadsheet String function and set the delimiter to a space.  This will produce a 2D channels table.  Then use the table to index and give the line number and column number.

  • Why our local DNS server, discount Internet user if the user insert new internet address?

    We have a local DNS server that has a strange problem. If a user insert new internet address DNS will cut this internet user. So every time that the user want to insert the new internet address that he must fix his connection and then refresh the browser to display the page.

    How can I fix this error?

    Hi Saman,
    first things first... more information is needed to correctly diagnose your problem.
    When you post a question please include at least the system operation, error message, and what happens when the issue appears.
    Second, server or business systems problems most will be better suited to Microsoft's Technet forum.
    Try this link below for search/post:
    http://social.technet.Microsoft.com/search/en-us/?query=DNS%20Server&refinement=112&AC=3
    B Eddie

  • I can't find the digital unicode to insert an apostrophe in the Times New Roman font

    Unicode for the Apostrophe

    I can't find the digital unicode to insert an apostrophe in the font Times New Roman 12 size. I used the table of characters, as always and apostrophe selected. The code usually comes at the bottom of the right hand of the box, but in this case it doesn't.  Can someone advise the code please. I searched through aid, but such a simple, and I would have thought, fundimental issue does not.

    Quote the num + 0039 Alt gives me just a closing speech.

    If U + 0027 is not the character you want to what?

    ---

  • What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    Mr President.

    What is wrong with this sequence, it does not work when, after 3 inserts, I add a new record with the trigger it gives an error.

    --SL_CUSTOMERS table data
    
    
    INSERT INTO SL_CUSTOMERS VALUES(1,'Kamrul Hasan',NULL,NULL,'Moghbazar', 'Dhaka','0456789123',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(2,'Rabiul Alam',NULL,NULL,'Motijheel', 'Dhaka','0567891234',NULL,NULL,NULL,'Y',NULL);
    INSERT INTO SL_CUSTOMERS VALUES(3,'Shahed Hasan',NULL,NULL,'2-G/1,2-2,Mirpur', 'Dhaka','0678912345',NULL,NULL,NULL,'Y',NULL);
    
    
    
    

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG 
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"   
    FOR EACH ROW   
    BEGIN   
    IF :NEW.CUSTOMER_ID IS NULL OR :NEW.CUSTOMER_ID < 0 THEN  
      SELECT SL_CUSTOMERS_SEQ.nextval   
        INTO :NEW.CUSTOMER_ID  
        FROM DUAL;   
      END IF;   
    END;   
    /
    
    
    
    

    When I try to insert several records with the seq.nextval it gives error

    violation of primary key.

    INSERT INTO "ALIZA"."SL_CUSTOMERS" (CUSTOMER_NAME) VALUES ('sdfsd')
    ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    One error saving changes to table "ALIZA"."SL_CUSTOMERS":
    Row 4: ORA-00001: unique constraint (ALIZA.SL_CUSTOMERS_PK) violated
    ORA-06512: at line 1
    
    
    
    
    
    
    
    

    Concerning

    Mr President.

    I find the solution by creating a function before the triiger

    as below

    CREATE SEQUENCE  "ALIZA"."SL_CUSTOMERS_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER  NOCYCLE ;
    
    CREATE OR REPLACE FUNCTION get_SL_CUSTOMERS_vId RETURN VARCHAR2 AS
    BEGIN
       RETURN SL_CUSTOMERS_SEQ.NEXTVAL;
    
    END;
    /
    
    CREATE OR REPLACE TRIGGER SL_CUSTOMERS_TRG
    BEFORE INSERT ON "ALIZA"."SL_CUSTOMERS"
    FOR EACH ROW
    DECLARE
    dummy VARCHAR2(200);
    BEGIN
      dummy := get_SL_CUSTOMERS_vId();
      :NEW.CUSTOMER_ID := dummy;
    END;
    /  
    

    It works very well

    Thank you all for the suggestions.

    Concerning

  • We can insert a new line at the end of af: table declaratively?

    Mr President.

    We can insert a new line at the end of af: table declaratively?

    Concerning

    In the t impl class substitution as below, after that, you should be able to insert at the end of the table.

    @Override

    {} public void insertRow (rank)

    Line lastRow = this.last ();

    If (lastRow! = null) {}

    int j = this.getRangeIndexOf (lastRow) + 1;

    this.insertRowAtRangeIndex (j, line);

    this.setCurrentRow (row);

    } else {}

    super.insertRow (row);

    }

    }

Maybe you are looking for