Assign a value of "dynamically created the sequence" to a variable

in my procedure I am creating a sequence on the fly, I prepare the name with some parameters passes as below

.
.
v_seq_name: = "seq_". loadid | v_table_name;
run immediately 'CREATE SEQUENCE'. v_seq_name | "MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 increment of 1 hiding 20';
.
.

and now after doing some operations I need to assign the current value of the sequence to a variable number, I tried but does not subsequently

(1) v_curr_value: = v_seq_name.currval;
(2) select v_seq_name |'. nextval' in double v_curr_value;

can you please suggest me how can I get the value in plsql block.

And what is - this?

v_curr_value: = v_seq_name.currval;

Of course, it will fail. If you want to get currval in a sequence whose name is stored in a variable, you must use dynamic SQL:

SQL> declare
  2      v_seq_name varchar2(30);
  3      loadid number := 1;
  4      v_table_name varchar2(10) := 'tbl';
  5      v_curr_value number;
  6  begin
  7      v_seq_name := 'seq_' || loadid || v_table_name;
  8      execute immediate 'CREATE SEQUENCE ' || v_seq_name ||
  9                        ' MINVALUE 1 MAXVALUE 999999999999999999999999999 START WITH 1 increment
by 1 cache 20';
 10      for i in 1..5 loop
 11        execute immediate 'select ' || v_seq_name || '.nextval from dual'into v_curr_value;
 12        dbms_output.put_line(v_curr_value);
 13      end loop;
 14  end;
 15  /
1
2
3
4
5

PL/SQL procedure successfully completed.

SQL> 

SY.

Tags: Database

