Select Into statement in the function db - query issued schema table

problem with "select into" in the function db to point 10.2


There are two schemas. "mdbdev" is the master database, and 'devusr' is granted SELECT access table to run queries in the mdbdev schema.


with devusr, in SQL, I am able to run the following query

Select wm_concat (strConcatedCountryList)
from (select country_name as mdbdev.country_master mdbcm strConcatedCountryList
where mdbcm.country_ship_status = < param? >
order of country_name)



but when I use the same procedure/function with 'select into' motion, failed to compile with error * "table or view does not exist."


FUNCTION GETCOUNTRYLISTTOSHIP (SHIP_STATUS NUMBER)
RETURN VARCHAR2
IS
var2CountryList VARCHAR2 (1000);
BEGIN
Select wm_concat INTO var2CountryList (strConcatedCountryList)
from (select country_name as mdbdev.country_master mdbcm strConcatedCountryList
where mdbcm.country_ship_status = value < SHIP_STATUS >
order of country_name);
Return var2CountryList;
END;


Please advise/help/suggestion :)

You don't have to ask for the DBA, you can run a query to find out:

select *
from  all_tab_privs_recd
where owner = 'MDBDEV'
and table_name = 'COUNTRY_MASTER'

What give you?

Tags: Database

Similar Questions

  • Dynamic region of the body of the function return query did not work

    APEX 4.1

    Oracle 11g

    I have a report of dynamic fields according to the value of the different type of zone set element is body of pl/sql function, return query, see the source code of the region below.

    declare

    v_sql varchar2 (2000);

    Start

    IF: P2_BY = 'MONTH' THEN

    v_sql: = 'SELECT ' | : P2_TYPE | ', SUM (JAN) JAN, SUM (FEB) FEB, SUM (MAR) MAR, SUM (APR) APR, SUM (MAY) MAY, SUM (JUN) JUN, SUM (JUL) JUL, SUM (AUG) AUG, SUM (SEP) SEP, SUM (OCT) OCT, SUM (NOV) NOV, SUM (DEC) DEC OF THE RPT_HOTEL GROUP BY ' | : P2_TYPE;

    ON THE OTHER

    v_sql: = 'SELECT ' | : P2_TYPE | ', SUM (Y2011) 2011, SUM (Y2012) Y2012, SUM (Y2013) Y2013, SUM (Y2014) 2014 RPT_HOTEL GROUP BY ' | : P2_TYPE;

    Return v_sql;

    end;

    But "Missing expression" error when Save source in the region.

    I checked the sql statement is valid in the sql command, and: P2_TYPE get the correct value.

    If the generic column name 'use' then get the correct report, but the column name is random.

    Please help solve.

    Thank you so mcuh

    Hi fac586,

    I couldn't thank you more. Of course, read you my code and found that the design of table is not reasonable. in fact I just design for the demonstration of the prototype, so do not consider architecture.

    I mean, it is that the problem has disappeared when I create a new page like this one, don't know how it happened. in any case what I need has been achieved, thank you very much for what you have done.

    Here I paste my code for reference, that someone might need.

    declare
    v_sql varchar2(2000);
    v_time varchar2(50);
    v_for varchar2(30);
    begin
    IF :P4_TIME='MONTH' THEN
    v_time := 'to_char(lodging_date,''MM'') MONTH';
    v_for := 'to_char(lodging_date,''MM'')';
    ELSE
    v_time := 'to_char(lodging_date,''YYYY'') YEAR';
    v_for := 'to_char(lodging_date,''YYYY'')';
    END IF;
    IF :P4_MEASURE='NIGHTS' THEN
    v_sql := 'SELECT * from (SELECT ' || :P4_BY || ',VENDOR_NAME,' || v_time
    || ',count(entry_legacy_key) ROOM_NIGHTS
    FROM HOTEL_EXPENSE GROUP BY ' || :P4_BY || ',VENDOR_NAME,' || v_for || ')
    PIVOT (SUM(ROOM_NIGHTS) FOR ';
    ELSE
    v_sql := 'SELECT * from (SELECT ' || :P4_BY || ',VENDOR_NAME,' || v_time
    || ',SUM(APPROVED_AMOUNT) SPENDING
    FROM HOTEL_EXPENSE GROUP BY ' || :P4_BY || ',VENDOR_NAME,' || v_for || ')
    PIVOT (SUM(SPENDING) FOR ';
    END IF;
    IF :P4_TIME='MONTH' THEN
    v_sql := v_sql || ' MONTH IN (''01'',''02'',''03'',''04'',''05'',''06'',''07'',''08'',''09'',''10'',''11'',''12''))';
    ELSE
    v_sql := v_sql || ' YEAR IN (''2011'',''2012'',''2013'',''2014''))';
    END IF;
    return v_sql;
    end;
    

    and checked

    'Use generic column names (analysis of query during execution only)'

    column of the report used PL/QL name

    declare
    v_sql varchar2(2000);
    begin
    v_sql :=  :P4_BY || ':VENDOR_NAME';
    IF :P4_TIME='MONTH' THEN
    v_sql := v_sql || ' :Jan:Feb:Mar:Apr:May:Jun:Jul:Aug:Sep:Oct:Nov:Dec';
    ELSE
    v_sql := v_sql || ':2011:2012:2013:2014';
    END IF;
    return v_sql;
    end;
    
  • calling the function of query of VO from bnd variables as parameters

    Hi all

    I Package SQL pack1 with 2 functions (par1, par2) funct1 return funct2 (par1, par2) R2 return R1.

    I have VO, vo1 query

    Select pack1.funct1 (bind1, bind2) as attr1,

    (bind3, bind4) funct2 as attr2 value

    See criteria VC1, like af:query. application of vo1 results as table results

    When the search button is touched

    get the error

    java.sql.SQLException: parameter IN or OUT to missing index: 1.

    Is this way of the function call?

    Thank you

    -shiva

    This indicates that DB schema on which the application is connected at run time does not recognize the

    Pack1. "" funct2.

    To verify your actual DB plan (which application uses running - may differ from the design schema time!) to see if there is pack1.funct2

  • Selecting correct state in the drop-down list.

    Here is my delima. I have a form that gets repopulate when users come back to update their contact information. Name, address, etc. of the State. What I am having a problem with performs their State to be selected from a drop-down list. For example, if I'm from Ohio, so I want Ohio selected in the drop-down list. I don't want the user to have to select again the State if the information has not changed. Here's an example of how it is formatted.

    < select tabIndex = "5" name = "State" >
    < option value = "" selected = "selected" > < / option > "
    < option value = 'AL' > Alabama < / option >
    < option value = "AK" > Alaska < / option >
    < option value = "AZ" > Arizona < / option >
    < option value = "AR" > Arkansas < / option >
    < option value = "CA" > California < / option >
    < option value = "CO" > Colorado < / option >

    Of course, the two-letter abbreviation is written and retrieved from the database.
    Everyone works with this before?
    Any help/information is appreciated.
    Brian

    Here's how I made this...

    Top of the page put

    Then, when comes the time to put the list do that...

    I hope this helps.

  • TO THE FUNCTION SUM WHILE JOINING THREE TABLES

    Hello

    I meet three tables as below in my oracle 9i DB.
    create table ac 
    (account_no varchar2(10),
    bal number)
    
    
    create table c
    (cid number,
    aid number,
    cname varchar2(50)
    )
    
    create table mu
    (ms number,
    BILLING_ACC_NO varchar2(10),
    aid number,
    cid number)
    and I have examples of data like this
    insert into ac (account_no,bal ) values ('1234',3456);
    insert into ac (account_no,bal ) values ('98767',567);
    insert into ac (account_no,bal ) values ('6754',6789);
    insert into ac (account_no,bal ) values ('54678',9453);
    
    insert into c (cid,aid,cname ) values (231,5050,'asdf');
    insert into c (cid,aid,cname ) values (131,5150,'fghj');
    insert into c (cid,aid,cname ) values (221,5050,'rtyu');
    insert into c (cid,aid,cname ) values (931,5151,'asdf');
    
    
    insert into MU (cid,aid,BILLING_ACC_NO ,MS) values (231,5050,'1234',987654);
    insert into MU (cid,aid,BILLING_ACC_NO ,MS) values (231,5050,'98767',8987654);
    insert into MU (cid,aid,BILLING_ACC_NO ,MS) values (221,5050,'6754',3434343);
    insert into MU (cid,aid,BILLING_ACC_NO ,MS) values (221,5050,'54678',667799);
    insert into MU (cid,aid,BILLING_ACC_NO ,MS) values (131,5150,'546738',66779933);
    I need the output as below help = 5050 table c.

    >
    c.CID, c.cname, sum (ac.bal)
    231, asdf, (3456 + 567 = 4023)
    221, rtyu, (6789 + 9453 = 16242)
    >

    selected the cid, cname in table c and found the list BILLING_ACC_NO table mu for help 5050 and every cid after found the sum (bal) for all these account_no (BILLING_ACC_NO MU).

    CID 231 cname asdf is to have BILLING_ACC_NO listed as 1234, 98767 and for these account_no in the ac table ball are 3 456 567 so its sum is needed.

    hope I explained it clearly.

    pls help me to get there.

    SELECT c.cid,
    c.CNAME,
    RTrim (regexp_replace (xmlagg (xmlelement (e, ac.bal |)))) ','))
    . Extract ('//Text ()'),
    ',',
    '+'),
    '+') || '=' || Sum (AC.bal)
    C, mu, ac
    WHERE mu.cid = c.cid
    AND mu.aid = c.aid
    AND account_no = mu.billing_acc_no
    GROUP OF c.cid, c.cname;

  • conditional select into statement


    Hi people.

    I'm trying to implement a conditional block in a select statement. I browsed the forums and seen the suggestions with the DECODING and the recurrent insistence that IF/ELSE do not or cannot work within the PL/SQL, which is what it would be.

    I'm trying to connect a simple string value if the value of a column is null. The block WHEN either does not either or I'm doing it wrong, but I would take any suggestions that you that you better informed than me on this.

    Here is the block:

    ------------------

    SELECT c.CHCTRLID 'CC ID', c.STATUS3, b.VPTIMSTAMP,
    a.VP_DATE AS 'Submit Date', a.CRITI_EXP_DT AS 'Critical Date', c.REQ_TYPE, c.SUBJLETTER,

    c.PGCOUNT AS 'Total Page', c.EFFECT_PGCOUNT,
    c.PUBTYPE AS "Type of Publication", c.COMPLEXITYLEVEL,.
    c.PUBDATE, a.BRANCH, a.BRANCH_SEC, a.PRIORITY, c.WRITER, a.REQ_INFO_DESCRIPT, a.DEPT,

    ABS (Round ((pubDate-VPTIMSTAMP), 0)) AS 'level of SLA in days. "

    -WHEN PUBDATE IS NULL
    - then return "n/a" AS "secondary ALS."
    -WHILE OTHERS THEN
    -BACK Abs (Round (SYSDATE-VPTIMSTAMP), 0)) AS 'secondary ALS. "

    a.OPS_MAN_CHG, a.OPS_MAN_PPCHAP, a.STRATEGY_UPDATE, a.CRITICAL_EXP

    B INNER JOIN CHG_CTRL_USR one CHG_CTRL_ADM
    ON b.CHCTRLID = a.CHCTRLID
    C INNER JOIN ADM_SUPP_INDX ON b.CHCTRLID = c.CHCTRLID

    WHERE c.STATUS3! = 'Cancelled' AND a.VP_DATE > 4 April 11 '
    ORDER BY a.CHCTRLID

    ---------------------------

    I commented on the block ONCE because it wouldn't work, but basically, that's what I'm trying to accomplish.

    Thank you.

    Decode is possible, but the CASE is more readable.

    Try this as a column value

    CASE WHEN PUBDATE IS NULL
      then 'n/a'
        else to_char(Abs(Round(SYSDATE-VPTIMSTAMP),0)) )  end AS "Secondary SLA",
    

    second possibility to check NULL is use NVL or NVL2.

    The data type of these two results must match.

    NVL2

    as in

    nvl2(PUBDATE, to_char(Abs(Round(SYSDATE-VPTIMSTAMP))) , 'n/a')
    
  • How to select and default hightlight the first line in a programmatic Table(ADF Table created based on a SortableModel) ADF.

    Hi all


    We use JDeveloper Studio Edition Version 12.1.3.0.0 and deployed on GlassFish Server Open Source Edition 3.1.2.2 (build 5) and connect to the SQLServer database.


    We created a table ADF programming related to a SortableModel created programmatically to a bean.


    We need to select and highlight the first row in the table just after making it to retrieve data based on the first line.


    We tried the based on the following thread: How to call the bean support just after JSFF / page fragment loads? and a few other posts online, but it does not work very well.


    W has created a hidden text in the bottom of the JSF model as follows:


    < af:table varStatus = "rowStat" Summary = "table" value = "#{pageFlowScope.crudBean.dynamicTable.collectionModel} '"

    Rows = "#{pageFlowScope.crudBean.dynamicTable.collectionModel.RowCount} '"

    contentDelivery = 'immediate' var = 'row' rendered = 'true '.

    Binding = "#{backingBeanScope.crudBackingBean.tasksTable} '"

    selectionListener = "#{backingBeanScope.crudBackingBean.customListener} '"

    "rowSelection ="single"id ="t1"partialTriggers =": pt_gr2 "columnStretching =" column: clmn0 ">

    < af:forEach items = "#{pageFlowScope.crudBean.dynamicTable.columnNames}" var = 'name' varStatus 'vs' = > "

    < af:column sortable = "true" sortProperty rowHeader = "#{name}" = "no style" headerText = "#{pageFlowScope.crudBean.dynamicTable.columnLabel [name]}" "

    inlineStyle = "width: 100px;"  ID = "clmn$ {vs.index}" >

    < af:activeOutputText value = "#{row [name]}" id = "aot1" / >

    < / af:column >

    < / af:forEach >

    < / af:table >

    ....


    < af:outputText id = "hiddenOutputTextId" visible = "false" value = "#{backingBeanScope.crudBackingBean.afterPageLoad} '"

    Binding="#{backingBeanScope.crudBackingBean.hiddenOutputText}"/ >

    And we have added the code to the bean to support below:

    public String getAfterPageLoad() {}

    If (!.) {AdfFacesContext.getCurrentInstance () .isPostback ()}

    selectFirstRowInTasksTable();

    }

    Return afterPageLoad;

    }

    public void selectFirstRowInTasksTable() {}

    try {}

    RKS RowKeySet = new RowKeySetImpl();

    RowKeySet rksEmpty = new RowKeySetImpl();

    Model CollectionModel = tasksTable.getValue ((CollectionModel));

    ROWCOUNT int = model.getRowCount ();

    If (rowcount > 0) {}

    model.setRowIndex (0);

    Key of the object = model.getRowKey ();

    RKS. Add (Key);

    tasksTable.setSelectedRowKeys (rks);

    SelectionEvent selectEvent =

    new SelectionEvent (tasksTable.getSelectedRowKeys (), rks, tasksTable);

    selectEvent.queue ();

    customListener (selectEvent); / / to retrieve data

    AdfFacesContext.getCurrentInstance () .addPartialTarget (tasksTable);

    }

    } catch (Exception e) {}

    }

    }

    I think that () selectEvent.queue; should work even without calling the customerListener, but it is not working in all cases.

    What is the problem in my code?



    Have you tried to bind property of 'selectedRowKeys' to selection configuration / bean there?

    Something like:

    public RowKeySet getSelectedRKS() {
        if (rks == null) {
            // make first record as selected
            // create RowKeySet and assign it to rks variable(where rks is variable defined in bean with some scope higher than request scope)
        }
        return rks;
    }
    

    Dario

  • How to modify a statement "select into" how to use a cursor

    The following code fails with an exception too many lines. How can I modify statement Select Into the procedure to use a cursor?
    CREATE OR REPLACE PROCEDURE Track_Asset(
       business_date IN NUMBER DEFAULT NULL,
       missing_table_name  OUT VARCHAR2) 
    IS
       ln_business_date NUMBER;
        incorrectdateformat EXCEPTION;
    BEGIN
       IF business_date < 0 
       THEN
          RAISE incorrectdateformat;
       ELSE
          DECLARE
            ln_business_date NUMBER;
          BEGIN
             SELECT MAX(business_date) 
             INTO ln_business_date
             FROM sproof ;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
             dbms_output.put_line('NO MATCH FOUND'); 
            WHEN OTHERS THEN
            dbms_output.put_line('ORACLE ERROR :' || SQLERRM);        
          END;
          
          DECLARE
            missedfeedfnd EXCEPTION;
          BEGIN
             SELECT 'Missing Value : ' || table_name 
             INTO missing_table_name 
             FROM ( 
                SELECT UPPER(table_name) table_name 
                FROM filespec
                WHERE data_table_name IN ('TABLE1','TABLE2','TABLE3') 
                MINUS ( 
                SELECT DISTINCT UPPER(first_table_name) 
                FROM dpca
                WHERE business_date = ln_business_date 
                AND first_table_name IN ('TABLE1','TABLE2','TABLE3') 
                GROUP BY UPPER(first_table_name) UNION 
                SELECT UPPER(first_table_name) 
                FROM dpca
                WHERE business_dt_num = TO_NUMBER( SUBSTR('201111', 1, 6) || '01' )
                AND first_table_name = 'TABLE4' 
                GROUP BY UPPER(first_table_name) ));
                
                IF missing_table_name  IS NOT NULL THEN
                   dbms_output.put_line('Missing Value : '|| missing_table_name);
                   RAISE missedfeedfnd;
                ELSE
                  NULL;
                END IF;
          EXCEPTION
             WHEN TOO_MANY_ROWS THEN
       DBMS_OUTPUT.PUT_LINE (' SELECT INTO statement retrieved multiple rows');
              WHEN missedfeedfnd THEN 
              raise_application_error ( - 20003, 'Missed Feed');
          END;
        END IF;
          EXCEPTION
       WHEN incorrectdatevalue 
       THEN
          raise_application_error ( - 20001, 'Incorrect/Bad Date Entered');
    END;

    OK, try this - OUT param will be filled with the table names comma-separated list:

    PROCEDURE Track_Asset(
       business_date IN NUMBER DEFAULT NULL,
       missing_table_name  OUT VARCHAR2)
    ...
    ...
    
    cursor c_table_names is
    select datatablename
    from   ( select upper(datatablename) datatablename
             from   filespec
             where  data_table_name in ('TABLE1','TABLE2','TABLE3'                                 )
            MINUS
            ( select upper(first_table_name)
              from   dpca
              where  business_dt_num = [-- this date is retrieved by getting the MAX(business_date) from sproof table]
                     and fus_data_table_name in ('TABLE1','TABLE2','TABLE3'
                                                )
              group  by
                     upper(first_table_name)
             UNION
              select upper(first_table_name)
              from   dpca
              where  business_dt_num = to_number( substr('201111',1,6) || '01' )
                     and first_table_name = 'TABLE4'
              group  by
                     upper(first_table_name)
            ));
    
    ...
    ...
    begin
       ...
       for rec in c_table_names
       loop
           missing_table_name  := missing_table_name  || rec.datatablename ||',';
       end loop;
       missing_table_name  := rtim(missing_table_name , ',');
    ...
    ...
    end ;
    

    HTH

    Published by: user130038 on December 28, 2011 08:46

  • Want to Elimate 'SYS. ODCIVARCHAR2LIST"by the result of query

    Hello

    Oracle Version installed is 11.0.2r6. I have a dummy table with data as below:

    STID ADDRESS Type_de_fichier
    -------- ------------------ ----------------
    SALES of ABC 9927 has 0
    TRANSFER of XYZ 9927 b 0
    TRANSFER of ABC 9927 has 0
    TRANSFER of XYZ 9927 b 0

    I want that the output voltage:

    STID ADDRESS Type_de_fichier
    -------- ------------------ ----------------
    9927-0 ABC SALES, TRANSFER
    TRANSFER of XYZ 9927 b 0

    I used 2 methods to achieve the same result, but face some problems.

    Method 1:
    --------------
    SELECT STID, ADDRESS, LISTAGG (File_Type, ',') within THE GROUP (ORDER BY Type_de_fichier) AS file_type
    MODELING
    STID GROUP, ADDRESS;

    I got the output as:

    STID ADDRESS Type_de_fichier
    -------- ------------------ ----------------
    9927-0 ABC SALES, TRANSFER
    9927b 0 XYZ, TRANSFER

    Method 2:
    -------------
    SELECT STID,
    ADDRESS,
    CAST (COLLECT (SEPARATE File_Type) AS SYS. ODCIVARCHAR2LIST) AS File_Type
    FROM (SELECT STID, ADDRESS, MODEL Type_de_fichier)
    STID GROUP, ADDRESS;

    I got the output as:

    STID ADDRESS Type_de_fichier
    -------- ------------------ ----------------
    9927-0 ABC SYS. ODCIVARCHAR2LIST (SALES, TRANSFER)
    9927b 0 XYZ SYS. ODCIVARCHAR2LIST (TRANSFER)

    Same method 2 gave good result which I like, "SYS. ODCIVARCHAR2LIST"is coming as a prefix in the result. I tried to use the replace, but it does not work. I tried to use the "wm_concat" method, but it does not work.

    Can someone help me please to get there? I want a simple Select statement, not the functions/procedures etc.

    Thank you
    Stéphane.

    And what about:

    SELECT STID, ADDRESS, LISTAGG(File_Type, ',') WITHIN GROUP (ORDER BY File_Type) AS file_type
    FROM (
         SELECT DISTINCT STID, ADDRESS, File_Type
         FROM DUMMY
         )
    GROUP BY STID, ADDRESS;
    
  • SELECT INTO does not return no loop lines and stops

    I scoured the internet looking for an appropriate way to handle this, but have developed in white. I'm not a pro so please excuse me if I asked a basic question stupidly. Firstly I have search the Forum but no joy (or rather too much results, none seemed relevant to my case).

    In any case, I have the following:

    DECLARE
    v_period_start DATE: = TO_DATE ('2010-02-21 00:00:00 ',' YYYY-MM-DD HH24:MI:SS');
    v_period_end DATE: = TO_DATE (' 2010-03-20 23:59:59 ',' YYYY-MM-DD HH24:MI:SS' ");

    v_last_active DATE;

    CURSOR cust_list
    IS
    SELECT a.cust_no,
    a.service_id,
    b.Name,
    c.account_no,
    c.agreement_no,
    c.agreement_part_no,
    c.MSISDN,
    c.equipment_no,
    a.ordered_from,
    a.cancelled_to,
    a.contract_period_until,
    c.valid_from,
    c.valid_to,
    a.Status,
    d.campaign_service_no,
    d.Name LIKE 'CAMPAIGN '.
    Order_rows a,
    b services
    mobilebb_equips_p_agree_part c,
    campaign_services d
    WHERE < where the big clause >

    FC cust_list_futur % ROWTYPE;

    BEGIN
    FOR cf IN cust_list
    LOOP

    -Search for a command line with the same equipment which ended within 24 hours of the new order from. This should identify up/downgrades

    SELECT o.cancelled_to
    IN v_last_active
    Of order_rows o
    WHERE o.agreement_no = cf.agreement_no
    AND o.agreement_part_no = cf.agreement_part_no
    AND o.equipment_no = cf.equipment_no
    AND o.service_id <>cf.service_id
    AND o.cancelled_to BETWEEN cf.ordered_from - 1 AND cf.ordered_from
    AND rownum < 2;

    INSERT INTO miken_mobint_cust
    VALUES (cf.cust_no, cf.service_id, cf.name, cf.account_no, cf.msisdn, cf.equipment_no, cf.ordered_from, cf.cancelled_to,
    CF.contract_period_until, cf.valid_from, cf.valid_to, cf.status, cf.campaign_service_no, cf.campaign, cf.agreement_no, cf.agreement_part_no, v_last_active);

    END LOOP;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN v_last_active: = NULL;
    END;

    The problem seems to be that the SELECT INTO retuens that all lines and my main INSERT never never seems to run. If I comment the SELECT INTO and set the field last slot insert on a NULL value of the table Gets the appropriate records.

    I do not expect a return value very often of the SELECT INTO statement, so I need to know how it default null and continue the treatment when nothing is returned.

    Try this.

     DECLARE
        v_period_start DATE := TO_DATE('2010-02-21 00:00:00','YYYY-MM-DD HH24:MI:SS');
        v_period_end   DATE := TO_DATE('2010-03-20 23:59:59','YYYY-MM-DD HH24:MI:SS');
    
        v_last_active  DATE;
    
        CURSOR cust_list
        IS
        SELECT a.cust_no,
               a.service_id,
               b.name,
               c.account_no,
               c.agreement_no,
               c.agreement_part_no,
               c.msisdn,
               c.equipment_no,
               a.ordered_from,
               a.cancelled_to,
               a.contract_period_until,
               c.valid_from,
               c.valid_to,
               a.status,
               d.campaign_service_no,
               d.name AS "CAMPAIGN"
          FROM order_rows a,
               services b,
               mobilebb_equips_p_agree_part c,
               campaign_services d
         WHERE 
    
        cf cust_list_futur%ROWTYPE;
    
     BEGIN
        FOR cf IN cust_list
        LOOP
    
     -- Look for an order row with the same equipment that finished within 24 hours of the new order starting. This should identify up/downgrades
    
        BEGIN
              SELECT o.cancelled_to
                INTO v_last_active
                FROM order_rows o
               WHERE o.agreement_no = cf.agreement_no
                    AND o.agreement_part_no = cf.agreement_part_no
                    AND o.equipment_no = cf.equipment_no
                    AND o.service_id <> cf.service_id
                    AND o.cancelled_to BETWEEN cf.ordered_from - 1 AND cf.ordered_from
                    AND rownum < 2;
    
        EXCEPTION
            WHEN NO_DATA_FOUND THEN
                v_last_active := null;
        END;
    
           INSERT INTO miken_mobint_cust
           VALUES (cf.cust_no, cf.service_id, cf.name, cf.account_no, cf.msisdn, cf.equipment_no, cf.ordered_from, cf.cancelled_to,
                   cf.contract_period_until, cf.valid_from, cf.valid_to, cf.status, cf.campaign_service_no, cf.campaign, cf.agreement_no, cf.agreement_part_no, v_last_active);
    
        END LOOP;
     EXCEPTION
        WHEN NO_DATA_FOUND THEN v_last_active := NULL;
     END;
    
  • read the elements and index of a table

    Hello

    I use the function buildArray to build a table 1 d of 1024 items.

    Aferwards I want to extract all items + index of all the elements in another goal.

    I mean if e.g. the 1st element of my table is 10, the second is 45, the third is 65 and I want to have (0.10), (1: 45), (2, 65).

    Can you please help me.

    Use a loop FOR.  AutoIndex your table.  Use the table to build inside the loop TO create a table of the index (starting from the terminal i) and your indexed element.  Connect the new array to the output of the loop FOR (again, use autoindexing) to create a 2D array.

  • passing multiple values from the query in the select statement of the procedure

    I am collecting IDS to select education agreement from the date of rental values and then I would pass the result of the query in the statement select to get the result.
    data type for the contract id is of type varchar and date of rental there is more than one id to contract for most of the time. Help, please. Thank you

    CREATE OR REPLACE PROCEDURE abstract_menu (p_letting   IN     VARCHAR2,
                                               p_results      OUT SYS_REFCURSOR)
    IS
       v_contractId   VARCHAR2 (40);
    
    SELECT lcontid
      INTO v_contractId
      FROM letprop
     WHERE datestat IS NOT NULL AND letting = p_letting AND letstat <> 'R';
    
    
    BEGIN
       OPEN p_results FOR
            SELECT DISTINCT
                      SUBSTR (l.letting, 3, 2)
                   || '-'
                   || SUBSTR (l.letting, 5, 2)
                   || '-'
                   || SUBSTR (l.letting, 1, 2)
                      lettingdate,
                   l.lcontid contractid,
                   SUBSTR (q.cprojnum, 1, 10) projectnumber,
                   DECODE (TRIM (MIN (j.route)), NULL, 'N/A', TRIM (MIN (j.route)))
                      routenumber,
                   L.DATESTAT statusdate,
                   L.LETSTAT lettingstatus,
                   (q.cdescr) jobdescription,
                   INITCAP (q.clocat1 || q.clocat2) LOCATION
              FROM vendor v,
                   vendaddr r,
                   letprop l,
                   planhold p,
                   proposal q,
                   project j,
                   propproj k,
                   bidlet bd
             WHERE     v.vendor = r.vendor
                   AND k.contid = q.contid
                   AND k.pcn = j.pcn
                   AND l.lcontid = k.contid
                   AND p.vendor = v.vendor
                   AND l.letting = p.letting
                   AND l.lcontid IN v_contactid  "**************This is where I would like to pass the contract id from the above select statement***********'"
                   AND l.CALL = p.CALL
                   AND r.addrnum = p.billto
                   AND bd.letting = l.letting
          GROUP BY q.cdescr,
                   q.clocat1,
                   q.clocat2,
                   bd.letting,
                   l.letting,
                   l.lcontid,
                   q.cprojnum,
                   L.LETSTAT,
                   L.DATESTAT
          ORDER BY lettingdate;
    
    end;

    user9196150 wrote:
    AND l.lcontid IN v_contactid ' * this is where I would like to pass the id of the select statement above contract * ""»

    CREATE OR REPLACE PROCEDURE abstract_menu (p_letting   IN     VARCHAR2,
                                               p_results      OUT SYS_REFCURSOR)
    IS
    BEGIN
       OPEN p_results FOR
            SELECT DISTINCT
                      SUBSTR (l.letting, 3, 2)
                   || '-'
                   || SUBSTR (l.letting, 5, 2)
                   || '-'
                   || SUBSTR (l.letting, 1, 2)
                      lettingdate,
                   l.lcontid contractid,
                   SUBSTR (q.cprojnum, 1, 10) projectnumber,
                   DECODE (TRIM (MIN (j.route)), NULL, 'N/A', TRIM (MIN (j.route)))
                      routenumber,
                   L.DATESTAT statusdate,
                   L.LETSTAT lettingstatus,
                   (q.cdescr) jobdescription,
                   INITCAP (q.clocat1 || q.clocat2) LOCATION
              FROM vendor v,
                   vendaddr r,
                   letprop l,
                   planhold p,
                   proposal q,
                   project j,
                   propproj k,
                   bidlet bd
             WHERE     v.vendor = r.vendor
                   AND k.contid = q.contid
                   AND k.pcn = j.pcn
                   AND l.lcontid = k.contid
                   AND p.vendor = v.vendor
                   AND l.letting = p.letting
                   AND l.lcontid IN (
                                     SELECT  ll.lcontid
                                       FROM  letprop ll
                                       WHERE ll.datestat IS NOT NULL AND ll.letting = p_letting AND ll.letstat  'R'
                                    )
                   AND l.CALL = p.CALL
                   AND r.addrnum = p.billto
                   AND bd.letting = l.letting
          GROUP BY q.cdescr,
                   q.clocat1,
                   q.clocat2,
                   bd.letting,
                   l.letting,
                   l.lcontid,
                   q.cprojnum,
                   L.LETSTAT,
                   L.DATESTAT
          ORDER BY lettingdate;
    
    end;
    /
    

    SY.

  • How to pass parameter in the function using the select statement?

    Hello

    I had a problem. I can't pass as parameter to the function by using the select statement. But it can pass as a parameter using the "code". How can I solve this problem?

    For example,.
    Select * from table (SplitFunction ('HS750020, HS750021')) < < < this work.

    but

    Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36')) < < < do not work.

    Thank you for trying to help him. Thank you.

    Select * from table (SplitFunction (select LOT_NO in the TRACER_SEARCH_SCHEDULE where JOB_ID = '36'))< do="" not="">

    Try like this

    select * from table(select splitfunction(lot_no) from tracer_search_schedule where job_id='36')
    

    Just make sure that your subquery returns only 1 row.

  • can we write the function in a select statement?

    I have function and there Out parameter, so in this case I can write a select statement to my function to retrieve the value?

    user11195165 wrote:
    I have function and there Out parameter, so in this case I can write a select statement to my function to retrieve the value?

    Never mind that it's bad! for a function to have an OUT parameter. That's not how the functions should be designed and written.

    It's like with a knife like a spoon to eat porridge. Of course, it can work in a way. But why? A knife was never designed to be a spoon - and while it may work of porridge to eat, you'll have a hell of a time trying to use it to eat the soup. So, use the right tool.

    In other words, a function is the wrong tool for the job. Use a procedure.

  • 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.

Maybe you are looking for

  • Satellite L10-187 wakes up when the lid is closed

    I got this Toshiba Satellite L10-187 for a few years now, and since I bought it I had problems with it to wake up even if the lid is closed.Suspended or hibernation is not serious, he always wakes. More annoying is when I have it in my backpack and I

  • HP ENVY 5530: B814E906 error code

    Bought this machine yesterday, works fine when connected with the USB of my count. However I can't work in Wi - Fi. Judge for 2 evenings together now more than a dozen suggestions posted here. Also run printing HP and Scan Doctor several times. Withe

  • My HP Slate 7 itself turns off

    Hello world My HP Slate 7 itself turns off, even when it is plugged. It becomes a real problem because I use it as an alarm clock as well. This problem only starts in the last week or two, but has been making more and more frequent. Suggestions help

  • I have a home network.

    A computer is a laptop, the other is a desktop computer. Both are running Windows Vista. Both computers are mine and sit when I'm home. I can see the two computers from a computer. I can't that computer access to computer B, but can not access to com

  • Sex cam HP internal not listed on devices and does not

    its been a week since my web cam internal started working it was working just before, but I do not know what happened