Helps the function 'Running background PL/SQL'

Hello everyone.

I come here for assistance with the service running background PL/SQL within the APEX. Here's a background of what I have to do.

Background:

Currently, I have just a page with a button above and some display boxes. The button calls a process flow Oracle Warehouse Builder (OWB) named RUN_ADJ_VAR and does what he must do. That works fine if my button simply calls the PL/SQL code of

BEGIN

ETQUEW. RUN_ADJ_VAR;

END;

Now that I know that the process flow and the button are working fine, I need to make the page "intelligently" by limiting multiple submissions until the process ends.

What I need:

I need assistance with running background PL/SQL function. My work has been running for a while and I need to run in the background and provide a status of the user, while restricting another presentation by the user. From what I've read here:

Advanced programming techniques

According to me, that this DBMS wrapper function, it's what I use.

What I have so far:

Using the API and example, I made my own attempt at this and it does not work. Here's what I have so far:

[code]

DECLARE

v_sql VARCHAR2 (32767).

BEGIN

v_sql: = '

BEGIN

ETQUEW. RUN_ADJ_VAR;

APEX_PLSQL_JOB. () UPDATE_JOB_STATUS

P_JOB = >: APP_JOB,.

P_STATUS = > "done");

END IF;

END;

';

: P1_JOB: = APEX_PLSQL_JOB. () SUBMIT_PROCESS

p_sql = > v_sql,

p_when = > sysdate,.

p_status = > 'Submit');

: P1_POST_DONE: = 'Y ';

END;

[/ code]

What the code so far:

The code seems to ignore the first part and does work through the underlined only section. The work never appears to run and the button can be clicked several times.

Other Options:

I don't know if the function from PL/SQL background running is the only way to do that. The work is performed for about 15 minutes so I can't use a javascript script wait indicator since that will expire because of the hours of work. I searched all over the internet and forums and I feel I have exhausted all my options. I am very new to the APEX and PL/SQL in general, so your help is very appreciated.

Thank you!!!

Hello Konrad B.!

Try to rewrite the code as shown below:

DECLARE

v_sql VARCHAR2 (32767).

BEGIN

v_sql: = '

BEGIN

ETQUEW. RUN_ADJ_VAR;

END;

';

: P1_JOB: = apex_plsql_job.submit_process (v_sql);

END;

Assume that P1_JOB - question on the page. After submitting the job, this point will be containing number of jobs. The job number,
username (can get APP_USER) and workspace id (can get WORKSPACE_ID) you can check the status
view of working level (field SYSTEM_STATUS) APEX_PLSQL_JOBS:

SELECT SYSTEM_STATUS
FROM APEX_PLSQL_JOBS
WHERE JOB = :P1_JOB
AND ANDUSER = :APP_USER
AND SECURITY_GROUP_ID = :WORKSPACE_ID

So you can make conditional button, selected example condition "NOT Exists (SQL query returns no rows)" and in the expression type:

Select 1 from apex_plsql_jobs

where employment =: P1_JOB

and end user =: APP_USER

and security_group_id =: WORKSPACE_ID

and system_status in ("in PROGRESS", "SUBMITTED")

If you must run the job for the user, then button will not be returned.

Tags: Database