Similar Questions

  • Dynamic, create the sequence then select nextval within a transaction

    The following procedure does not compile if the sequence SEQ_ADR does not exist before compilation. I had to manually create the sequence before you can compile this procedure. How can I avoid this manual generation?
    PROCEDURE A_270(proc_id number) IS
    seq_cnt number;
    curr_max number;
    BEGIN
    select count(*) into seq_cnt from user_sequences where sequence_name='SEQ_ADR';
    if seq_cnt > 0 then
    execute immediate 'drop sequence SEQ_ADR';
    end if;
    select max(id)+1 into curr_max from adress;
    execute immediate 'create sequence SEQ_ADR start with '||curr_max||'';
    insert into adress(ID,
    IMPORTED_DT
    )
    select
    SEQ_ADR.nextval ID,
    sysdate IMPORTED_DT
    from new_adress;
    END;
    Published by: totalnewby on August 23, 2012 06:41

    The SELECTION against the sequence should be dynamic as well. Otherwise, the procedure has a dependency on a non-existent sequence.

  • How to create the sequence 0.1, 0.2, 0.6 1,1.1,1.2...1.6,2

    Hi all,

    I tried to do above sequence type that similar football during the sequence, I tried to do but not and start by allow only integer value...
    If anny we know the answer please share with us...

    Thnaks in advance...

    797525 wrote:

    and you must use the check constraint to fix the problem

    SQL> create table tbl(n number)
      2  /
    
    Table created.
    
    SQL> alter table tbl
      2    add constraint tbl_chk1
      3      check(
      4            regexp_like(n,'^[0-6]*\.{0,1}[0-6]{0,1}$')
      5           )
      6  /
    
    Table altered.
    
    SQL> insert
      2    into tbl
      3    values(
      4           0
      5          )
      6  /
    
    1 row created.
    
    SQL> insert
      2    into tbl
      3    values(
      4           0.4
      5          )
      6  /
    
    1 row created.
    
    SQL> insert
      2    into tbl
      3    values(
      4           0.44
      5          )
      6  /
    insert
    *
    ERROR at line 1:
    ORA-02290: check constraint (SCOTT.TBL_CHK1) violated
    
    SQL> insert
      2    into tbl
      3    values(
      4           0.7
      5          )
      6  /
    insert
    *
    ERROR at line 1:
    ORA-02290: check constraint (SCOTT.TBL_CHK1) violated
    
    SQL> insert
      2    into tbl
      3    values(
      4           6.6
      5          )
      6  /
    
    1 row created.
    
    SQL> insert
      2    into tbl
      3    values(
      4           7
      5          )
      6  /
    insert
    *
    ERROR at line 1:
    ORA-02290: check constraint (SCOTT.TBL_CHK1) violated
    
    SQL> insert
      2    into tbl
      3    values(
      4           16.6
      5          )
      6  /
    
    1 row created.
    
    SQL> 
    

    SY.

  • By program (step by step) read data XFDF and dynamically create the form

    Hej,

    I have a form created dynamically with JavaScript in Adobe Acrobat 9. I exported the variable amount of data in an XFDF file.

    Now, I want to import the XFDF file into a second PDF file. But while the data is variable, I need to read the data imported manually

    and to create the new PDF dynamically. This is required, while the new PDF must contain a chart made in Flash and will be

    filled with data from the XFDF file.

    My problem is, that "doc.importAnXFDF ()" does not return the data that is imported as an object. I was looking for solutions

    but I have always found solutions to automatically populate an existing form. The API guide is not useful. Where can I read the imported data

    to iterate on and in the process.

    Thank you very much.

    Christian

    As I discovered (https://acrobatusers.com/tutorials/extracting-pages-pdf-acrobat-javascript) it is possible to save a range of

    pages programmatically. In fact, this has many advantages for my use case, including to prevent the many errors made by users.

    So I decided to use this solution and close this issue.

  • Dynamically create the input text element

    Hello

    I'm trying to dynamically create a text entry and add it to the Table

    but I'm having some problem with createWebBean method we can invoke it.

    Please help thanks
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;
    import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;
    import oracle.apps.fnd.framework.webui.beans.table.OATableBean;
    import oracle.apps.pa.ci.webui.PaSupplierImplementCO;
    import oracle.apps.pa.util.webui.Debug;
    
     public class xxpaPaSupplierImplementCO extends PaSupplierImplementCO {
    
        public void processRequest(OAPageContext paramOAPageContext,OAWebBean paramOAWebBean) {
            
            super.processRequest(paramOAPageContext, paramOAWebBean);
            xxpaProcessRequest(paramOAPageContext, paramOAWebBean);
        }
        public void xxpaProcessRequest(OAPageContext paramOAPageContext,OAWebBean paramOAWebBean) {
            
            super.processRequest(paramOAPageContext, paramOAWebBean);
            print_log("Start processRequest",paramOAPageContext);
            
            OATableBean localOATableBean = (OATableBean)paramOAWebBean.findIndexedChildRecursive("SupplierTable");
            if (localOATableBean != null){
               OAMessageTextInputBean xxPaPOQuantityBy = (OAMessageTextInputBean)createWebBean(paramOAWebBean,OAWebBeanConstants.MESSAGE_TEXT_INPUT_BEAN,null,"xxPaPOQuantityBy");
               OAMessageTextInputBean xxPaPOQuantityBy1 = (OAMessageTextInputBean)createWebBean(paramOAWebBean,MESSAGE_TEXT_INPUT_BEAN,null,"xxPaPOQuantityBy");
               xxPaPOQuantityBy.setPrompt("Change Quantity By");
               xxPaPOQuantityBy.setMaximumLength(10);
               localOATableBean.addIndexedChild(xxPaPOQuantityBy);
               print_log("PO QTY ADDED ot Supplier Table",paramOAPageContext);
            }
             
            print_log("End processRequest",paramOAPageContext);
        }
    
    }

    Hello

    Try with:

    OAMessageStyledTextBean oamessagestyledtextbean is createWebBean (OAMessageStyledTextBean) (oapagecontext, "MESSAGE_TEXT", null);.

    Concerning
    Meher Irk

  • How to use my photos to my power of cannon shot to create the sequence of shooting panoramic

    I have a canon power shot camera with a "panoramic" photo sequence parameter, but how I put the pictures together several times downloaded from my camera so that they display as a shooting panoramic?

    Have you tried Windows Live Photo Gallery... it has a Panorama option.
    Select (highlight) the pictures and go to... Make / create a panoramic Photo...

  • dynamically create the file name

    Hello

    I tried to save the file dynamically according to the following code:

    QUrl(QString::fromLatin1("%1/songs%2.mp4")
    

    This saves the file with something like songs001.mp4, songs002.mp4, etc.

    no idea how to better customize the name of the file to save with something more convenient, say the name being april5.mp4, april6.mp4 and so on... (based on the date or time or both)

    LOL, not really, in any case you can use the QDateTime class to get the current time with functions that return a QString that you can add the name...

    http://developer.BlackBerry.com/native/reference/Cascades/QDateTime.html

    You can also consider adding metadata to help the other players and differentiate data more...

    http://developer.BlackBerry.com/native/reference/Cascades/bb__multimedia__metadata.html
    http://developer.BlackBerry.com/native/documentation/Cascades/graphics_multimedia/audio_video/access...

  • Custom name - original file name works do not export, Lightroom creates the sequence jpeg instead of the original file number

    When you export from Lightroom with "custom name - original file name" selected, Lightroom replaces the original file with a useless jpeg sequence number. Export must have the custom, followed by the number of original file name.

    There is no option for Custom name + nameof the file.

    I would, with all due respect-

    If you "change" in the file name changes dialog box, you can set the change of name {Custom + file name}

    or Custom + Original file name!

  • Dynamically create the unknown object

    Hi all
    Would appreciate any thoughts on the following. I have an interface where the layout of the background image, scheme of color/alpha presence/absence of certain controls etc. is driven by a descriptor XML file, so that the different choices of menus lead to proper sanitation of the interface.
    I would like to add the facility to have optional controls where I specify the type in the descriptor file - for example, only one can use a box of text while the other one image. In this simple case, I would of course have a flag stored in the descriptor and a switch statement, but I prefer not to put this choice too precipitously in the code. The most likely situation is that I have a number of all custom components subclassed to, say, Panel or canvas and make a choice between them.
    So what I want to do, it's something like:
    [xml file]
    < component = State id '1' = "mycustom1" / >
    > State id component = '2' = "mycustom2" / >
    [Flex]
    var model: Object
    .. .read XML... Assume that we are in State 2
    model = new Object() as mycustom2;
    ... etc, now assuming that the model is a mycustom2 object

    Hope that makes sense. Is this possible? I am happy to have mycustom1 etc. all closely related to each other by subclassing.
    Thank you in advance, any ideas
    Richard

    You can do something like this (code written very quickly):

    import flash.utils.getDefinitionByName;

    var className:String = "MyClassName".

    Name of class
    var cls: Class = getDefinitionByName (className) class;

    now, use cls you prefer
    instance: canvas var = new cls();

    Hope this helps,

    -c.

  • When dynamically created variables are emptied in the sequential process template?

    I have a sequence TestStand 2014 in which I dynamically create and fill many FileGlobal variables in the installation section of my main sequence.  I have it using the TestStand API to read the data in an Excel file (the data consists mainly of thresholds, limits, etc.).  The methodology itself works flawlessy.

    However, there are differences in behavior when using entry points both execution of the sequential process model.  When you use the entry point of execution 'Single Pass', he has no problem in test a DUT after another.  However, when you use the entry point for execution "Test DUT", I encounter the following error after completing of DUT1 and DUT2 testing:

    An error occurred the call 'InsertSubProperty' in 'PropertyObject' of 'NI TestStand 2014 API.

    The name of the element "VariableName" is not valid because it is already in use.

    I interpret this error message means that the variable I am trying to dynamically create the DUT2 track is already present race of DUT1.  I have a few questions about this:

    1. at what point in the sequential process template are dynamically created variables flushed, such as run a further by using 'Single Pass' starts with a clean slate?

    2. is there a reminder that I can substitute such as variables to rinse after each HAD run, allowing me to dynamically create variables on each HAD, during execution using "Test UUT?

    3. better yet, is there a counter of TestStand I can query to determine if I already ran DUT1 when using "Test DUT", such as DUT2 uses the variables that were created dynamically on trail of DUT1?

    Or you can simply use the PropertyExists function as a precondition.

    PropertyExists ("Locals.Foo")

  • Insert data. Select the sequence ID, but popuate even value for two different columns

    Hello

    Version Oracle 11 G

    [code]

    CREATE TABLE MT_PROGRAM

    (

    NUMBER OF "PROGRAM_ID."

    NUMBER OF "REPORTING_PROGRAM_ID."

    'PROGRAM_NAME' VARCHAR2 (128 BYTE)

    );

    INSERT INTO MT_PROGRAM)

    PROGRAM_ID,

    REPORTING_PROGRAM_ID,

    PROGRAM NAME)

    SELECT PROGRAM_ID,

    PROGRAM_ID,

    PROGRAM NAME

    Of

    (SELECT

    fn_get_new_prog_id()

    AS PROGRAM_ID,

    'Test' as the program name OF THE DOUBLE);

    The function has

    create or replace

    FUNCTION "FN_GET_NEW_PROG_ID".

    RETURN NUMBER

    AS

    BEGIN

    RETURN SQ_PROG_ID. NEXTVAL;

    END;

    [/ code]

    Problem is that I must get

    I need Reporting same Program ID ID program and the same sequence. But here I am ecstasy. For example, if my sequence is from 1 then it inserts

    1, 2, 'test '.

    But I need

    1, 1, 'test '.

    P.S. I can't not 1 insert unwanted accounting value of the program and of the update the program id. I have a trigger on the table which keeps track of each insert, update. And I don't want to use the separate update statement because it will create additional row in the history table.

    SQL > create the sequence Tessai minvalue maxvalue 1 99999999999999999 with increment of 1 by 1 cover 2;

    Order of creation

    SQL > select ttest.currval from double;

    Select double ttest.currval

    ORA-08002: sequence TESSAI. CURRVAL is not yet defined in this session

    SQL > select ttest.nextval from double;

    NEXTVAL

    ----------

    1

    SQL > select ttest.currval from double;

    CURRVAL

    ----------

    1

    SQL > select ttest.nextval from double;

    NEXTVAL

    ----------

    2

    SQL > select ttest.currval from double;

    CURRVAL

    ----------

    2

    SQL >

    I have it?

    ----

    Ramin Hashimzade

  • Get the ID of a dynamically created symbol library, inside another symbol.

    Hello world

    I'm trying to get the id of a dynamic created symbol library.

    When you dynamically create the symbol directly on the stage (or the level of the composition), there is no problem.

    But I can not function when you create the symbol inside another symbol.

    A few examples using 'getChildSymbols()' and 'aSymbolInstances '.

    // USING "getChildSymbols()" /////////////////////////////////////////////////////////////////////////

    ON THE STAGE

    var m_item = sym.createChildSymbol ("m_item", "Stage");

    var symbolChildren = sym.getChildSymbols ();

    console.log (symbolChildren [0] .getSymbolElement () .attr ('id')); / / ok eid_1391853893203

    / / Inside a SYMBOL OTHER

    var m_item = sym.createChildSymbol ("m_item", sym.getSymbol("holder").getSymbolElement ());

    var symbolChildren = sym.getSymbol("holder").getChildSymbols (); / / I use this maybe wrong?

    console.log (symbolChildren.Length) / / returns 0 if can't ID is

    ' USE 'aSymbolInstances "".

    ON THE STAGE

    var m_item = sym.createChildSymbol ("m_item", "Stage");

    console.log(sym.aSymbolInstances[0]); / / ok (I guess) x.fn.x.init [1] 0: #eid_1391854141436 div

    / / Inside a SYMBOL OTHER

    var m_item = sym.createChildSymbol ("m_item", sym.getSymbol("holder").getSymbolElement ());

    console.log (sym.getSymbol("holder").aSymbolInstances [0]); / / Error Javascript in the event handler. Type of event = element

    In this post http://forums.Adobe.com/message/5691824 is written: "mySym.aSymbolInstances will give you a table containing all the 'names' when you create symbols"

    Would be - this only works on the scene / composition level only and not inside a symbol?

    The following methods to obtain the same are indeed possible, but I do not simply want to use them in this case:

    (1) storing a reference to the symbol created in a table and call it later by index.

    (2) giving the elements an ID manually on the creation and use of document.getElementById () thereafter.

    I can't believe that this is not possible. I am probably missing something here.

    Forgive me that I am a newbie using Adobe Edge!
    I really hope that someone can help me here.

    Anyway, thnx in advance people!

    Kind regards

    Lester.

    OK, I solved my problem by using the (simple) code below.
    I guess that 'getChildSymbols()' and 'aSymbolInstances' only works on stage / level of the composition.

    Just thought I'd share this to everyone. Peace!

    var m_item = sym.createChildSymbol ("m_item", sym.getSymbol("holder").getSymbolElement ());

    $.each (sym.$("holder").children (), function (index, obj) {}

    Console.log ($(sym.$("holder").) ([Index] Children()) .attr ('id'));

    });

  • Finding and fixing of the sequences that are out of sync

    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production version

    Hello

    Recently, our development database has been updated with production data, but have not been copied from the sequence.

    Then of course the sequence numbers are very badly synchronized with the primary key for tables throwing errors in primary key.

    How can I find the sequence names, names of tables, columns in primary key, and max values for the primary key columns that have values of key primary school max who are higher than the nextval of their corresponding sequences?

    So far the nextval of sequence numbers were all less than the max value for the primary key for the corresponding tables.

    We used the method:

    SELECT max (primary key column)

    TABLE;

    SELECT sequence_name.nextval FROM dual;

    Sequence_name ALTER SEQUENCE increment primary key value - current value of sequence max + 1;

    SELECT sequence_name.nextval FROM dual;

    SEQUENCE Sequence_name CHANGE INCREMENT OF 1;

    But this is done when a record is inserted into a table and the error is thrown.

    So I hope there is a much better way to remedy.

    Please leave me a question.

    Thank you

    Joe

    I don't know if this will help you or not, but here is what I used for the synchronization to the top of my sequences during the last upgrade/server database migration, I was involved with. You must be logged under the scheme that sequences need synchronization, linking of data back to the database, you are basing the sequences on and then let go and recreate sequences. It essentially creates a couple of other scripts and then executes them.

    CREATE DATABASE LINK dblink
    CONNECT to & schema
    IDENTIFIED BY "& password»
    USING ' & dbname';

    set pages 0;
    left head;
    Set feedback off;
    Set trimspool
    fixed line 1000;

    coil gen_seq_grants_spoolfile.sql

    Select 'grants'. privilege: ' on ' | table_name |' to ' | dealer | « ; »
    to user_sequences us,
    USER_TAB_PRIVS PAO
    where us.sequence_name = dtp.table_name;

    spool off;

    coil gen_seq_spoolfile.sql

    Select 'remove the sequence'. o.object_name | ';' | Chr (10) | Chr (10) |
    ' create the sequence ' | o.object_name | Chr (10) |
    "Start by ' | '. (to_number (s.last_number) + s.increment_by) | Chr (10) |
    "maxvalue ' | s.MAX_VALUE | Chr (10) |
    "minvalue ' | s.MIN_VALUE | Chr (10) |
    "nocycle | Chr (10) |
    'cache'. largest (s.cache_size, 20). Chr (10) |
    "all." Chr (10)
    of dba_objects@dblink o,.
    s dba_sequences@dblink,
    USER_SEQUENCES us
    where o.owner = user
    and o.object_name = s.sequence_name
    and o.owner = s.sequence_owner
    and s.sequence_name = us.sequence_name
    and o.object_type = 'SEQUENCE '.
    and us.last_number< s.last_number="" +="">
    order of o.object_name;

    spool off;

    Set of feedback

    @gen_seq_spoolfile.sql
    @gen_seq_grants_spoolfile.sql

    Drop database link dblink;

  • Publish in the sequence of creation

    Hi all

    I use
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bi
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for Linux: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    I have the diagram with the following roles
    ALTER ANY OUTLINE
    CREATE ANY OUTLINE
    CREATE ANY SYNONYM
    CREATE DATABASE LINK
    CREATE MATERIALIZED VIEW
    CREATE PUBLIC DATABASE LINK
    CREATE VIEW
    DROP ANY OUTLINE
    DROP PUBLIC DATABASE LINK
    SELECT ANY TABLE
    UNLIMITED TABLESPACE
    CONNECT
    DBA
    EXP_FULL_DATABASE
    IMP_FULL_DATABASE
    OEM_MONITOR
    RESOURCE
    I can create a sequence by SQLPLUS and toad.
    SQL> CREATE SEQUENCE ROLE_ACTIVITY_SEQ START WITH 225006249 INCREMENT BY 1 MAXVALUE 9999999999999999999 MINVALUE 225006249 NOCYCLE CACHE 100 ORDER;
    
    Sequence created.
    
    SQL>
    When I try to create the sequence in a dynamic way through get error in PL/SQL procedure
    SQL> execute PROC_CLONE_BU;
    BEGIN PROC_CLONE_BU; END;
    
    *
    ERROR at line 1:
    ORA-01031: insufficient privileges
    ORA-06512: at "SUPERNOVA.PROC_CLONE_BU", line 19
    ORA-06512: at line 1
    
    
    SQL>
    Even though I have the DBA role for the schema. I do not know what oracle of privileges always the exception...

    Pls guide me to solve...

    Thanks and greetings
    Saami

    Procedures PL/SQL etc (except anonymous PL/SQL) does not take into account the roles.
    You must grant permission to create sequences explicitly to the user who will perform the procedure.

    You can also get the procedure to use a particular role, but you end up switching dynamically from the roles in your code and things can get messy. If a user is supposed to be able to do something, it's much cleaner (IMHO) to give explicit permission to the user that something.

    You should also question yourself as to why you are trying to create a sequence dynamically to the execution of your code? What is the purpose of the present, and why the sequence cannot be created as part of database design?

  • TopLink - dynamically create session connection?

    Hi all
    How can PLS, I dynamically create the connection to the database?
    I use toplink workbench and in this step 6: [http://www.oracle.com/technology/products/ias/toplink/doc/11110/tutorial/intro/standalone/intro_tutorial010.htm#CIHIHIFF] I do not check "save the Login and password"...
    If I put the password and static user, everthing works fine, bud I need dynamically created connection... my code is:

    + createSession() protected Sub throws Exception {+
    System.setProperty ("toplink.xml.platform", "oracle.toplink.platform.xml.jaxp.JAXPPlatform");
    XMLSessionConfigLoader loader = new XMLSessionConfigLoader (getSessionsXmlPath ());
    Bishop SessionManager = oracle.toplink.tools.sessionmanagement.SessionManager.getManager ();
    session.setLogin (applyLogin ());
    session = (ServerSession) mgr.getSession (loader, getSessionName(), Thread.currentThread () .getContextClassLoader (), true, true);
    +}+

    + private DatabaseLogin applyLogin() {+
    DatabaseLogin connection = new DatabaseLogin();
    login.usePlatform (new oracle.toplink.platform.database.oracle.Oracle8Platform ());
    login.setDriverClassName ("oracle.jdbc.OracleDriver");
    login.setConnectionString ("path"); JDBC:Oracle:thin:@host:port:SID - path is OK (but SECRET) :-)
    login.setUserName ("user"); USER NAME - user is OK, but hawa ;-)
    login.setEncryptedPassword ("pass"); PASSWORD, ENCRYPTED password is OK ;-)
    Returns the user name;
    +}+

    but he always returns java.lang.NullPointerException! If I set password and user of TopLink workbench, if it works...

    Any ideas, how to configure Java connection, pls?

    SRY for my English...

    Thanks in advance!
    BES cordially, KLD

    Your session variable has the value null until you attribute to him, so you can not call a method on it.

    Try,

    session = (ServerSession) mgr.getSession (loader, getSessionName(), Thread.currentThread () .getContextClassLoader (), false, true);
    session.setLogin (applyLogin ()); \
    session. Login());

    Means that the fake is not to identify the session.

    ----
    James: http://www.eclipselink.org

Maybe you are looking for