Set a variable to the result of an instruction select

I create a list view of the numbers that I have in the system. I'm doing a table with only a list of numbers from 1 to whatever number max is in view. IIf 89 324 is so the last number in the system, so I want a table with 1 thru 89324. Then I can use the NOT EXIST to determine what numbers are miissing in the system. so, if 1 to 200 are not used, but by 89 324 201 is used, then I want the output to 1,2,3... 200.

The code to make the display works and the code to create the table is good, the loop works when I use a number defined for example 100. I just have problems affecting a variable in the number max.

Here's what I have (which of course does not)
CREATE OR REPLACE PROCEDURE test IS

n number := 1;
maxNum number;
BEGIN

execute immediate 'create view check_numbers as
  select num from table1
 union
  select num from table2
 union
  select num from table3';

maxNum := EXECUTE IMMEDIATE 'select max(num) from check_numbers'; --I also tried taking out the EXECUTE IMMEDATE here and it still did not work

WHILE n <= maxIpid LOOP
     insert into numList values(n);          
     n := n + 1;
END LOOP;

--Here I will put in the code to compare the two and display the numbers that are in numList but not in Check_numbers

END;
/
Published by: james3302 on August 11, 2010 15:59

James,

The solution to your immediate problem to get the result of the immediate execution in a variable is to use

EXECUTE IMMEDIATE 'select max(num) from check_numbers' into maxNum;

You can also do without running to the immediate assistance

select max(num) into maxNum from check_numbers;

Of course, you should definitely consider using one of the other solutions already provided.

Depending on what you ultimately trying to reach, another option to consider is to get the list of discrepancies between the numbers to help
Method of Tabibitosan of Aketi ({: identifier of the thread = 1005478}).

with t as (
select  1 as n from dual union all
select  2 as n from dual union all
select  7 as n from dual union all
select  8 as n from dual union all
select 11 as n from dual
)
select * from (
select grp, n1, n2, 1+lag(n2,1,0) over(order by n1) as gap_n1, n1-1 as gap_n2
from (
  select grp, min(n) as n1, max(n) as n2
  from (
    select n, n - row_number() over(order by n) as grp
    from t
    )
  group by grp
  )
)
where grp>0
order by grp
;

GRP                    N1                     N2                     GAP_N1                 GAP_N2
---------------------- ---------------------- ---------------------- ---------------------- ----------------------
4                      7                      8                      3                      6
6                      11                     11                     9                      10                     

Kind regards
Bob

Published by: BobLilly on August 11, 2010 15:00

Tags: Database