Similar Questions

  • Find the function object DB with SQL Developer

    Hello to all, SQL developer 4.0.0.13 on Windows 7 64 bit version. I just started to use the function of object find DB. I type the name of the object in the worksheet, select the name of the object and press ALT + g pane, tab, palette, dialogbox binocular opens and shows me all the objects (and schema name) which are referred to as the selected text in the worksheet. When you click on the name of the object, the object opens twice in the object browser. Maybe I understood something wrong. I tried clicking on it once and twice, twice, I see two viewers object showing the same object. Also the pane, tab, palette, dialogbox binocular remains open after that. Is there a way I can hide/close this as soon as I click on the object. Thank you for your help in advance.

    the search panel will remain open until you hide/close it

    I'm not able to reproduce the problem of double-open - what type of object happens to, or she to what whether you click on?

    In addition, you are on an older version, you can upgrade to 4.0.2 because it could have been corrected in a 2 patch releases as your version debuted.

  • Helps the function of class of SMTP with authentication

    My server no longer supports the php mail() feature.  I need to use the SMTP class with the authentication function in my php code, and they suggested this to replace it: on-with-authentication-in-php-code http://www.yrhostsupport.com/index.php?/Knowledgebase/Article/View/101/2/smtp-class-functi

    So, I tried, but cannot make it work. This is my test form:

    < are method = "post" action = "forms/sendmail - test2.php" onsubmit = "return checkEmail (this);" >

    < script type = "text/javascript" language = "JavaScript" >

    < /script >

    < fieldset > < legend > news < / legend >

    < Label > name < / label >

    < input type = "text".

    name = "name" size = "30" maxlength = "40" / > < br / >

    < label > < span class = 'redText' > * </span > Email < / label >

    < input name = "email" type = "text" size = "30" maxlength = "40" / >

    < br / >

    < label > < span class = 'redText' > * </span > Message < / label >

    < textarea cols = "40" rows = "5" name = "message" type = "text" / > < / textarea > < br / >

    < / fieldset >

    < input type = "reset" value = "Reset" / >

    < input type = value = "submit" / >

    < / fieldset >

    < / make >

    It's sendmail - test2.php where going to the form. It will not be sent unless I have comment on the first 10 lines.

    <? PHP

    include ('Mail.php');

    //$to = " [email protected] "; "

    $name = $_REQUEST ['name'];

    $email = $_REQUEST ['email'];

    $message = $_REQUEST ['name'];

    $headers = "from: $email";

    $subject = "price quote";

    $fields = array();

    $fields {'name'} = 'Name ';

    $fields {'email'} = 'Email ';

    $fields {'message'} = 'Message ';

    $recipients = ' [email protected] '; //CHANGE

    $headers ['from'] = ' [email protected] '; //CHANGE

    ["to"] = $headers ' [email protected] '; //CHANGE

    $headers ['subject'] = 'Test Message';

    $body = "test message";

    Set the SMTP settings

    $params ['host'] = "levy.dnsbox25.com";

    $params ['port'] = '25';

    $params ["auth"] = "PLAIN";

    $params ["username"] = ' [email protected] '; //CHANGE

    $params ["password"] = "xxxxxx"; CHANGE

    / Next option allows the SMTP debug and will print the SMTP Protocol

    conversation on the page, it will help only with authentication problems. */

    $params ['debug'] = 'true ';

    Create the mail object using the Mail::factory method

    $mail_object = & Mail::factory ('smtp', $params);

    Print the parameters you use for the page

    {foreach ($params as $p)

    echo "$p < br / > ';

    }

    Send the message

    $mail_object-> send ($recipients, $headers, $body);

    ? >

    It used to work well when I used

    $send = mail ($ $subject, $body, $headers);

    $send2 = mail ($from, $subject2, $autoreply, $headers2);

    But they said I can't use it anymore. I'm good with HTML and CSS, but I don't know much about php. Thanks for any help integrating one of in this new code!

    It is to be expected. When you assign a value to a variable that was already assigned, you replace the previous value. You must add. Try this

    $body = "name:". "." $name. "\r\n". "e-mail:". "."  $email. "\r\n". $message

  • MAXL: Error when you use the runtimesubvar variable in the function 'run the calculation '.

    Hello everyone,

    I am trying to use a variable ($MyScenario) as a runtimesubvar for a calculation script.

    This excerpt from my script works perfectly (without variables):

    run the calculation "MyApp". "MyPlantype'. '" MyCalcscript' with runtimesubvars ' MyRTSV = 'Budget '. ' ;

    The following with variable does not work:

    The value MyScenario = "Budget";

    echo $MyScenario;

    run the calculationn 'MyApp'.' MyPlantype'. 'MyCalcscript' with runtimesubvars ' MyRTSV = $MyScenario; ' ;


    It is the output:

    Budget (<-$MyScenario echo works!)

    MAXL > run the calculation 'MyApp'.' MyPlantype'. 'MyCalcscript' with runtimesubvars 'MyRTSV = $MyScenario;';

    ERROR - 1012150 - environment variable [MyScenario] does not exist...

    I also tried putting $MyScenario between quotation marks simple '$MyScenario', which seems to work better but leading to a different error:

    Budget

    MAXL > run the calculation 'MyApp'.' MyPlantype'. 'MyCalcscript' with runtimesubvars ' MyRTSV = 'Budget';

    ERROR - syntax error 1242021-1 ['Budget'].

    What Miss me?

    Thanks in advance,

    Fadel

    Have you tried to use double quotes around the entire string of RTSV? Apostrophes are cutting the expansion of variables in MaxL. I think the idea is at the exit of the second snippet - $MyScenario is passed through the intact calculation and then script (MIS-) interpreted as an environment variable.

  • Value returned by the function

    SQL * more: Release 10.2.0.1.0 - Production on Sun 17 may at 11:41:10 2009

    Copyright (c) 1982, 2005, Oracle. All rights reserved.


    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64 bit Production
    With partitioning, OLAP and Data Mining options

    SQL > create table testdata
    () 2
    facid number 3.
    4 data varchar2 (10));

    Table created.

    SQL > insert into testdata (facid, data) values ('10 ', 'Data');

    1 line of creation.

    SQL > insert into testdata (facid, data) values ('20', 'Qdata');

    1 line of creation.

    SQL > select * from testdata;

    FACID DATA
    ---------- ----------
    10 data
    20 Qdata


    SQL > create or replace function testdata_fn (v_facid number)
    2 back tank
    3 is
    4
    number of tempid 5;
    6
    7. start
    8
    9. Select facid in tempid testdata where facid = v_facid;
    10
    11. IF tempid is null then
    12 DBMS_OUTPUT. PUT_LINE ('TEMPID' | tempid);
    13 back 'n';
    14 on the other
    15 return "Y";
    16 end if;
    17
    18 end testdata_fn;
    19.

    The function is created.



    SQL > select distinct testdata_fn (10) of testdata.

    TESTDATA_FN (10)
    --------------------------------------------------------------------------------
    THERE

    SQL > SELECT distinct testdata_fn (38) FROM testdata;

    TESTDATA_FN (38)
    --------------------------------------------------------------------------------


    SQL >


    I was expecting a "n" If there is no corresponding data.

    Is this possible in a single query? I will join this query for an existing query.

    Please give your comments.

    you need an exception for this handler:

     ....
     exception when no_data_found then
      return 'N'
     end testdata_fn;
    
  • How do I inject inside the ODI 11 G PL/SQL (not function procedure)

    Hello Expert,

    would be like double until OWB and ODI OWB 11 G I wich 'The user function' run PL/SQL and it remove some data in the table and the reel journal, is possible that I can do the same thing in ODI, in my case, I can't call function, or a procedure stored outside the ODI. See below the part of the PL/SQL based on user OWB.

    coil MyFile... Journal

    command prompt

    create table MyTable as

    Select a.*

    Of...

    commit;

    command prompt

    spool off;

    "exit";

    Thank you!

    You can run a PL within a procedure, you simply copy paste your PL and place in a procedure inside the ODI.

    I hope this can help you!

  • Functions running in the reports.

    Hello. I have a report that runs a function within a function. For example, GET_EQUIPT_COUNT_FINAL_2010 is called in a report. In GET_EQUIPT_COUNT_FINAL_2010, another function (* GET_EQUIPT_COUNT_2010_X *) which returns a true no is executed. When GET_EQUIPT_COUNT_2010_X is run separately in SQL plus, the exit returns a specific real don't. say - 3. GET_EQUIPT_COUNT_FINAL_2010 is executed within a report and returns a value of say 5. If I place an equation in GET_EQUIPT_COUNT_FINAL_2010 as return value of GET_EQUIPT_COUNT_FINAL_2010 must be the original return value (5) over the return value of GET_EQUIPT_COUNT_2010_X (-3), which should give me a value of + 2. The resulting out put is + 5. It does not seem to recognize the value of GET_EQUIPT_COUNT_2010_X. Why is it so? I hope you get this. It's a little hard to explain. Thanks for the help. Here is my function below:

    CREATE OR REPLACE FUNCTION SPM_IS.*GET_EQUIPT_COUNT_FINAL_2010* (V_CUTOFF_FROM IN VARCHAR2, V_CUTOFF_TO IN VARCHAR2, P_GRID IN VARCHAR2, P_REGION IN VARCHAR2, P_ACC IN VARCHAR2, P_DISTRICT IN VARCHAR2, P_BRANCH IN VARCHAR2, P_CLASSIFICATION IN VARCHAR2, P_VOLTLEVEL IN VARCHAR2, P_EQUIPMENT IN VARCHAR2) RETURN NUMBER IS PRAGMA AUTONOMOUS_TRANSACTION;

    NUMBER OF V_COUNT: = 0;
    V_TOTAL_COUNT NUMBER: = 0;
    V_CUTOFF VARCHAR2 (11);
    NUMBER OF V_LOOP_DAY;
    REAL V_FUNCTION;

    BEGIN

    V_CUTOFF: = V_CUTOFF_FROM;

    V_LOOP_DAY: = TO_DATE (V_CUTOFF_TO, ' DD/MONTH/YYYY') - TO_DATE(V_CUTOFF_FROM, 'DD/MON/YYYY') + 1;

    FOR V_LOOP IN 1.V_LOOP_DAY

    LOOP

    GET_EQUIPMENT_COUNT_A* (V_CUTOFF_FROM, V_CUTOFF_TO, P_GRID, P_REGION, P_ACC, P_DISTRICT, P_BRANCH, P_CLASSIFICATION, P_VOLTLEVEL);

    SELECT COUNT (1)
    IN V_COUNT
    Of
    (SELECT A.trans_code, A.transformer, A.DATE_COMMISSION, A.DATE_DECOMMISSION, A.CLASSIFICATION,
    SUBSTR (S.SUBSTATION_CODE, 1, 1) GRID, SUBSTR (S.SUBSTATION_CODE, 2, 4) REGION.
    SUBSTR (S.SUBSTATION_CODE, 6.4) DISTRICT, S.ACC_CODE, S.BRANCH_CODE
    FROM (SELECT *)
    OF SPM_COUNT_TEMP_TRANS_A
    ), SPM_SUBSTATIONS S
    WHERE A.SUBSTATION_CODE = S.SUBSTATION_CODE
    )
    ;

    V_TOTAL_COUNT: = V_TOTAL_COUNT + V_COUNT;

    V_CUTOFF: = TO_CHAR (TO_DATE (V_CUTOFF, ' DD/MONTH/YYYY') + 1, "MON/DD/YYYY");

    DELETE FROM SPM_COUNT_TEMP_TRANS_A;

    END LOOP;

    COMMIT;

    V_TOTAL_COUNT: = V_TOTAL_COUNT + GET_EQUIPT_COUNT_2010_X* (V_CUTOFF_FROM, V_CUTOFF_TO, P_GRID, P_REGION, P_ACC, P_DISTRICT, P_BRANCH, P_CLASSIFICATION, P_VOLTLEVEL, P_EQUIPMENT);

    RETURN (NVL(V_TOTAL_COUNT,0));

    END GET_EQUIPT_COUNT_FINAL_2010; *

    Published by: 829713 on January 19, 2011 23:34

    Thanks Inol. I saw the problem already. Thanks for the tip on the dbms_output.putline. The function worked fine, the problem is that the result of the V_COUNT is the total number of equipment for the duration. What I wanted was to subtract the 'everyday' number of the material. So what happened was even if 2 has been subtracted from V_COUNT, whose value is 465, the resulting value divided by 31 days is also 15 during the flare, is why it shows an incorrect value. What I wanted was 13. I hope you get my point. Thank you much for the help. Until the next time.

  • To call the function in sql and script call

    Hello

    I'll have a .sql script that returns the name of the partition and I need to run alter table Exchange partition something like this

    get_part. SQL

    COLUMN file_name new_value by sub_script_col

    accept the start_date char prompt arguments ' input start (exact): '

    accept the end_date char prompt "enter end date (exact): '"

    create or replace function get_part_name (p_date in date)

    VARCHAR2 is back

    date d;

    RETP varchar2 (30);

    spirit date: = to_date('4444-01-01','yyyy-mm-dd');

    Str varchar2 (32000);

    cursor c is

    Select high_value, nom_partition p

    of all_tab_partitions

    where table_name = 'TO_TEHBLNC ';

    Start

    for r in c loop

    Str: = r.high_value;

    run immediately 'select'. Str |' double ' in d;

    If p_date < d and d, then the spirit

    RETP: = r.p;

    spirit: = d;

    end if;

    end loop;

    return pter;

    end;

    Select get_part_name ('& 1') twice;

    ACCEPT user_yn PROMPT ' do you want to partion with < partition name > table? (Y, N) : "

    SELECT THE CHECK BOX

    WHEN TOP (LTRIM (' & user_yn')) AS 'y %. "

    THEN "insert_partition".

    ELSE 'do_nothing.

    END AS sub_script_col

    DOUBLE;

    @ &sub_script_col < partition_name >

    sub_script_col. SQL

    ALTER TABLE to_tehblnc

    SWAP PARTITION < name patition >

    WITH TABLE T1

    WITHOUT VALIDATION

    UPDATE GLOBAL INDEXES;

    I need to call once again for the sub_script.sql based on start_date and end_date, for example 1st January 2015 and January 5, 2015 I must first get the parition name and proceed to modify the table with that respective partition name returned by the function, so that it will be 5 times alter the table to swap partition

    I'll have a .sql script that returns the name of the partition and I need to run alter table Exchange partition

    This is just a continuation of your other thread

    For the name of the partition in the partition range table

    As I said it you do not have to know the name of the partition to make an EXCHANGE. I gave you an example in this other thread.

    ACCEPT user_yn PROMPT ' do you want the table to partition with ? (Y, N) : "

    That makes no sense at all. You cannot partition a table that is already partitioned. If there is a name for the partition and then the table is partitioned already - then ask why to partition?

    ALTER TABLE to_tehblnc

    SWAP PARTITION

    WITH TABLE T1

    WITHOUT VALIDATION

    UPDATE GLOBAL INDEXES;

    I need to call once again for the sub_script.sql based on start_date and end_date, for example 1st January 2015 and January 5, 2015 I must first get the parition name and proceed to modify the table with that respective partition name returned by the function, so that it will be 5 times alter the table to swap partition

    No - you don't have. Just use the code example I provided in your other thread. You don't need to know the name of the partition and use dynamic sql statements to make the Exchange.

    Just use PARTITION syntax as shown in the example.

    Do things the EASY way. Your code and the script is totally useless.

  • Grant permission to select the function but not executed in a PL/SQL block

    Hello.

    I know that there are only two permissions on procedures/functions - RUN and DEBUG.

    But I want to grant EXECUTE permissions for a user so that the user can Select the function to double or to any other request, but not to run(to prevent the user to trigger the update of LMD - insertion, etc.) inside a BEGIN-END block.

    I know that we can revoke access to tables etc. But that access has to give. The user must be able to perform the DML operation, but just not through a function.

    Can someone please help?

    I know that there are only two permissions on procedures/functions - RUN and DEBUG.

    Fix - so give one or both of those who depend on your use case.

    
    But I want to grant the EXECUTE permission to a user in such a way that the user can select the function using dual or any other query but not execute( to prevent the user from firing DMLs - Insert, update etc) inside any BEGIN-END block.
     
    

    You already know that there is NO "select" privileges for functions. a query such as "select the function of double" RUNS the function. That's all what you can do with the functions is execute them.

    I know that we can revoke access to tables etc. But that access has to be given. The user should be able to do perform DML operation, but just not through a function.
    

    Then revoke execute on the service. Then the user cannot run the service either directly or in the context of a dml statement.

  • How to identify columns that have the same data in a SQL query or function?

    Deal all,

    How to identify columns that have the same data in a SQL query or function? I have the sample data as below

    DEPT_IDEMP_IDCome on
    !CITYSTATECOUNTRY111 June 1983DELHIHUMAN RESOURCESIndia1218 January 1987DELHIHUMAN RESOURCESIndia1328 November 1985DELHIHUMAN RESOURCESIndia144 June 1985DELHIHUMAN RESOURCESIndia255 June 1983MUMBAIHDIndia266 June 1983MUMBAIHDIndia277 June 1983MUMBAIHDIndia288 Jun. 1983MUMBAIHDIndia399. June 1983GURGAONDLIndia31010 June 1983GURGAONDLIndia

    Now, I want to Indify columns that have the same data for the same Department ID.

    Is it possible in sql unique or do I have to write the function for this? Pls Help how to write?

    Thanks in advance.

    You can try this?

    WITH T1)

    DEPT_ID, EMP_ID, DATE OF BIRTH, CITY, STATE, COUNTRY

    ), ()

    SELECT 1, 1, TO_DATE('1.) June 1983', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 1, 2, TO_DATE('18.) January 1987', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 1, 3, TO_DATE('28.) November 1985', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 1, 4, TO_DATE('4.) June 1985', 'JJ. LUN. (YYYY'), 'DELHI', 'HR', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.5, TO_DATE('5.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.6, TO_DATE('6.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.7, TO_DATE('7.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 2.8, TO_DATE('8.) June 1983', 'JJ. LUN. (YYYY'), 'BOMBAY', 'HD', 'INDIA' OF THE DUAL UNION ALL

    SELECT 3, 9, TO_DATE('9.) June 1983', 'JJ. LUN. (YYYY'), 'GURGAON', 'DL', 'INDIA' OF THE DUAL UNION ALL

    SELECT 3.10, TO_DATE('10.) June 1983', 'JJ. LUN. (YYYY'), 'GURGAON', 'DL', 'INDIA' OF THE DOUBLE)

    SELECT DEPT_ID,

    RTRIM (XMLAGG (XMLELEMENT(A,VALS||',')). Extract ('//Text ()'), ',') COLUMNS_WITH_DUPLICATE

    DE)

    SELECT * FROM)

    SELECT DEPT_ID,

    EMP_ID,

    Date of birth

    CITY,

    STATE,

    COUNTRY

    DE)

    SELECT DEPT_ID,

    EMP_ID,

    Date of birth

    CITY,

    STATE,

    COUNTRIES,

    COUNT (*) OVER(PARTITION BY DEPT_ID ORDER BY EMP_ID DESC,DOB DESC,CITY DESC,STATE DESC, COUNTRY DESC) RN

    DE)

    SELECT DEPT_ID,

    CASE WHEN(CEID>1) AND THEN 'YES' ELSE 'NO' END AS EMP_ID.

    CASE WHEN(CDOB>1) THEN 'YES' ELSE 'NO' END AS DATE OF BIRTH,

    CASE WHEN(CCITY>1) AND THEN 'YES' ELSE 'NO' END AS CITY.

    CASE WHEN(CSTATE>1) AND THEN 'YES' ELSE 'NO' END AS STATE.

    CASE WHEN(CCOUNTRY>1) THEN 'YES' ELSE 'NO' END AS A COUNTRY

    DE)

    SELECT DISTINCT

    DEPT_ID,

    CEID,

    CDOB,

    CITY,

    CSTATE,

    CCOUNTRY

    DE)

    SELECT DEPT_ID,

    COUNT (*) TO THE CEID (DEPT_ID PARTITION, EMP_ID),.

    COUNT (*) ON CDOB (DEPT_ID SCORE, DATE OF BIRTH),

    COUNT (*) ON THE CITY (DEPT_ID PARTITION, CITY),

    COUNT (*) ON CSTATE (DEPT_ID PARTITION, STATE).

    COUNT (*) ON CCOUNTRY (DEPT_ID, COUNTRY PARTITION)

    FROM T1)))

    WHERE RN = 1)

    UNPIVOT (CLO FOR (VALS) IN (EMP_ID, DATE OF BIRTH, CITY, STATE, COUNTRY)))

    WHERE COLS = "YES".

    DEPT_ID GROUP;

    OUTPUT:

    DEPT_ID COLUMNS_WITH_DUPLICATE
    --------- ------------------------

    1 CITY, COUNTRY, STATE
    2 CITY, COUNTRY, STATE
    3 CITY, COUNTRY, STATE

    Post edited by: Parth272025

  • Problem with the process running sql

    I created a pricess that deletes a file off of the table apex_application_files

    When I run the following statement:
    delete apex_application_files whose name like "resume.pdf" it works without problem

    When I run the following statement:
    delete apex_application_files whose name like ': P4_PDF_DISPLAY' he does not. what I have to do.

    I changed the: p4_pdf_display to be a single item displayed on the page
    With the help of the P4_PDF_DISPLAY can view the file in a query sql and beable to view the file to download, but am unable to delete
    Help!

    Hello
    >
    I created a pricess that deletes a file off of the table apex_application_files

    When I run the following statement:
    delete apex_application_files whose name like "resume.pdf" it works without problem

    When I run the following statement:
    delete apex_application_files whose name like ': P4_PDF_DISPLAY' he does not. what I have to do.

    I changed the: p4_pdf_display to be a single item displayed on the page
    With the help of the P4_PDF_DISPLAY can view the file in a query sql and beable to view the file to download, but am unable to delete
    >

    What is this point of P4_PDF_DISPLAY? It is the name of the file, as it is supposed to be in your delete statement? Or, view the article PDF?
    Verify session state to display the value of the element. You see the name in it?

    See you soon,.

  • How to "end" to the function definition in SQL like?

    I'm using Oracle 11 g and SQL Plus.

    I'm trying to define a function and return to the SQL command prompt, but it is simply not to leave the function definition.

    SQL > create function dept_count (dept_name varchar (20))
    2 returns whole
    3. start
    4 declare entire d_count;
    5. select count (*) in d_count
    6 the instructor
    7 where instructor.dept_name = dept_name
    8 return d_count;
    9 end
    10;
    11
    12
    13
    14
    15
    16.
    end 17 dept_count;
    18;
    19
    20; <-I expect the SQL > invite here, but it is not.

    What should I do? Help, please. Thank you.

    Try this please

    .
    .
    .
    SQL> end ;
    SQL> /
    
  • catch the collection returned by the function in a SQL statement

    I have a select like query: (I need all the values returned by the function in the select list)

    Select t1.col1, t2.col2, (by selecting t.a, t.b., t.c in fn (t2.col3) t)
    Of
    T1, t2
    where t1.col1 = t2.col2;



    My function is like:

    FN (T2.col3) returns an array in format of the object



    Here, I was able to select only one value from the table returned by the funcation both. If I select all of the values as above, she gave too much error vales.
    Please someone help me in this

    user13044793 wrote:
    I have a select like query: (I need all the values returned by the function in the select list)

    Select t1.col1, t2.col2, (by selecting t.a, t.b., t.c in fn (t2.col3) t)
    Of
    T1, t2
    where t1.col1 = t2.col2;

    No specific reason for this? It adds additional complexity to the projection of SQL, and there are additional costs of failover for the motor of PL/SQL (per line) of context. Overall - not your typical approach and one that should have sound justification.

    With regard to the basic method - the SQL multiset() function should be used to create a collection. Here is an example of the approach:

    SQL> create or replace type TFoo as object(
      2          id      number,
      3          bar     varchar2(5)
      4  );
      5  /
    
    Type created.
    
    SQL>
    SQL> create or replace type TFooSet as table of TFoo;
      2  /
    
    Type created.
    
    SQL>
    SQL> create or replace function GetSomeFoo( n number ) return TFooSet is
      2          foo     TFooSet;
      3  begin
      4          foo := new TFooSet();
      5          foo.Extend( 5 );
      6
      7          for i in 1..5
      8          loop
      9                  foo(i) := new TFoo( n+i-1, to_char(i-1,'0000') );
     10          end loop;
     11
     12          return( foo );
     13  end;
     14  /
    
    Function created.
    
    SQL>
    SQL> select
      2          object_id,
      3          object_name,
      4          cast(
      5                  multiset( select * from table(GetSomeFoo(object_id)) ) as TFooSet
      6          )       as FOO
      7  from       all_objects
      8  where      owner = 'SYS'
      9  and        rownum <= 5;
    
     OBJECT_ID OBJECT_NAME                    FOO(ID, BAR)
    ---------- ------------------------------ --------------------------------------------------
         27538 /1000e8d1_LinkedHashMapValueIt TFOOSET(TFOO(27538, ' 0000'), TFOO(27539, ' 0001')
                                              , TFOO(27540, ' 0002'), TFOO(27541, ' 0003'), TFOO
                                              (27542, ' 0004'))
    
         28544 /1005bd30_LnkdConstant         TFOOSET(TFOO(28544, ' 0000'), TFOO(28545, ' 0001')
                                              , TFOO(28546, ' 0002'), TFOO(28547, ' 0003'), TFOO
                                              (28548, ' 0004'))
    
         11718 /10076b23_OraCustomDatumClosur TFOOSET(TFOO(11718, ' 0000'), TFOO(11719, ' 0001')
                                              , TFOO(11720, ' 0002'), TFOO(11721, ' 0003'), TFOO
                                              (11722, ' 0004'))
    
         30094 /100c1606_StandardMidiFileRead TFOOSET(TFOO(30094, ' 0000'), TFOO(30095, ' 0001')
                                              , TFOO(30096, ' 0002'), TFOO(30097, ' 0003'), TFOO
                                              (30098, ' 0004'))
    
        684122 /1023e902_OraCharsetUTFE       TFOOSET(TFOO(684122, ' 0000'), TFOO(684123, ' 0001
                                              '), TFOO(684124, ' 0002'), TFOO(684125, ' 0003'),
                                              TFOO(684126, ' 0004'))
    
    SQL>
    SQL> with dataset as(
      2          select
      3                  object_id,
      4                  object_name,
      5                  cast(
      6                          multiset( select * from table(GetSomeFoo(object_id)) ) as TFooSet
      7                  )                as FOO
      8          from    all_objects
      9          where   owner = 'SYS'
     10          and     rownum <= 5
     11  )
     12  select
     13          d.object_id,
     14          d.object_name,
     15          f.id,
     16          f.bar
     17  from   dataset d,
     18          table(d.foo) f
     19  /
    
     OBJECT_ID OBJECT_NAME                            ID BAR
    ---------- ------------------------------ ---------- ---------------
           217 DUAL                                  217  0000
           217 DUAL                                  218  0001
           217 DUAL                                  219  0002
           217 DUAL                                  220  0003
           217 DUAL                                  221  0004
           268 SYSTEM_PRIVILEGE_MAP                  268  0000
           268 SYSTEM_PRIVILEGE_MAP                  269  0001
           268 SYSTEM_PRIVILEGE_MAP                  270  0002
           268 SYSTEM_PRIVILEGE_MAP                  271  0003
           268 SYSTEM_PRIVILEGE_MAP                  272  0004
           271 TABLE_PRIVILEGE_MAP                   271  0000
           271 TABLE_PRIVILEGE_MAP                   272  0001
           271 TABLE_PRIVILEGE_MAP                   273  0002
           271 TABLE_PRIVILEGE_MAP                   274  0003
           271 TABLE_PRIVILEGE_MAP                   275  0004
           274 STMT_AUDIT_OPTION_MAP                 274  0000
           274 STMT_AUDIT_OPTION_MAP                 275  0001
           274 STMT_AUDIT_OPTION_MAP                 276  0002
           274 STMT_AUDIT_OPTION_MAP                 277  0003
           274 STMT_AUDIT_OPTION_MAP                 278  0004
           815 RE$NV_LIST                            815  0000
           815 RE$NV_LIST                            816  0001
           815 RE$NV_LIST                            817  0002
           815 RE$NV_LIST                            818  0003
           815 RE$NV_LIST                            819  0004
    
    25 rows selected.
    
    SQL>
    
  • Helps the REST FUNCTION

    Hi all

    I am preparing the review of the basic course 1 SQL.
    I'm confused about function REST.
    I use Sybex (11g) for my studies.

    Now the REST is set as follows:
    REST (x, y): the function returns the rest if it divides X.

    Now the following queries have been used.

    Select the stay (13.5), stay (12.5), Remainder (12.5,5) twice;
    This gave-2, 2 and 2.5 respectively.
    My confusion is how remains (12.5) will return - 2 instead of 3.
    I ran the query using sql and still have-2, please someone must help very urgent
    as I don't understand why it must be so.


    Thank you



    Harrison

    Hello

    If you look in the documentation Oracle the function else is

    rest (m, n)

    The rest is calculated as:

    m (n * X) where X is the closest whole number of m / n

    http://www.techonthenet.com/Oracle/functions/remainder.php
    Thank you

  • Any difference between the separate function and aggregation in sql query cost?

    Hello
    I've run many models sql stmts - such as:
    one) using a single table
    (b) using the two tables, using simple joins or outer joins

    but I didn't notice a difference in sql stmts in cost and implementation plan...
    In any case, my colleague insists on only using the aggregate function is less expensive compared to
    separate... (something I've not confirmed, that is why I believe that they are exactly the same...)

    For the situation described above under 1 sql... We could for example use
    select distinct deptno
    from emp
    select count(*), deptno
    from emp
    group by deptno
    select distinct owner, object_type from all_objects
    select count(*), owner, object_type from all_objects
    group by owner, object_type
    Have you ever found no difference between the two...?

    Note: I use Ora DB 10g v2.

    Thank you
    SIM

    Alexandre Gelin says:
    function separate and aggregation are for different uses and can give the same result, but if you use the aggregate function to get the separate records, it will be expensive...

    really? I find them almost identical to 11g. Actually GROUP BY is almost always more fast for me in the old days.

    article about this askTom Re: any difference between the separate function and aggregation in sql query cost?
    This applies mainly to the older oracle versions http://www.oracle.com/technology/products/rdb/pdf/distinct_derivedtables_groupby_sort_tech_article.pdf

Maybe you are looking for