passing point to pl/sql to modify the query

Hi all

I'm new to apex and appreciate any help :)

what I'm trying to do is show point of interest on the map and filter them :)

what I have done:

I have an exclu.1 where a list and when you click on the link it has you sent to page.2 with 3 elements, "type" start date "end date".
the type is the type of point :)
start date and end date are the dates of today who are from db when you click

When page.2 open I see 3 items on the page
the body of the page load a pl/sql procedure that:

pl/sql code on page.2
"start item_locations; end; »

queries the database and returns them
'type' values 'date' 'id' "lat, long" from different tables

example;
ID type lat, long
coffe 2 40.386289,49.824348 5 October 7, 12 10.37.54.000000 PM
40.386289,49.824348 tea 2 5 7 October 12 10.37.54.000000 PM
power supply 2 40.386289,49.824348 5 October 7, 12 10.37.54.000000 PM
40.386289,49.824348 car 1 5 7 October 12 10.37.54.000000 PM
40.386289,49.824348 bars 3 5 7 October 12 10.37.54.000000 PM
shops 6 40.386289,49.824348 5 October 7, 12 10.37.54.000000 PM

then the procedure takes excursions as 'htp.print' and creates a map and show ALL points.

I want to do 2 things
(1) I want to filter whats shown on the page by type and date when the loading of the page (assuming that users coming from exclu.1 with full elements :))
My idea is to add "where type = * point page.2 type * and date * page point date1 * between * page point date2."

(2) add a button and if I manually enter/edit the page lists on page 2. them click on the button will have new results :)


by the installer:
WIN8 64bits
Oracle db express
Request Express 4.0.2.00.09

Thanks in advancce

Looks like a great app!

The best way to proceed would be to change your item_locations of procedure to include the three parameters that you want to use, so that your procedure looks like:

PROCEDURE item_locations
(p_type VARCHAR2 DEFAULT NULL
,p_start_date DATE DEFAULT NULL
,p_end_date DATE DEFAULT NULL)
IS ...
BEGIN
...
Select col1, col2, col3
from my_table
where type = NVL(p_type,type)
and my_date between NVL(p_start_date,my_date) and NVL(p_end_date,my_date)

htp.p(my_data)

END  item_locations;

etc
-- Note  - this is purely example code and not intended to compile as is. Just saying.

Then in your page apex process, simply call

BEGIN
item_locations (:P2_ITEM, :P2_START_DATE, :P2_END_DATE);
END;

I hope this makes sense. Looks like you're new as you have not had the pleasure to the 2 day Developer Guide. I highly recommend do you if you are not familiar with Apex - it is a necessity.

Best regards, Pete

Tags: Database