Similar Questions

  • Insert the result of a query select in another table

    Hello

    I have a strange problem when I try to insert all the results of a query select in another table, using the declaration of the order.

    With the declaration of COMMAND it works fine
    Work:
    ------------------------------
    INSERT INTO ADART01 (SELECT (codart)
    "STOCK". "" CODART_STO ".
    Of
    "DB". ' ' 'ACTIONS');
    ------------------------------

    But if I try to sort the result using the declaration of the ORDER, I have the following error:
    Error: ORA-00907 missing right parenthesis
    ------------------------------
    INSERT INTO ADART01 (SELECT (codart)
    "STOCK". "" CODART_STO ".
    Of
    "DB". "" "ACTIONS"
    ORDER BY
    "STOCK". ("' CODART_STO ASC ');
    ------------------------------

    Any idea?

    Thank you for your help,
    Angel.

    delete "()" to select

    create table test1 (a number, b varchar2(100));
    
    insert into test1
        (a, b)
        select level, 'level ' || level from dual connect by level < 101;
    
    insert into test1
        (a, b)
        select level, 'level ' || level from dual connect by level < 101 order by to_char(sysdate - level, 'D');
    
    select * from test1;
    
    drop table test1;
    
  • How to set a variable in the main timeline of in a symbol?

    Just get started with Animate and coming from Flash, it may be apparent to my question. How do you define a variable for the main timeline of in a symbol?

    I have 24 pairs of clickable elements, each in their own symbols, and 24 of these symbols to sit inside another symbol. I want every 24 to set the global variable even when you click on it. I do not find that this question is anywhere, which makes me think that I can be stuck in a mentality from Flash and approaching the task in a bad way. (However, there are MANY discussions address showing how objects to different levels in the hierarchy.) Which is well covered).

    By the way, how to access a function on the main timeline of in a symbol?

    Adobe should consider putting on foot (or pages) support just for people migration form Flash. In the documents that I've met so far there seems to be a studied effort to refrain from mentioning Flash somehow. I imagine that there are many people out there like me who have a deep background in coding Flash, but start with Animate. We don't need help with most of the basic concepts, but we still have some pretty basic questions on how to achieve certain things in Animate because our knowledge of Flash gets in the way.

    Hi Bill,

    There are a lot of discussions here on the scope, but here's a way to create a global variable:

    code on Stage.compositionReady

    sym.myGlobalVar = 1;

    Then, anywhere in your project, you can check/set this var as follows:

    sym.getComposition () .getStage () .myGlobalVar = 2;

    And here is a way to create a global function:

    code on Stage.compositionReady

    sym.myGlobalFunction = function() {}

    Console.log ('myGlobalFunction');

    }

    Then, anywhere in your project, you can call this function as follows:

    sym.getComposition () .getStage () .myGlobalFunction ();

  • set a variable to the sum of 2 variables

    Hello
    How can I set the value of the variable is the sum of a + b in a package
    I get on the error message
    java.lang.NumberFormatException...

    Thank you
    Eyal

    Hello

    You need to "Refresh" the variable. You can only 'Set' constant. For example, I have variables a, b. In a package 'Set' a = 1, b = 2. Then 'Refresh' variable c as

    Select #a + #b double

    Checks if the value variable historized c = 3

    See you soon

    BOS

  • How to use the result of widget radio selection to 'show' a text box?

    Hello again,

    I have a question about widgets.

    What I want to do is to take the result of radio button widgets (in this case 1 2 rather long sentences that were available) and which will display a text box on another screen.

    Background: I have a series of slides where I ask the questions of the learner through Radio button widgets and so I get a number of variables (= penalty) they choose.

    The question I have is that I want to display all the choices they made on 1 page. Because the possible answers are relatively long I have run out of space if I simply inserts

    variables to shown as such and/or the police gets too small.

    So my idea is to use the answer that they choose to make a text box with a shorter version of the same appearo of sentence on this slide 'results '.

    So my idea is to have the learner to make their selection, then use a tip action to check what answer (= the option button), they clicked on.

    What I would do through "If XYZ variable ' 'contains (a keyword of the long sentence)' then 'show textbox YZ' etc.

    Question 1: Is this the most simple/more convenient way or I can save me time somwhow?

    2 "contain" a medium of action adv. the exact text or it may be just one of the words (out of the long sentence that could be selected)? I ask because then I have to use the same long exact phrase in the NOA that seems awkward.

    3. I need to create a separate fast action for each radio widget, I've used. Is this correct?

    4 if I then say 5 adv. actions for different questions, I asked what should trigger these advanc. action? The goal is just to shorten the long sentences in the selections made?

    If I use ' enter' for all the screen I just started one, I haven´t?

    Many probably incorrect assumptions, on my part, I guess...

    Any help is greatly appreciated!

    In my example the var who will get the short sentence is v_class. It's always the variable associated with the interaction of radio buttons. You have as much of these variables to be inserted on the last slide you have interactions button radio please never enter the variable to insert, but use the X button in the role of composition of the properties panel for the text container. Variables are case sensitive, in this way, you will avoid typos.

  • Set a variable to the selected path name Photoshop

    I am trying to assign the name of the currently selected Photoshop (like, normal) route to a variable.

    I can do it for an artLayer as follows app.activeDocument.activeLayer.name; but I searched the web a way to isolate the active path.

    Could someone help with this?

    Thank you

    Limey

    Ah, I misunderstood.

    This might help:

    determine the path selected, set to day 09.2015.

    function selectedPath2015 () {}

    try {}

    Var ref = new ActionReference();

    ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("targetPathIndex"));

    ref.putEnumerated (charIDToTypeID ("Dcmn"), charIDToTypeID ("Ordn"), charIDToTypeID ("Trgt"));

    var docDesc = executeActionGet (ref);

    return app.activeDocument.pathItems [docDesc.getInteger (stringIDToTypeID ("targetPathIndex"))]

    }

    catch (e) {return undefined}

    };

  • How to set a Variable with the data Srouce store data

    Hello ODI Experts.
    I created a physical & logical schema and a Data Source store collection data to a database table.

    On the other hand, I have a little variable I'll pass in a web service call (ODIInvokeWebService tool).

    Yo please guide how do I set up my store of data source variables.

    Thank you and best regards,
    Arfaoui

    Hello

    You can close this thread you opened another for your question.

    To answer you second point, it depends on what you select. You can use the function list_agg of values separated by commas if you wish. Or add/edit you WHERE to ROWNUM = 1 to clause example

    See you soon

    BOS

  • by comparing the form variable to the result of the query

    Hello
    I'm trying to compare a form variable to what is in the database. Two transmitted variables - "form.employid" and "form.class". If the person chooses the wrong class or made a typo, then I get an error message. It sounds pretty simple, but I just don't get it. I want to compare "form.class" with COURSE_TTTLE in the database. If the "form.class" that the user selects does not match any COURSE_TITLE s in the database then I want to raise an error and told recheck. Here is my code

    < IsDefined ("form.employid") cfif >

    < cfquery name = "all" datasource = "hr1" >
    Select EMPLID, COURSE_START_DT, COURSE_END_DT, SESSION_NBR, COURSE_TITLE
    Of PS_TRAINING
    WHERE EMPLID ='#FORM. EMPLOYID #'

    < / cfquery >
    < / CFIF >


    It works well on it, but it's the cfif with that I have a problem. Here's the problem code:

    cfoutput query = "all" >
    <! - if the employee id and the title of the course are not in the same record, then run a mistake - >
    < cfif TRIM ("form.class") eq ' #COURSE_TITLE # ' >
    We do not show you as having enrolled in the course. Please check your employee ID and reselect a course.
    < cfabort showerror = "No class" >

    < cfelse >

    #EMPLID # #COURSE_TITLE
    < / cfif >
    < / cfoutput >

    I thought about it - you must use compare (form.class, #COURSE_TITLE #)

    Then use cfswitch to compare and send the appropriate response. Here is the solution:

















    This is the default case





    #expression #.

  • ODI error - no value to set this variable when the scenario planning

    Hi all

    I will carry out the PIP of accounting revenue to load XML BRM for Oracle GL data. When I run the package by using a local agent, the data is loaded successfully by ODI gl_interface table. However, when I schedule the script to load the data of gl BRM to GL_interface table of ODI I get the following error. Kindly help

    java.lang.Exception: error: no value to assign to this variable for DefDate:2007 - 05-17 14:21:47.0
    DefN:null
    DefV:null
    IndStore:L
    ITxtDefT:4141200
    ITxtVar:null
    SessNo:215200
    VarDatatype:T
    VarName:PORTAL_TO_ORACLE_GL_PROJECT. PVV_SOB_ID
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlV.execStdOrders (SnpSessTaskSqlV.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt (SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlV.treatTaskTrt (SnpSessTaskSqlV.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask (SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlV.treatTask (SnpSessTaskSqlV.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep (SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession (SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandScenario.treatCommand (DwgCommandScenario.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute (DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.i (e.java)
    at com.sunopsis.dwg.cmd.g.y (g.java)
    at com.sunopsis.dwg.cmd.e.run (e.java)
    at java.lang.Thread.run(Thread.java:595)
    Thank you
    Anand

    Ok

    If you get more problems, let know us.

    Please, remember to close the request if the problem is solve and also, to assing status each answer which was useful or appropriate for you.

    Thank you

    Cezar

  • JS CS4: Create the variable for the active layer, and then select the layer at the end of a script

    I'm come white with the verbiage and spin my wheels with OMV guide and script.

    var myOriginalLayer = app.activeDocument.layers.item (0);
    Alert (myOriginalLayer)

    Returns "layer object" and not the name of the layer.

    var myOriginalLayer = app.activeDocument.layers.lastItem () .name;

    Returns the name of the layer I want but not by choice.

    I am challenged on how to select the layer.

    Hi John,.

    The difference lies in that the [Object Layer] is the real object, and the 'name' is a property - like color.

    You can use one of these two approaches:

    var myOriginalLayer = app.activeDocument.layers.item (0);
    Alert (myOriginalLayer.Name);

    hosts the original layer object, and you can see the name if necessary :-)

    For re - select the layer, use

    app.activeDocument.activeLayer = myOriginalLayer;

    You can also select name goes like

    var myOriginalLayerNAME = app.activeDocument.layers.lastItem () .name;

    ...

    app.activeDocument.activeLayer = app.activeDocument.layers.item (myOriginalLayerNAME);

    I also noted the following:

    app.activeDocument.layers.item (0) points to the first layer of your document; not the 'active'. Similarly, app.activeDocument.layers.lastItem () points only to the very last. I don't know if the order of the activeDocument.layers array mimicks the order as shown in the tags palette, but I hope for it :-)

    To get/set the active layer, use app.activeDocument.activeLayer as shown above.

  • How to enable the Java Script function in APEX 4.2.6 running on the result of an Xquery query.

    How to take a SQL query result in the source section of an APEX "agenda of the page" field and allow this request to be formatted using XML in an HTML format for a Java Script file to perform a function on the result?

    Currently I have the following text:

    To query the DB table and format the result as HTML:

    SELECT XMLELEMENT ("UL id ="ticker01"', XMLAGG (XMLFOREST (Scroll_Mess AS LI))") "item UL' OF Web_Ticker where Mess_Id < 10 order by Mess_Id;


    That displays the following:


    < UL id = "ticker01" > < LI > HELLO < /LI > < LI > HELLO < /LI > < /UL id = "ticker01" >

    I need the output of this to be visible to a JScript function that is currently called the "head of page", but there doesn't seem to be its scope? The function works correctly if there is a list in the page field items 'Text element Pre' but does not work correctly when used in conjunction with the query to generate a table form.

    If everyone is happy to help I would be grateful .

    James.

    Solved!

    In order for the request to be part of the DOM of the page of the APEX, the Java Script allows to perform its function on the result marked "HTML" to query, you must set page of the apex on which the query resides and then add the inner text of this page to a second variable for which the function of web ticker can run on as follows:

    $(function() {})

    var x = $("#P9_TICKER_DATA");

    var y = x [0] .innerText;

    x.Append (y);

    $("UL#ticker01").liScroll ();

    });

    From there, on the Java script is able to properly see the result of the query in HTML format.

  • Variables in the title page

    Hi all

    Can it be done in HR 2015? I've implemented my own title page using a word doc, but I want more than a logo and company name doc in the title page. I want to add numbers version using variables, and I want to be able to set a variable in the text, but also the product name changes slightly with different versions. Is this possible?

    Thank you

    Nick

    If you use a Word doc as your title page, then you can only use Word features. What you need to do here, is create a topic in the goal and that insert on the third page of the dialog configuration instead of a Word doc.

    See www.grainge.org for creating tips and RoboHelp

    @petergrainge

  • How to assign the variable in the SQL script?

    I have the below running to generate the XML from the file.
    set long 100
    set pages 0
    set trimspool on
    set serveroutput on
    set echo off
    set terminal off
    variable out CLOB
    begin
            pack.proc('&&1','&&2',:out);
    end;
    /
    spool /dir/loc/file1.xml
    select :out from dual;
    spool off
    I'm queue in the order of the coil, the output to a file named file1.xml. I invoke this SQL script from a shell script, I will pass variable association 3rd since the shell script which I want to use in the file ' & & 3'.xml. Help me set this variable to the DIGITAL field in this SQL script and how can I add to the command of the coil?
    set long 100
    set pages 0
    set trimspool on
    set serveroutput on
    set echo off
    set terminal off
    variable out CLOB
    define var1='&1' -- to allow for more readable code
    define var2='&2'
    define var3 ='&3'
    begin
            pack.proc('&var1','&var2',:out);
    end;
    /
    spool /dir/loc/file&var3..xml -- note the substition variable has  . appended
    print out
    spool off
    

    ------------
    Sybrand Bakker
    Senior Oracle DBA

  • How to replace the variable with the help OF the operator?

    Hello

    I'm creating a form where the user selects the check box which products he wants to see. After the choice, I should show all sales of this product, but the selection does not recognize the variable after the IN operator, for example:

    SELECT the product, price, quantity
    FROM the sale
    Product WHERE IN (vcProducts);

    Can someone help me?

    Cree

    I guess that vcProduct is a varchar2 variable where you have a chain of your prodids, as ' 4711,4712 concatinated, 4713'. May be you have each place value '. Is not the question, which is not part of the sql syntax set. You either have a list of enumeration or a subselect.

    Where do you need it? In the block or Pl/Sql where clause.
    In the latter case, you can configure the list in a variable (with enclosing "") and set the block where property.

    In the first of may by INSTR is useful, INSTR (vcProduct, vcDelim | table.prod_id | vcDelim) > 0. Make sure you have your list attached and separated by the vcDelim. If you prodct table with the number of lines (million), it can be slow because no index will be used.

    Dynamic sql or.
    Or write a subquery und temp-table.

  • Is a cursor variable determined by the result set persistence pause feature?

    My world of PL/SQL is upside down: I'm expecting cursor set persistence any operation of inner loop can affect the result. This does not work as expected with an aggregation as subquery (see sal_dept), but adds little by little upward in determining the value of the slider by a function (see sel_debt_funct). What is the reason for this behavior? Bug feature?

    Facts: Oracle 10.2.0.4
    CREATE OR REPLACE FUNCTION get_sal_dept(
        pdeptno IN emp.deptno%TYPE
    )
        RETURN emp.sal%TYPE
    IS
        lnreturn  emp.sal%TYPE;
    BEGIN
        SELECT SUM(sal)
        INTO   lnreturn
        FROM   emp
        WHERE  deptno = pdeptno;
    
        RETURN lnreturn;
    END get_sal_dept;
    /
    
    BEGIN
        FOR r_emp IN (SELECT empno
                            ,ename
                            ,sal
                            ,emp.deptno
                            ,sal_dept
                            ,get_sal_dept(emp.deptno) sel_debt_funct
                      FROM   emp
                            ,(SELECT   deptno
                                      ,SUM(sal) sal_dept
                              FROM     emp
                              GROUP BY deptno) x
                      WHERE  emp.deptno = x.deptno)
        LOOP
            UPDATE emp
            SET sal = sal * 1.33
            WHERE  empno = r_emp.empno;
    
            DBMS_OUTPUT.put_line(r_emp.ename
                                 || ': '
                                 || r_emp.sal
                                 || ' Total Deptno: '
                                 || r_emp.deptno
                                 || ' by inline aggr:'
                                 || r_emp.sal_dept
                                 || ' by function:'
                                 || r_emp.sel_debt_funct
                                );
        END LOOP;
    
        ROLLBACK;
    END;
    /
    
    DROP FUNCTION get_sal_dept
    /
    Result:

    CLARK: 2450 Deptno Total: 10 by aggr:8750 inline by function: * 8750 *.
    KING: 5000 Deptno Total: 10 by inline function aggr:8750: * 9558.5 *.
    MILLER: 1300 Deptno Total: 10 by inline function aggr:8750: * 11208.5 *.
    JONES: 2975 Deptno Total: 20 by inline aggr:10875 by function: * 10875 *.
    FORD: 3000 Deptno Total: 20 by inline function aggr:10875: * 11856.75 *.
    ADAMS: 1100 Deptno Total: 20 by inline function aggr:10875: * 12846.75 *.
    ...
    ...

    Edited by: user577229 the 07.06.2011 09:27

    Published by: BluShadow on June 8, 2011 08:29
    addition of {noformat}
    {noformat} tags                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

    If I understand your point, the key concept to understand here is related to "* statement-level Read consistency and coherence of reading at the level of transactions."

    From the Manual:
    + "If a SELECTION list contains a function, then the database applies consistency of reading to the statement-level to the level of the SQL statement executed in the PL/SQL function, rather than the parent level SQL code. For example, a function can access a table whose data are changed and committed by another user. For each execution of the function, SELECT a snapshot consistent new reading is established. » +

    These two concepts are well explained in the "Oracle® Database Concepts":
    http://download.Oracle.com/docs/CD/B19306_01/server.102/b14220/consist.htm#sthref1955

Maybe you are looking for

  • HP 15-ay503tx: USB Driver for hp 15-AY503tx

    I downloaded and installed all the important drivers on the hp site. But I am not able to connect the USB to the laptop. I checked again in the list of drivers, but there seems to be no driver for USB. I don't know how to follow upwards to make the U

  • HP 3115 m: password lost admin

    I've lost my admin password and I get a code. 93810442

  • revolve 810

    I have before me a 810 turn EliteBook with a blank disc (no recovery partition). I have not any restoration or recovery media. Where can I get something to perform a restore factory on this unit?

  • Replace the HDD with SSD boot disk and use the disk HARD now as secondary storage

    I would like to replace my dv7 - 6143cl HDD with a SSD boot drive and using the OEM HARD drive as secondary storage. I have the SSD and the caddy I need to: delete the original OEM HD Install the SSD install OEM HARD drive in secondary Bay Install Wi

  • HP OFFICEJET PRO 8610: Fax problems

    I can receive faxes if I manually select to receive a fax, but if I'm missing the line will just ringing and ringing and never take. I got response AUTOMATIC activated so please help!