Similar Questions

  • Modify the query

    I have a question,
    Select Distinct Pod, Filer From Fhm_Filer_Pod_Volume_D Where Pod='ABCSA'
    that the output is as

    ABCSA ac32p25
    ABCSA ac32p27

    The query can be modified so that the output will be like b

    ABCSA ac32p25, ac32p27

    ?

    Thank you.

    Published by: Kuldip on April 19, 2012 02:17
    with t as
    (select 'ABCSA' pod, 'ac23fs' filer from dual union
    select 'ABCSA', 'akskks' from dual
    )
    SELECT   pod, max(substr(SYS_CONNECT_BY_PATH (filer, ','),2)) PATH
          FROM (select rownum rn,
                       a.*
                  FROM (Select * from t order by filer desc) a
                 WHERE POd='ABCSA' )
    CONNECT BY PRIOR rn =rn - 1
     group by pod
    
  • SQL text of the query are output in the output of the coil-ed

    Hello

    I have s script that starts with sql * more:
    SET SERVEROUTPUT ON
    SET LINESIZE 1000
    SET ECHO OFF
    SET TERMOUT OFF
    SET FEEDBACK OFF
    
    SPOOL /home/scott/out.txt
    
    SELECT col_1||';'||col_2 FROM table1;  --and my select statement here!
    
    SPOOL OFF
    My out.txt must contain all records from table1, where the fields are separated by a semicolon.
    Unfortunately, out.txt also contains the text of the query itself:
    SELECT col_1||';'||col_2 FROM table1
    ------------------------------------
    1;one
    2;two
    
    AND SO ON!
    How can I Remove the text of the query output?

    Thank you!

    Looks like you want to delete the pages headers. VR;

    set pagesize 0
    
  • Why SQL * more divide the query result?

    My result is:
    ENAME, DEPTNO SAL RUNNING_TOTAL DEPARTMENT_TOTAL SEQ
    ---------- ---------- ---------- ------------- ---------------- ----------
    10 2450 2450 2450 1 CLARK
    KING 10 5000 7450 7450 2
    10 1300 8750 8750 3 MILLER
    20 1100 9850 1100 1 ADAMS
    20 3000 12850 4100 2 FORD
    20 2975 15825 7075 3 JONES
    20 3000 18825 10075 4 SCOTT
    SMITH, 20 800 19625 10875 5
    30 1600 21225 1600 1 ALLEN
    30 2850 24075 4450 2 BLAKE
    30 950 25025 5400 3 JAMES

    ENAME, DEPTNO SAL RUNNING_TOTAL DEPARTMENT_TOTAL SEQ
    ---------- ---------- ---------- ------------- ---------------- ----------
    30 1250 26275 6650 4 MARTIN
    30 1500 27775 8150 5 TURNER
    30 1250 29025 9400 6 DISTRICT

    14 selected lines.

    It is very annoying and I wonder if there is a way to tell SQL * Plus, don't not to divide this result by 2 sub-results.

    user8931607 wrote:

    It is very annoying and I wonder if there is a way to tell SQL * Plus, don't not to divide this result by 2 sub-results.

    Well, then you should RTFM. Learn more about SQL * Plus PAGESIZE, property:

    SQL> select ename from emp
      2  /
    
    ENAME
    ----------
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    
    ENAME
    ----------
    JAMES
    FORD
    MILLER
    
    14 rows selected.
    
    SQL> set pagesize 100
    SQL> select ename from emp
      2  /
    
    ENAME
    ----------
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    
    14 rows selected.
    
    SQL> 
    

    SY.

  • Extend the VO - need to change the query of VO - screen is off

    {Re-post the message in this forum (thanks to John Stegeman to lead me here...)   {Posted: August 28, 2009 04:27}

    Dear all,

    Thanks to this great body of knowledge, I ask my questions.

    I need to extend a VO to display the name of the country.
    The column is not in the VO. So, I need to get another table: FndTerritories

    I want to change the query, but the request frame is turned off (in the wizard the View - step 5 of 6 - Generated statement object substitution)

    Could you be it someone please let me know: how to change the application of the VO in this case?

    OR is there another solution for such cases, to maintain development standards

    Thank you very much

    Kind regards

    Hello

    I think that's when you just have to add an attribute, you should not click the expert mode checkbox... make use of
    Mix and add the button.

    But when you need to modify the query, and then we want to use to modify the query window...

    Thank you
    Gerard

  • pl/sql block, reading the reading of data from the table to a single point in time

    I'm trying to figure out if several cursors in a PL/SQL block are executed inside a single Point in time, and so don't see no updates of paintings by other processes or procedures running at the same time.

    The reason why I ask is I have a block of code as an initial extraction of data, with some Sanity Check before the code runs. However, if another procedure might modify the data between the two, then the mental health check is not valid. So I am essentially trying to know if there is consistency read in a PL/SQL, preventing updates to other processes to be seen.

    Anyone who has an idea?
    BR,
    Chambaz

    Google SET Transaction.

    or

    Follow this link

    http://download-West.Oracle.com/docs/CD/B12037_01/server.101/b10759/statements_10005.htm

    Kind regards
    Prazy

  • When going through the process of downloading with social monkee and reach the point add it to firefox, I get the following message: "social Monkee cannot be installed because firefox is unable to modify the required." How can this be repaired?

    When going through the process of downloading with social monkee and reach the point add it to firefox, I get the following message: "social Monkee cannot be installed because firefox is unable to modify the required." How can this be repaired?

    Which is usually caused by a lack of unpacking the directive (< em: unzip > true < / em: unzip >) in the file install.rdf to this extension.

    See https://developer.mozilla.org/En/Updating_extensions_for_Firefox_4.0#XPI_unpacking

  • 0 and the decimal point in Oracle SQL

    Hello


    IM using Oracle Sql developer 'Oracle Database 11g Enterprise Edition Release 11.1.0.6.0' (I'm fairly new), im having trouble inserting '0 before 1' in the table, as well as with the decimal point
    I created a table with the following:

    CREATE TABLE employee
    (Employe_id number (4,0) NOT NULL primary key,)
    L_Name varchar2 (15).
    What varchar2 (10),
    Number of Pay_Rate (5);

    Then tried to insert this: insert into employee
    values ('003', 'Clarke', 'Michael', '13 h 00');
    which has been a success, but when I used the query select it to display the table, the result was not the same

    result:
    Employee_id L_Name what Pay_Rate
    1 13 Michael Clarke


    How can I ensure that the result looks like this (001 and 13 h 00):
    Employee_id L_Name what Pay_Rate
    001 Micheal Clarke 13.00

    Edited by: 936867 may 25, 2012 20:15

    Edited by: 936867 may 25, 2012 20:18

    936867 wrote:
    Sorry, I wanted to ask "what needs to be changed in the create table statement, so when I introduced through the 'Insert into' data is presented as above after the select query. I want the data to show as entered when I look at the table, I know that can use the select query to display data in the desired format.

    Then do not define the columns as a NUMBER, but as strings of VARCHAR2,
    but realize that you can't do arithmetic on strings.

    NUMBERS have no beginning or ending zeros but bites can contain what you want.

  • Pass Pl/sql table in the USING clause in the EXECUTE IMMEDIATE statement

    Getting error when I try to pass the PL/SQL table in the USING clause in the EXECUTE IMMEDIATE statement:

    Declare
    result NUMBER;
    TYPE values_tab IS TABLE OF NUMBER INDEX OF directory;
    lv_tab values_tab;
    lv_exp varchar2 (300);
    lv_exec varchar2 (300);
    BEGIN
    lv_tab (1): = 5;
    lv_tab (2): = 48;
    lv_tab (3): = 7;
    lv_tab (4): = 6;
    lv_exp: = ': + b1: b2 + (: b3 *: b4)';
    lv_exec: = 'SELECT'. lv_exp | ' THE DOUBLE '.

    IMMEDIATE EXECUTION
    lv_exec
    IN
    result
    USING
    lv_tab;
    DBMS_OUTPUT. Put_line (result);

    END;
    /

    Error on line 1
    ORA-06550: line 20, column 12:
    PLS-00457: expressions must be SQL types
    ORA-06550: line 15, column 8:
    PL/SQL: Statement ignored


    I am trying to evaluate the expression ': + b1: b2 + (: b3 *: b4) "which is stored in the table. This table has different expressions (expressions about 300). I want to use the bind variable in the expression because each expression evaluated thousands of time may be more in some cases. If I use bind variable can he fill pool.

    Is there a way I can pass parameters with the HELP of (IN) dynamically instead of write "help lv_tab (1), lv_tab (2), lv_tab (3), lv_tab (4)? As number of change of the input parameters depend on the expression in the table.

    If it is possible please suggest any other ideas/approaches

    Help, please...

    Published by: satnam on June 11, 2009 11:50

    Well, you keep changing faster reqs that I can follow. In any case, assuming that N-th variable bind (left to right) corresponds to n-th collection item:

    Declare
        result NUMBER;
        lv_tab values_tab := values_tab();
        lv_exp varchar2(300);
        lv_exec varchar2(300);
        lv_i number := 0;
    BEGIN
        lv_tab.extend(4);
        lv_tab(1) := 5;
        lv_tab(2) := 48;
        lv_tab(3) := 7;
        lv_tab(4) := 6;
        lv_exp := ':5000135+:5403456+(:5900111*:5200456)';
        lv_exec := lv_exp;
        While regexp_like(lv_exec,':\d+') loop
          lv_i := lv_i + 1;
          lv_exec := REGEXP_REPLACE(lv_exec,':\d+',':b(' || lv_i || ')',1,1);
        end loop;
        lv_exec := 'BEGIN :a := ' || lv_exec || '; END;';
    DBMS_OUTPUT.PUT_LINE(lv_exec);
    EXECUTE IMMEDIATE lv_exec USING OUT result,IN lv_tab;
    DBMS_OUTPUT.PUT_LINE(result);
    END;
    /
    BEGIN :a := :b(1)+:b(2)+(:b(3)*:b(4)); END;
    95
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • Why when I point where says "all programs", said the white box ' (empty), the same thing when I point to the administrative tools? How to reset to where he was before?

    I'm a novice help!

    Hi robertzee,
     
    -Did you of recent changes made to your computer before this problem?
     
    Method 1: Follow the suggestion given in this link and check if this may help in fixing the issue:
     
    Method 2: Try the following steps to get the contents of the folder "admin tools".

    Important: This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs.

    For more information about how to back up and restore the registry, click the article windows below:

    How to back up and restore the registry in Windows

    a. Click Start. Click run.

    b. type regedit.exe, and then press ENTER.

    c. in the Registry Editor window, navigate to these locations:

    • HKEY_LOCAL_MACHINE-SOFTWARE-Microsoft-Windows-CurrentVersion------Explorer------user Shell folders
    • HKEY_LOCAL_MACHINE-SOFTWARE-Microsoft-Windows-CurrentVersion------Explorer------shell folders

    d. delete the value named common administrative tools (if any).

    e. close Regedit.exe and restart Windows.

  • After a passage to the we modify the tnsnames address list or y at - it another option using TAF

    We have work on Oracle running on Oracle Linux 6.7 11.2.0.3.   We have the only non rac primary and secondary instance unique instance no cars. We have installation Application transparent failure (TAF) that works very well, we have created service, the triggers for changes of role and configuring the listener.  We have after tns

    TAFTEST =

    (DESCRIPTION =

    (ADDRESS_LIST =

    (FAILOVER = ON)

    (LOAD_BALANCE = OFF)

    (ADDRESS = (PROTOCOL = TCP)(HOST = taf.one.us) (PORT = 1521))

    (ADDRESS = (PROTOCOL = TCP)(HOST = taf.two.us) (PORT = 1521))

    )

    (CONNECT_DATA =

    (SERVER = DEDICATED)

    (SERVICE_NAME = TAFTESTSERVICE)

    )

    )

    TAF - one is the main stream.  everything is good.  We do a failover and TAF does its job.  Select continue, sessions already open before the work of swtichover very well subsequently without errors.

    However, no meeting again fails with ORA-01033: ORACLE initialization or shutdown in progress since the taf-one-us is now not the day before the main.  If I manually modify the AMT so that taf - two.us is first then it works fine as it is now the main.

    We tried (LOAD_BALANCE = ON) 1/2, but by the time we get the same error since it randomly chooses the standby address.

    is this what we can add to the entrance of the AMT so that if the address of the 1st operation fails, it takes the second.  understanding is that it is the default behavior, but it doesn't work like that.   We do something wrong?  We followed the code in Re: TAF on 11g DataGuard with FSFO

    I think I found the cause and solution.

    After some research (for example https://docs.oracle.com/cd/B28359_01/server.111/b28294/role_management.htm), I found that there was an additional trigger.  Failovers undergo a transition of role. Therefore, a relaxation on the role changes to start and stop the service as needed.

    The following trigger

    create trigger WHENROLECHANGE after DB_ROLE_CHANGE ON DATABASE
    declare
    v_role varchar (30);
    Start
    Select database_role in the v_role of the v database $;
    If v_role = "PRIMARY" then
    DBMS_SERVICE. START_SERVICE ('drrpt');
    on the other
    DBMS_SERVICE. STOP_SERVICE ('drrpt');
    end if;
    end;
    /

    now makes the configuration of the work.  Selects existing continues to work to pick up where they were on the other server, existing connections continue to meet, and new connections go to the correct server without getting an error.  When we make him switch to return chooses to continue to work and new connections to connect to the appropriate server.

    Note that this is usually done for logical standby, but we need for physical too checksection 8.2.1 perform a failover of a physical database from the previous day

    Step 4 Verify that the goal of the digital switchover is ready to be switched to the primary role.

    Step 5 place yourself in the role of physical standby database target the main role.

    Run the following SQL statement on the basis of Eve physical target:

    SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
    

    6. open the new primary database.

    SQL> ALTER DATABASE OPEN;
    

    Step 7 Start repeat if applied on the new information physical standby database.

    Note that there no restart of the previous day, triggering of start on not be triggered.  had he been restarted while this would have worked, since it was not we need the additional trigger for the role to change.

    Thank you all for your efforts and work.

  • Try to run a SQL statement through the window of OEM 12 c run SQL.  Statement fails

    All,

    I have a 11g database.  When it is initially installed, I installed it in $ORACLE_BASE = / orabin/app/oracle/product and $ORACLE_HOME = $ORACLE_BASE/11gDB_R2.  This is the version 11.2.0.1 to give birth to 11.2.0.3.

    Recently, I installed 11.2.0.4 in $ORACLE_BASE/11.2.0.4.  Then, I upgraded my database at 11.2.0.4.  Everything works fine.

    All my scripts on the linux host logon changed to point my environment at $ORACLE_BASE/11.2.0.4 House and my $PATH when I connect to the linux host is: /orabin/app/oracle/product/11.2.0.4/bin:/orabin/app/oracle/product/11.2.0.4/OPatch:/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin

    On my OEM Console, the database appears as 11.2.0.4 and me can manage very well.

    However, when I try to use the window of the OEM Console to execute SQL to execute any type of SQL statement, it fails.

    The failure error is:

    Could not launch/orabin/app/oracle/product/11gDB_R2/bin/sqlplus-s/nolog: no such file or directory

    It would be a mistake since the 11gDB_R2 directory tree (the 11.2.0.3 software) has been removed from the host, now that the database is set to level and working as 11.2.0.4.

    I wonder if somewhere in the OEM software, there is always a pointer to the old ORACLE_HOME?  I can't find anything in the .bashrc or other shell scripts that are executed when a Shell session on the host computer which were still the reference to the old directory of 11gDB_R2 so I'm a bit puzzled.

    I have 8 guests, and all have been improved in the same way at 11.2.0.4.  For some databases, the OEM window run SQL is executing the SQL code.

    Someone has some ideas on this?

    Go to the Configuration of the analysis of the database (when you set the password) and update of the Oracle home.   Also do this for all targets listener on this host as well.

  • PL/SQL, help in the validation of the data exists in a table.

    Greetings,

    I'm still new to PL/SQL and try to create a stored procedure that would allow me to check if a user exists in the connection table.  The final objective is to have a connection of the user to an ASP.net web application and have a stored procedure validate the user exists in the table user.

    To start, I just want to test the SP only from the DB.  So, I'm wondering how I can configure the parameter with a value to imitate an application by passing a value to this parameter.

    Here is my code for the SP that was compiled without error.

    CREATE OR REPLACE PROCEDURE SP_LOGIN_CHK

    (

    P_USRNAME IN VARCHAR2

    ) IS

    v_login_id VARCHAR2 (20);

    BEGIN

    Select login_id

    in v_login_id

    of login_user where v_login_id = p_usrname;

    END SP_LOGIN_CHK;

    Here is what I use to run the stored procedure...

    exec sp_login_chk('Chris');

    I get an error "no data found".  However, when I run this query on the database, I get 1 line returned.

    Select login_id login_user where login_id = "Chris";

    Hello

    cjpicc11 wrote:

    Greetings,

    I'm still new to PL/SQL and try to create a stored procedure that would allow me to check if a user exists in the connection table.  The final objective is to have a connection of the user to an ASP.net web application and have a stored procedure validate the user exists in the table user.

    To start, I just want to test the SP only from the DB.  So, I'm wondering how I can configure the parameter with a value to imitate an application by passing a value to this parameter.

    Here is my code for the SP that was compiled without error.

    CREATE OR REPLACE PROCEDURE SP_LOGIN_CHK

    (

    P_USRNAME IN VARCHAR2

    ) IS

    v_login_id VARCHAR2 (20);

    BEGIN

    Select login_id

    in v_login_id

    of login_user where v_login_id = p_usrname;

    END SP_LOGIN_CHK;

    Here is what I use to run the stored procedure...

    exec sp_login_chk('Chris');

    I get an error "no data found".  However, when I run this query on the database, I get 1 line returned.

    Select login_id login_user where login_id = "Chris";

    At the same time that you run the query, the local variable v_login_id has the value NULL, then the condition:

    where v_login_id = p_usrname;

    won't be true.  I bet you want to use the column in the table in this condition, not the local variable, like this:

    where login_id = p_usrname;

  • Are constants of body of the PL/SQL Package in the shared or private area

    Based on that it is not clear to me if body Package PL/SQL constants are stored in the shared or private area.

    http://docs.Oracle.com/CD/B28359_01/server.111/b28318/memory.htm

    "PL/SQL program units and the Shared Pool

    Oracle database treats PL/SQL program units (anonymous blocks, procedures, functions, packages and triggers in database) much the same way he treats the individual SQL statements. Oracle database allocates a shared area to hold the shape analyzed, compiled a program unit. Oracle database allocates a private space to hold values specific to the session who runs the program unit, including local, global and package variables (also known as the package is instantiated) and stamps of SQL execution. If more than one user is running the same program unit, a place unique and shared is used by all users, while each user runs a separate copy of his own private SQL area containing session-specific values.

    The individual SQL statements contained in a PL/SQL program unit are processed as described in the previous sections. Despite their origins within a PL/SQL program unit, these SQL statements use a shared area to hold their analysed representations and a private space for each session, who executes the statement. »


    I am also curious to know what are the differences in fine grain in a perspective of memory and performance (multisession) for the two examples below. One is more effective?


    Example 1.

    create or replace
    package body
    application_util
    as

    c_create_metadata constant varchar2 (6000): =...

    procedure process_xxx
    (
    )
    as
    Start
    ...
    end process_xxx;

    end application_util;

    vs.

    Example 2.

    create or replace
    package body
    application_util
    as

    procedure process_xxx
    (
    )
    as

    c_create_metadata constant varchar2 (6000): =...

    Start
    ...
    end process_xxx;

    end application_util;

    881398 wrote:

    But I still have to ask because it seems still more particularly in example 1 that the constant can be attributed to the use that the actual value could be a pointer to a constant string value in a table of symbols or something related to the compilation unit. I'm always curious in a perspective of management of memory if there is a difference between the example 1 and example 2, and if one is better and why.

    The storage is real, references to this storage internal to the PL/SQL engine. And irrelevant to the PL/SQL programmer.

    This question is really a disagreement over the shape is better: example 1 or example 2. I prefer the 1 example, for readability, testability, etc., and so the question is where is the performance of the memory/differences and or is it just preference of developer.

    I agree with rp0428 - he raised a very important point that it is a problem of scope and nothing else.

    Basically is there any trade-off between using one shape on the other insofar as the performance and memory management?

    Not really. Most runtime engines release not just actual system memory when a variable is out of range. the malloc() calls are expensive. Free() calls are expensive (and are not always the result in usable free memory which can be malloc'ed again).

    Several execution engines use what is called a managed heap. A malloc is made of a new process when it is initialized. The heap memory / managed malloc'ed is adjacent. Pointer allocation of memory for this process is initially pointing to the base of the managed heap. As the process allocates / uses memory, the pointer is moved just advance in the managed heap, which indicates the HWM as such - the beginning of the 'free' memory in the heap. Allocation is sequential.

    Reset of your variable execution, or releasing your runtime object, does not reset the HWM as other objects/variables can still be used and located after this place in the bunch. In this case set him free memory by releasing / resetting the language variables does not restore the kernel memory.

    Memory management is a sophisticated process entirely processed by the engine running - and best left to the runtime engine. As you as a programmer do not explicitly control the memory management, it is not a good idea to try to write code that artificially attempt to use 'better' for the runtime engine memory management. The next version of the runtime of that aura of new features, optimizations and so on — and your interference in your code to get the "valorisation" of memory can happen just bite you not bad after an upgrade to execution.

    Regarding the performance aspect - variable initialization is dependent on scope. In order to have a global scope means a one-time initialization, whereas a private scope (created each call) is a multiple unit. If the first is a little faster than the latter.

    However, the performance differences are tiny - IMO too small to justify this as a valid consideration to spend in addition to the decision of functional design on what possibilities a variable or a constant need to have.

    SQL> create or replace package FooLib1 as
      2          procedure Exec;
      3  end;
      4  /
    
    Package created.
    
    SQL>
    SQL> create or replace package body FooLib1 as
      2          const1  constant varchar2(32767) := rpad('-',10000,'-');
      3
      4          procedure Exec is
      5                  var1    varchar2(32767);
      6          begin
      7                  var1 := const1;
      8          end;
      9  end;
     10  /
    
    Package body created.
    
    SQL>
    SQL>
    SQL> create or replace package FooLib2 as
      2          procedure Exec;
      3  end;
      4  /
    
    Package created.
    
    SQL>
    SQL> create or replace package body FooLib2 as
      2          procedure Exec is
      3                  const1  constant varchar2(32767) := rpad('-',10000,'-');
      4                  var1    varchar2(32767);
      5          begin
      6                  var1 := const1;
      7          end;
      8  end;
      9  /
    
    Package body created.
    
    SQL>
    SQL> set timing on
    SQL> exec for i in 1..100000 loop FooLib1.Exec; end loop;
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.28
    SQL> exec for i in 1..100000 loop FooLib2.Exec; end loop;
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.74
    SQL> 
    

    A second difference 0.0000046 in a single execution for FooLib.Exec between the use of package for the constant scope, against increased private. Which means that the issue of the scope is not a decision of the performance. Not when improving performance overhead is 0,0046 millisecs.

  • Detroit SQL of the query in writing: analysis of the GAPS in order of Row_Wid in a Table

    I am writing a query that scans a product Dimension Row_Wid, notes the gaps in the sequence and generates the missing Row_Wids. It loads these 'missing Feds"in a sequence of wid created table to reuse by Informatica transformation of research without bond during the subsequent data loads. Yes, I expect many people asking why I do this. The simple reason is that Informatica has a limit of 2 147 sequence generator 483 647'. I arrived at this upper limit, but my table contains only 2.2 million lines of actual data. I'm trying to reuse these Row_Wids now 'not used '.

    I have a job with success the query to find the first ditch and fill some of that gap. Now my next problem is to figure out how to get my request to move away from the next. I can't use the PL/SQL in the query. My client does not allow its use.

    I'll paste the code I have now. I need to evolve to the next gap. Suggestions? Help? Ideas?



    The Version of database: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi

    The table I'm inserting: CREATE GLOBAL TEMPORARY TABLE "OLAP". "" ROWWIDVAL "("ROWWID"NUMBER (10.0), NUMBER (10,0)"EXTRAVAL") ON COMMIT PRESERVE ROWS;
    A note: the Temp Table to test this point, I've created is "RowWidVal" and it has two columns.

    -Updated Code collaboration-
    Insert Into RowWidVal(
    SELECT
         CASE
              WHEN NumGen <= GapSize+2 THEN (P2.MinGapStart-1)+NG.NumGen
         END RowWid, 0
    FROM
         (SELECT MIN(T4.GapStart) MinGapStart, MIN(T4.GapStop) MinGapStop, (MIN(T4.GapStop) - MIN(T4.GapStart)) GapSize
              FROM
                   (SELECT T2.row_wid + 1 GapStart,
                        (SELECT MIN(T1.row_wid) - 1 FROM w_product_d_test T1 WHERE T1.row_wid > T2.row_wid) GapStop
                        FROM w_product_d_test T2
                        LEFT OUTER JOIN w_product_d_test T3 ON T2.row_wid = T3.row_wid - 1
                   WHERE T3.row_wid IS NULL
                   ) T4
         WHERE T4.GapStop IS NOT NULL
      ) P2,
         (SELECT LEVEL NumGen
          FROM dual
          CONNECT BY LEVEL <= (SELECT ((Min(GapStop) - Min(T4.GapStart)) +1) GapSize
                                   FROM
                                       (SELECT T2.row_wid + 1 GapStart,
                                            (SELECT MIN(T1.row_wid) - 1 FROM w_product_d_test T1 WHERE T1.row_wid > T2.row_wid) GapStop
                                            FROM w_product_d_test T2
                                            LEFT OUTER JOIN w_product_d_test T3 ON T2.row_wid = T3.row_wid - 1
                                            WHERE T3.row_wid IS NULL
                                       ) T4
                                        WHERE T4.GapStop IS NOT NULL)
         ) NG
    WHERE P2.MinGapStart < P2.MinGapStart+(GapSize+2));
    Published by: user1002601 on 16 January 2013 08:33

    Published by: user1002601 on 16 January 2013 08:39

    How about this?

    Sample data:

    SQL> create table w_product_d_test (row_wid number);
    
    Table created
    
    SQL>
    SQL> insert into w_product_d_test (row_wid)
      2  select column_value
      3  from table(sys.odcinumberlist(1,2,3,4,5,11,12,13,31,32,33,34));
    
    12 rows inserted
    
    SQL> select * from w_product_d_test;
    
       ROW_WID
    ----------
             1
             2
             3
             4
             5
            11
            12
            13
            31
            32
            33
            34
    
    12 rows selected
     
    

    Generate sequence available numbers:

    SQL> with gaps as (
      2    select rw, gapsize
      3    from (
      4      select row_wid as rw
      5           , row_wid - lag(row_wid,1,0) over(order by row_wid) - 1 as gapsize
      6      from w_product_d_test
      7    )
      8    where gapsize > 0
      9  )
     10  select g.rw - t.column_value as available_rw
     11  from gaps g
     12     , table(
     13         cast(
     14           multiset( select level from dual connect by level <= g.gapsize )
     15           as sys.odcinumberlist
     16         )
     17       ) t
     18  ;
    
    AVAILABLE_RW
    ------------
              10
               9
               8
               7
               6
              30
              29
              28
              27
              26
              25
              24
              23
              22
              21
              20
              19
              18
              17
              16
              15
              14
    
    22 rows selected
     
    

Maybe you are looking for

  • Download Scilab on my ipad?

    Hello Download Scilab on an Ipad Air or an Ipad Pro? Maybe an apps can open on my ipad. I have an air of the Ipad, but I want to buy a pro for my work but I need Scilab on this. My Ipad air has 114 go, IOS 9,3,5, carrier 24.0 I can download Scilab th

  • 12.3.3.17 update erased my music library

    Updated to 12.3.3.17 yesterday. Open iTunes and saw almost all of my library was missing. I did the .itl file renaming. This restored all files of the Album, but not individual tracks. Since I have more than 4,000 titles, I'm not at all prone to is s

  • HP x 360 Convertible spectrum: it voids my warranty?

    My touchpad has to be tightened. I have experience with laptop repair and have all the tools, so I would rather not send it somewhere to be fixed. I also cover against accidental damage. Can I just fix it myself or that could result in the cancellati

  • Blackbird 002 RAM

    IM upgrading to the ram in my Merle, everything in the spec sheet and going threw sites as new egg when using find correct ram programs are all showing me that she uses ddr2 ram. My Blackbird comes preinstalled with 4 1600 sticks of corsair ddr3. a f

  • Refunds for iTunes

    I bought one as a gift, but accidentally bought album on my I tunes. I don't want the album. How can I get a refund?