Help with EXECUTE IMMEDIATE and DROP

Hi all,
we are trying to create a procedure to do the following:
* We have in the database some tables named like C$_XXXXXXXXX
* We want to drop some of these tables that have a common prefix (f.e C$_1203101)
DECLARE
v_sql VARCHAR2(300);
BEGIN
SELECT 'DROP TABLE ODISTAG.'|| TABLE_NAME ||';' INTO v_sql FROM USER_TABLES WHERE TABLE_NAME LIKE 'C$_1203101%';
EXECUTE IMMEDIATE v_sql;
END;
But we get this error:
Error report:
ORA-00911: invalid character
ORA-06512: at line 5
00911. 00000 - "invalid character"
*Cause:    identifiers may not start with any ASCII character other than
letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes
(q'#...#') cannot use spaces, tabs, or carriage returns as
delimiters. For all other contexts, consult the SQL Language
Reference Manual.
*Action:
Any help on that please?
Thanks!

This will not work if you fetch more than one row..instead you can do this..
DECLARE
     v_sql VARCHAR2(30000);
BEGIN
     for c2 in (
                    SELECT 'DROP TABLE ODISTAG.'|| TABLE_NAME drp
                    FROM USER_TABLES WHERE TABLE_NAME LIKE 'C$_1203101%'
     loop
          v_Sql := c2.drp;
          EXECUTE IMMEDIATE v_sql;
     end loop;
END;

Similar Messages

  • Need help with EXECUTE IMMEDIATE

    I have created a CHAR string in my form that contains a UPDATE statement. This statement is passed into my procedure and in the procedure, the EXECUTE IMMEDIATE is supposed to run the UPDATE statement. THIS IS NOT THE CASE for some reason. NEWVALUE is record is also passed into the procedure.
    this is the UPDATE_STATEMENT statement prepared by my forms application:
    'UPDATE xtable SET ACTION_CODE_DESC =''a b c'',INACTIVE =''N'' WHERE ACTION_CODE = newValue.ACTION_CODE'
    The CHAR values are surrounded by a pair of single quotes. The UPDATE statement starts and ends with single quotes.
    In my procedure I have this statement:
    PROCEDURE JKUPD_ACTION_CODE
    ( newValue in etmst_action_code%rowtype
    ,UPDATE_STATEMENT in CHAR
    ,perr_count out number
    AS
    BEGIN
    EXECUTE IMMEDIATE UPDATE_STATEMENT ;
    IF SQL%NOTFOUND
    THEN .......
    I keep getting ORA-00900: invalid SQL statement and dont understand why this is happening.
    Any ideas anyone?
    Thanks :)

    I haven't seen a version indication for this thread, but there should be 2 (different!) functions that come with Oracle that might do what you want.
    If all you want to do is dynamically execute text representing a SQL command check the on-line documentation (if there is any) for dbms_sql.execute and/or dbms_utility.exec_ddl. Make sure the string passed in are syntactically correct :)

  • Difficulties with execute immediate and 'in' clause

    Hello all,
    I have some SQL that will have to run dynamically, which I can get to work by building a long statement, then getting it hard-parsed
    example:
    sql_stmt VARCHAR2(256) :=
    'select distinct some_id from table1
    where lname = ''Smith''
    and fname in(''Joe'', ''Joey'', ''Joseph'')
    and ssn = 111223333';
    execute immediate sql_stmt into new_id_value;
    the above state executes fine and returns the desired result.
    HOWEVER, when I try to use bind variables (this statement will be called several million times), I get a no rows returned error.
    I use bind variables as follows:
    sql_stmt VARCHAR2(256);
    vlname VARCHAR2(50) := 'Smith';
    vssn NUMBER := 111223333;
    vfname VARCHAR2(100) := '''Joe'', ''Joey'', ''Joseph''';
    sql_stmt :=
    'select distinct some_id from table1
    where lname = :vlname
    and fname in(:vfname)
    and ssn = :vssn;
    execute immediate sql_stmt into new_id_value
    using vlname, vfname, vssn;
    I know the issue involves the 'in' clause because I've substituted hardcoded values in and it has worked.
    any suggestions?

    Well maybe its all a little confusing, does an end to end demo make it any clearer Mr Bidness?
    SQL> create or replace type tabstr_t as table of varchar2(4000)
      2  /
    Type created.
    SQL> create or replace function tabstr (
      2      p_str in varchar2,
      3      p_sep in varchar2 default ','
      4      )
      5  return tabstr_t
      6  is
      7      l_str long := p_str || p_sep;
      8      l_tabstr tabstr_t := tabstr_t();
      9  begin
    10      while l_str is not null loop
    11          l_tabstr.extend(1);
    12          l_tabstr(l_tabstr.count) := rtrim(substr(
    13                  l_str,1,instr(l_str,p_sep)),p_sep);
    14          l_str := substr(l_str,instr(l_str,p_sep)+1);
    15      end loop;
    16      return l_tabstr;
    17  end;
    18  /
    Function created.
    SQL> var s varchar2(100)
    SQL> exec :s := 'king,turner,ward'
    PL/SQL procedure successfully completed.
    SQL> select ename, sal from emp
      2  where ename in (
      3    select upper(column_value) from
      4    table(cast(tabstr(:s) as tabstr_t))
      5    );
    ENAME             SAL
    KING             5000
    TURNER           1500
    WARD             1250
    SQL> exec :s := 'jones,blake,clark'
    PL/SQL procedure successfully completed.
    SQL> /
    ENAME             SAL
    BLAKE            2850
    CLARK            2450
    JONES            2975

  • Execute a DML query its length exceeds 4000 characters with execute immediate statement.

    I want to execute a DML query with execute immediate statement. That DML query length exceeds 4000 characters. This query has Xquery related conditions, i can not split the query. when i tried execute it is giving "string literal too long".  I tried with DBMS_SQL.Parse() and DBMS_SQL.Execute also, but it is giving same error. I have to execute this DML query inside a Procedure. Please help me to resolve this. We are using oracle 10g version
    Thanks & Regards,
    K.Kedarnadh

    Actually Query is a dynamic query. Query length will exceeds if the no of domains\domain values \products exceeds. Any way Below one is current dynamic query, which is generated within procedure
    SELECT
      IVT.ID_IVT
        ,IVT.ID_INS_IVT
      ,EXTRACTVALUE(IVT.DOCUMENT_IVT,'//productName/text()') AS PRODUCTNAME
      ,EXTRACTVALUE(IVT.DOCUMENT_IVT,'//elementName/text()') AS INSTANCENAME
      ,EXTRACTVALUE(IVT.DOCUMENT_IVT,'//elementInternalName/text()') AS INTERNALNAME
        ,CTG.NAME_CTG
        ,CTR.NAME_CTR
        ,MDL.NAME_MDL
      ,IVT.REEDIT_FLAG_IVT
        FROM  VARIATION_IVT IVT INNER JOIN CATEGORY_CTG CTG ON CTG.ID_CTG=IVT.ID_CTG_IVT
      AND IVT.STATUS_IVT='Active' AND IVT.DELETE_FLAG_IVT=0 AND IVT.ID_PRJ_IVT=1
      AND  IVT.DOCUMENT_IVT.existsnode('.//domain[domainName="Jurisdictions" and (domainValue="Delhi" or domainValue="Bangladesh" or domainValue="Mumbai" or domainValue="India" or domainValue="Pakistan" or domainValue="Nepal" or domainValue="Maldives" or domainValue="Kolkata" or domainValue="Bhutan" or domainValue="Chennai" or domainValue="ALL")]')=1 AND  IVT.DOCUMENT_IVT.existsnode('.//domain[domainName="Channels" and (domainValue="Agents" or domainValue="SBI" or domainValue="Maruti" or domainValue="Direct" or domainValue="CitiFinancial" or domainValue="SCB" or domainValue="BankAssurance" or domainValue="CitiBank" or domainValue="Employees" or domainValue="GE" or domainValue="Brokers" or domainValue="Telemarketing" or domainValue="Agency" or domainValue="ALL")]')=1 AND  IVT.DOCUMENT_IVT.existsnode('.//domain[domainName="ModeofDelivery" and (domainValue="Walkin" or domainValue="Internet" or domainValue="ALL")]')=1 AND  IVT.DOCUMENT_IVT.existsnode('.//context[(productName="ALL" or productName="A009" or productName="A010" or productName="A046" or productName="AccidentShieldClassic" or productName="AccidentShieldOnline" or productName="AM01" or productName="AM02" or productName="AME_Cancellation" or productName="ARHG" or productName="ARPA" or productName="B003" or productName="B004" or productName="B007" or productName="B008" or productName="B009" or productName="B010" or productName="B012" or productName="B013" or productName="B015" or productName="B016" or productName="B017" or productName="BC04_PA" or productName="BC06_FDP" or productName="BC06_PA" or productName="BC09" or productName="BC10" or productName="BC12" or productName="BC13" or productName="BF03" or productName="BS01" or productName="BS02" or productName="C017" or productName="C035" or productName="C036" or productName="C037" or productName="C038" or productName="C040" or productName="C041" or productName="C041Gold" or productName="C041New" or productName="C045HomeContents" or productName="C048" or productName="C049" or productName="C054" or productName="C057" or productName="C060Building" or productName="C060Contents" or productName="C060FDP" or productName="C061Building" or productName="C061Contents" or productName="C062" or productName="C063" or productName="C067" or productName="C070" or productName="C072" or productName="C074" or productName="C077" or productName="C081" or productName="C082" or productName="C087" or productName="C088" or productName="CITIFOREVER" or productName="CITISECURE" or productName="CITICHILDPLAN" or productName="D001" or productName="DB01" or productName="DD01" or productName="DD02" or productName="DD03" or productName="DD04" or productName="DD09" or productName="DD10" or productName="E005" or productName="E011" or productName="E016" or productName="E020" or productName="E030" or productName="E034" or productName="E040" or productName="E041" or productName="E045HCP" or productName="E045HSP" or productName="E049" or productName="E049New" or productName="E052" or productName="E053" or productName="E054FDP" or productName="E055" or productName="E056" or productName="E057" or productName="E058" or productName="E061" or productName="E061BATCH" or productName="E062" or productName="E063" or productName="E064HCP" or productName="E064HSP" or productName="E066" or productName="E069" or productName="E073" or productName="E075" or productName="E076" or productName="E088" or productName="E090" or productName="E093A" or productName="E093B" or productName="E095" or productName="E099A" or productName="E099B" or productName="E106" or productName="E107" or productName="E110" or productName="E112" or productName="E114" or productName="E115" or productName="E116" or productName="F001" or productName="FamilyHealthInsurance" or productName="FamilyHospitalBenefits" or productName="FamilyHospitalisationCoverBenefit" or productName="G001" or productName="G002" or productName="HealthShieldOnline" or productName="Health_B005" or productName="Health_S057" or productName="HealthSheild" or productName="HealthWalkin" or productName="HomeContentOnline" or productName="HomeShieldOnline" or productName="HomeShieldWalkin" or productName="HospitalCashOnline" or productName="J001" or productName="J008" or productName="K001" or productName="KV02" or productName="LC03" or productName="ML01" or productName="MP02" or productName="MP03" or productName="MR01" or productName="O005" or productName="PO01" or productName="PO02" or productName="PO03" or productName="PO04" or productName="PO05" or productName="PO06" or productName="RR02" or productName="RR03" or productName="RR04" or productName="S006" or productName="S033" or productName="S049" or productName="S051" or productName="S054" or productName="S057" or productName="S060" or productName="S061" or productName="S065" or productName="S065TM" or productName="S068" or productName="S076" or productName="S077" or productName="S079" or productName="S080" or productName="S081" or productName="S084" or productName="S085" or productName="S086" or productName="S087" or productName="S088" or productName="S091" or productName="S092" or productName="S093" or productName="S094" or productName="S095" or productName="S097" or productName="S098" or productName="S099" or productName="S100" or productName="S101" or productName="S102" or productName="S103" or productName="S104" or productName="S106" or productName="S107" or productName="S108" or productName="S109" or productName="S110" or productName="S111" or productName="S113" or productName="SCBNAC" or productName="SF02" or productName="SS01" or productName="SS02" or productName="SUNFHM" or productName="SurgicalShield" or productName="TD01" or productName="TD02" or productName="TP01" or productName="U002Building" or productName="U002Contents" or productName="U004Building" or productName="U007" or productName="U009" or productName="U013" or productName="U014" or productName="U015" or productName="U016" or productName="V001" or productName="V002" or productName="V005" or productName="V006" or productName="V008" or productName="W008" or productName="W020" or productName="W021" or productName="W022" or productName="W023" or productName="W024" or productName="W026" or productName="W027" or productName="W028" or productName="W029" or productName="W105" or productName="W106" or productName="WI01" or productName="WI02" or productName="WI03" or productName="WI07" or productName="WI08" or productName="WI09" or productName="WI10" or productName="WI11" or productName="WI12" or productName="WI13" or productName="WI14" or productName="WI17" or productName="WI20" or productName="WI21" or productName="WI21_Health" or productName="WI23" or productName="WI24" or productName="WI26" or productName="WI30" or productName="WI31" or productName="WI33" or productName="WI34" or productName="X001" or productName="X002" or productName="X003" or productName="X004" or productName="X005" or productName="X008" or productName="Y001" or productName="Y007" or productName="Y009" or productName="Y010" or productName="Y011" or productName="Y011H" or productName="Y020" or productName="Y020N" or productName="Z008" or productName="ZI001")]')=1
      INNER JOIN CENTER_CTR CTR ON CTR.ID_CTR=CTG.ID_CTR_CTG
        INNER JOIN MODEL_MDL MDL ON  MDL.ID_MDL=CTR.ID_MDL_CTR

  • Execute Immediate and CLOB

    Hi All,
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    I am getting error when trying to use CLOB with execute immediate.
    DECLARE
    v_clob CLOB;
    BEGIN
    EXECUTE IMMEDIATE 'SELECT DBMS_METADATA.GET_DDL(''TABLE'',''T_FDB_TMP'') from dual'
               INTO v_clob_part_ddl;
    EXECUTE IMMEDIATE 'DROP TABLE T_FDB_TMP';
    EXECUTE IMMEDIATE to_char(v_clob_part_ddl);
    END;
    ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at line 1
    ORA-06502: PL/SQL: numeric or value error
    ORA-31605: the following was returned from LpxXSLResetAllVars in routine kuxslResetParams:
    LPX-1: NULL pointer
    ORA-06512: at line 3
    06502. 00000 -  "PL/SQL: numeric or value error%s"Please help

    If you can't upgrade to 11g then you'll have to use DBMS_SQL package...
    e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  declare
      2    v_large_sql  CLOB;
      3    v_num        NUMBER := 0;
      4    v_upperbound NUMBER;
      5    v_sql        DBMS_SQL.VARCHAR2S;
      6    v_cur        INTEGER;
      7    v_ret        NUMBER;
      8  begin
      9    -- Build a very large SQL statement in the CLOB
    10    LOOP
    11      IF v_num = 0 THEN
    12        v_large_sql := 'CREATE VIEW vw_tmp AS SELECT ''The number of this row is : '||to_char(v_num,'fm0999999')||''' as col1 FROM DUAL';
    13      ELSE
    14        v_large_sql := v_large_sql || ' UNION ALL SELECT ''The number of this row is : '||to_char(v_num,'fm0999999')||''' as col1 FROM DUAL';
    15      END IF;
    16      v_num := v_num + 1;
    17      EXIT WHEN DBMS_LOB.GETLENGTH(v_large_sql) > 40000 OR v_num > 800;
    18    END LOOP;
    19    DBMS_OUTPUT.PUT_LINE('Length:'||DBMS_LOB.GETLENGTH(v_large_sql));
    20    DBMS_OUTPUT.PUT_LINE('Num:'||v_num);
    21    --
    22    -- Now split that large SQL statement into chunks of 256 characters and put in VARCHAR2S array
    23    v_upperbound := CEIL(DBMS_LOB.GETLENGTH(v_large_sql)/256);
    24    FOR i IN 1..v_upperbound
    25    LOOP
    26      v_sql(i) := DBMS_LOB.SUBSTR(v_large_sql
    27                                 ,256 -- amount
    28                                 ,((i-1)*256)+1 -- offset
    29                                 );
    30    END LOOP;
    31    --
    32    -- Now parse and execute the SQL statement
    33    v_cur := DBMS_SQL.OPEN_CURSOR;
    34    DBMS_SQL.PARSE(v_cur, v_sql, 1, v_upperbound, FALSE, DBMS_SQL.NATIVE);
    35    v_ret := DBMS_SQL.EXECUTE(v_cur);
    36    DBMS_OUTPUT.PUT_LINE('View Created');
    37* end;
    SQL> /
    Length:40015
    Num:548
    View Created
    PL/SQL procedure successfully completed.
    SQL> select count(*) from vw_tmp;
      COUNT(*)
           548
    SQL> select * from vw_tmp where rownum <= 10;
    COL1
    The number of this row is : 0000000
    The number of this row is : 0000001
    The number of this row is : 0000002
    The number of this row is : 0000003
    The number of this row is : 0000004
    The number of this row is : 0000005
    The number of this row is : 0000006
    The number of this row is : 0000007
    The number of this row is : 0000008
    The number of this row is : 0000009
    10 rows selected.
    SQL>

  • Gallery with Paypal buttons and drop-downs on the index page?

    I'm looking for a LR gallery where I can have thumbnails with Paypal buttons and drop-downs on the index page.
    I would prefer to keep my galleries interface streamlined and don't want to clutter it up with dropdowns and cart. I would like to have 1 page for ordering that has all my images as thumbnails with drop downs for price and size, rather than right-clicking on and image which opens in another page like the LRG Gallery with Paypal.
    I don't have a lot of experience messing with code, and none with .js. I did make a drop down in Paypal and have the code, but I think things would be pretty unwield it I designed a page as a table like I would in MS Word.
    I'm familiar with LRG Complete gallery, but don't see that it has the ability to not require a right click to order.
    I don't have a lot of experience messing with code, and none with .js. I did make a drop down in Paypal and have the code, but I think things would be pretty unwield it I designed a page as a table like I would in MS Word.
    Any thoughts, ideas, or help?
    Thanks,
    Reid

    Maybe some could try this out, and has experienced the same problem.
    It is on the site http://www.fonetix.biz
    and then push the German flag in the top Right corner, and further click on the Button "Contact info". It will give the eroor.

  • Pipelined Function with execute immediate

    Hello Experts,
    I have created a Pipe lined function with execute immediate, due to below requirement;
    1) Columns in where clause is passed dynamically.
    2) I want to know the data stored into above dynamic columns.
    3) I want to use it in report, so I don't want to insert it into a table.
    I have created a TYPE, then through execute immediate i have got the query and result of that query will be stored in TYPE.
    But when calling the function i am getting
    ORA-00932: inconsistent datatypes: expected - got -
    Below is my function and type, let me know i am going wrong, and is my logic correct.
    CREATE OR REPLACE TYPE OBJ_FPD AS OBJECT
                      (LOW_PLAN_NO VARCHAR2 (40),
                       FPD VARCHAR2 (5),
                       SERIAL_NO NUMBER,
                       CEDIA_CODE VARCHAR2 (2),
                       DT DATE);
    CREATE OR REPLACE TYPE FPD_TBL_TYPE AS TABLE OF OBJ_FPD;
    CREATE OR REPLACE FUNCTION FUNC_GET_FPD_DATE (P_LOW_PLAN_NO    VARCHAR2,
                                                  P_CEDIA_CODE     VARCHAR2,
                                                  P_SERIAL_NO      NUMBER)
       RETURN FPD_TBL_TYPE
       PIPELINED
    AS
       CURSOR C1
       IS
              SELECT 'FPD' || LEVEL TBL_COL
                FROM DUAL
          CONNECT BY LEVEL <= 31;
       V_STR        VARCHAR2 (5000);
       V_TBL_TYPE   FPD_TBL_TYPE;
    BEGIN
       FOR X IN C1
       LOOP
          V_STR :=
                'SELECT A.low_PLAN_NO,
               A.FPD,
               A.SERIAL_NO,
               A.cedia_code,
               TO_DATE (
                     SUBSTR (FPD, 4, 5)
                  || ''/''
                  || TO_CHAR (C.low_PLAN_PERIOD_FROM, ''MM'')
                  || ''/''
                  || TO_CHAR (C.low_PLAN_PERIOD_FROM, ''RRRR''),
                  ''DD/MM/RRRR'')
                  DT FROM ( SELECT low_PLAN_NO, '
             || ''''
             || X.TBL_COL
             || ''''
             || ' FPD, '
             || X.TBL_COL
             || ' SPTS, SERIAL_NO, cedia_code FROM M_low_PLAN_DETAILS WHERE NVL('
             || X.TBL_COL
             || ',0) > 0 AND SERIAL_NO = '
             || P_SERIAL_NO
             || ' AND cedia_code = '
             || ''''
             || P_CEDIA_CODE
             || ''''
             || ' AND low_PLAN_NO = '
             || ''''
             || P_LOW_PLAN_NO
             || ''''
             || ') A,
               M_low_PLAN_DETAILS B,
               M_low_PLAN_MSTR C
         WHERE     A.low_PLAN_NO = B.low_PLAN_NO
               AND A.cedia_code = B.cedia_code
               AND A.SERIAL_NO = B.SERIAL_NO
               AND B.low_PLAN_NO = C.low_PLAN_NO
               AND B.CLIENT_CODE = C.CLIENT_CODE
               AND B.VARIANT_CODE = C.VARIANT_CODE
    CONNECT BY LEVEL <= SPTS';
          EXECUTE IMMEDIATE V_STR INTO V_TBL_TYPE;
          FOR I IN 1 .. V_TBL_TYPE.COUNT
          LOOP
             PIPE ROW (OBJ_FPD (V_TBL_TYPE (I).LOW_PLAN_NO,
                                V_TBL_TYPE (I).FPD,
                                V_TBL_TYPE (I).SERIAL_NO,
                                V_TBL_TYPE (I).CEDIA_CODE,
                                V_TBL_TYPE (I).DT));
          END LOOP;
       END LOOP;
       RETURN;
    EXCEPTION
       WHEN OTHERS
       THEN
          RAISE_APPLICATION_ERROR (-20000, SQLCODE || ' ' || SQLERRM);
          RAISE;
    END;Waiting for your views.
    Regards,

    Ora Ash wrote:
    Hello Experts,
    I have created a Pipe lined function with execute immediate, due to below requirement;
    1) Columns in where clause is passed dynamically.No, that's something you've introduced, and is due to poor database design. You appear to have columns on your table called FPD1, FPD2 ... FPD31. The columns do not need to be 'passed dynamically'
    2) I want to know the data stored into above dynamic columns.And you can know the data without it being dynamic.
    3) I want to use it in report, so I don't want to insert it into a table.That's fine, though there's no reason to use a pipelined function.
    You also have an pointless exception handler, which masks any real errors.
    I'm not quite sure what the point of your "connect by" is in your query as we don't have your tables or data or know for sure what the expected output is.
    However, in terms of handling the 'dynamic' part that you've introduced, then you would be looking at doing something along the following lines, using a static query that requires no poor dynamic code, and no pipelined function...
    with x as (select level as dy from dual connect by level <= 31)
    select a.low_plan_no
          ,a.fpd
          ,a.serial_no
          ,a.cedia_code
          ,trunc(c.low_plan_period_from)+a.dy-1 as dt
    from  (select low_plan_no
                 ,dy
                 ,'FPD'||dy as fpd
                 ,spts
                 ,serial_no
                 ,cedia_code
           from (
                 select low_plan_no
                       ,x.dy
                       ,case x.dy when 1 then fpd1
                                  when 2 then fpd2
                                  when 3 then fpd3
                                  when 4 then fpd4
                                  when 5 then fpd5
                                  when 6 then fpd6
                                  when 7 then fpd7
                                  when 8 then fpd8
                                  when 9 then fpd9
                                  when 10 then fpd10
                                  when 11 then fpd11
                                  when 12 then fpd12
                                  when 13 then fpd13
                                  when 14 then fpd14
                                  when 15 then fpd15
                                  when 16 then fpd16
                                  when 17 then fpd17
                                  when 18 then fpd18
                                  when 19 then fpd19
                                  when 20 then fpd20
                                  when 21 then fpd21
                                  when 22 then fpd22
                                  when 23 then fpd23
                                  when 24 then fpd24
                                  when 25 then fpd25
                                  when 26 then fpd26
                                  when 27 then fpd27
                                  when 28 then fpd28
                                  when 29 then fpd29
                                  when 30 then fpd30
                                  when 31 then fpd31
                        else null
                        end as spts
                       ,serial_no
                       ,cedia_code
                 from   x cross join m_low_plan_details
                 where  serial_no = p_serial_no
                 and    cedia_code = p_cedia_code
                 and    low_plan_no = p_low_plan_no
           where  nvl(spts,0) > 0
          ) A
          join m_low_plan_details B on (    A.low_plan_no = B.low_plan_no
                                        and A.cedia_code = B.cedia_code
                                        and A.serial_no = B.serial_no
          join m_low_plan_mstr C on (    B.low_plan_no = C.low_plan_no
                                     and B.client_code = C.client_code
                                     and B.variant_code = C.variant_code
    connect by level <= spts;... so just remind us again why you think it needs to be dynamic?

  • Transaction control with execute immediate

    Hi, What is the correct way to commit/ rollback transactions when executing a dynamic update statement with execute immediate?

    Hi Thanks fo the reply, they don't appear to be. here's my procedure. Is there anything the is obviously wrong?
    PROCEDURE p_move_city_numerics ( p_mode IN VARCHAR2,
    p_schema IN VARCHAR2,
              p_table IN VARCHAR2,
                   p_destination IN VARCHAR2,
                   p_city_name IN VARCHAR2,
                   p_outcome     OUT VARCHAR2)
    IS
    l_valid_object VARCHAR2(200);
         l_error_msg VARCHAR2(200);
         l_outcome     VARCHAR2(2000);
         l_sql_count VARCHAR2(2000);
         l_sql_update VARCHAR2(2000);
         l_record_count NUMBER;
         e_object_error EXCEPTION;
    BEGIN
    l_valid_object := f_is_city_valid (p_schema, p_table, p_destination);
         IF l_valid_object != 'VALID' THEN
         RAISE e_object_error;
         END IF;
         l_sql_count := 'SELECT COUNT(*) FROM ' || p_schema || '.' || p_table;
         l_sql_count := l_sql_count || ' WHERE UPPER(city) LIKE ' || '''' || '%' || UPPER(p_city_name) || '%' || '''';
         l_sql_count := l_sql_count || ' AND ( city LIKE ' || '''' || '%1%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%2%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%3%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%4%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%5%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%6%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%7%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%8%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%9%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%0%' || '''' || ')';
         l_sql_update := 'UPDATE ' || p_schema || '.' || p_table;
         l_sql_update := l_sql_update || ' SET ' || p_destination || ' = city,';
         l_sql_update := l_sql_update || ' city = ' || '''' || p_city_name || '''';
         l_sql_update := l_sql_update || ' WHERE UPPER(city) LIKE ' || '''' || '%' || UPPER(p_city_name) || '%' || '''';
         l_sql_update := l_sql_update || ' AND ( city LIKE ' || '''' || '%1%' || '''';
         l_sql_update := l_sql_update || ' OR ciity LIKE ' || '''' || '%2%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%3%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%4%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%5%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%6%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%7%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%8%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%9%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%0%' || '''' || ')';
         IF p_mode = 'SELECT' THEN
         EXECUTE IMMEDIATE(l_sql_count) INTO l_record_count;
         l_outcome := TO_CHAR(l_record_count) || ' records to be updated!';
         ELSIF p_mode = 'UPDATE' THEN
         EXECUTE IMMEDIATE(l_sql_count) INTO l_record_count;
         EXECUTE IMMEDIATE(l_sql_update);
    l_outcome := TO_CHAR(l_record_count) || ' records have been updated!';
         COMMIT;
         ELSE
         l_outcome := ' ERROR - Invalid mode: ' || p_mode || ' has been passed into the function! Valid values are SELECT or UPDATE';
         END IF;
    EXCEPTION
    WHEN e_object_error THEN
         IF l_valid_object = 'INVALID_TABLE' THEN
         l_outcome := 'ERROR - Not a valid table name: ' || p_schema || '.' || p_table;
         ELSIF l_valid_object = 'INVALID_CITY' THEN
         l_outcome := 'ERROR - CITY not a valid field in the table: ' || p_schema || '.' || p_table;
         ELSIF l_valid_object = 'INVALID_DEST' THEN
         l_outcome := 'ERROR - Destination field: ' || p_destination || ' is not a valid field in the table: ' || p_schema || '.' || p_table;
         END IF;
         WHEN OTHERS THEN
         l_error_msg := SQLCODE || '-' || SUBSTR(SQLERRM, 1, 150);
         l_outcome := 'ERROR - ' || l_error_msg;
         ROLLBACK;
    END p_move_city_numerics;

  • Disadvantage with 'Execute Immediate'

    What is the disadvantage with 'EXECUTE IMMEDIATE'.

    I think you guys are missing the point here.
    None of the issues listed are 'EXECUTE IMMEDIATE' disadvantages.
    'EXECUTE IMMEDIATE' is a tool. Like DMS_SQL. Like ref cursors. Like explicit cursor. Like implicit cursors.
    A tool, any tool, needs to be used correctly. If you use a hammer and hit a nail so hard that it bents, causing the hammer to slip doing some serious damage to your thumb... whose fault it is?
    Is it The Hammer that is at fault here? Or is the user of that tool?
    There are no disadvantages to using 'EXECUTE IMMEDIATE'. It is a tool. But like all tools it needs to be used correctly and safely. Things like excessive hard parsing because of a severe lack of bind variables, or opening a hole for SQL injection, etc.. all these are symptoms of - and let's be blunt here - an ignorant developer. It has nothing to do with the tool 'EXECUTE IMMEDIATE'.
    And those same type of errors will be made by Mr Ignorant Developer using other tools in Oracle.
    Shoddy workmanship is not because of poor tools. Shoddy code is not because of using a specific feature (like execute immediate).
    The proper question to ask is thus not "what are the disadvantages of execute immediate", but rather "where should I typically use execute immediate and how?".
    Not every developer will know how to use every single tool in the toolbox (I sure don't know all the tools in the Oracle toolbox). So there is nothing wrong with asking.
    But asking what is "wrong" with a tool (aka "what are the disadvantages") is in my view seriously missing the point that a tool is there to solve very specific types of problems...
    That is what a developer should be after - How to use the tool correctly.

  • Problems with ListViews Drag and Drop

    I'm surprised that there isn't an Active X control that can do this more
    easily? Would
    be curious to find out if there is - although we aren't really embracing the
    use of
    them within Forte because it locks you into the Microsoft arena.
    ---------------------- Forwarded by Peggy Lynn Adrian/AM/LLY on 02/03/98 01:33
    PM ---------------------------
    "Stokesbary, Michael" <[email protected]> on 02/03/98 12:19:52 PM
    Please respond to "Stokesbary, Michael" <[email protected]>
    To: "'[email protected]'" <[email protected]>
    cc:
    Subject: Problems with ListViews Drag and Drop
    I am just curious as to other people's experiences with the ListView
    widget when elements in it are set to be draggable. In particular, I am
    currently trying to design an interface that looks a lot like Windows
    Explorer where a TreeView resides on the left side of the window and a
    ListView resides on the right side. Upon double clicking on the
    ListView, if the current node that was clicked on was a folder, then the
    TreeView expands this folder and the contents are then displayed in the
    ListView, otherwise, it was a file and it is brought up in Microsoft
    Word. All this works great if I don't have the elements in the ListView
    widget set to be draggable. If they are set to be draggable, then I am
    finding that the DoubleClick event seems to get registered twice along
    with the ObjectDrop event. This is not good because if I double click
    and the current node is a folder, then it will expand this folder in the
    TreeView, display the contents in the ListView, grab the node that is
    now displayed where that node used to be displayed and run the events
    for that as well. What this means, is that if this is a file, then Word
    is just launched and no big deal. Unfortunately, if this happens to be
    another directory, then the previous directory is dropped into this
    current directory and a recursive copy gets performed, giving me one
    heck of a deep directory tree for that folder.
    Has anybody else seen this, or am I the only lucky one to experience.
    If need be, I do have this exported in a .pex file if anybody needs to
    look at it more closely.
    Thanks in advance.
    Michael Stokesbary
    Software Engineer
    GTE Government Systems Corporation
    tel: (650) 966-2975
    e-mail: [email protected]

    here is the required code....
    private static class TreeDragGestureListener implements DragGestureListener {
         public void dragGestureRecognized(DragGestureEvent dragGestureEvent) {
         // Can only drag leafs
         JTree tree = (JTree) dragGestureEvent.getComponent();
         TreePath path = tree.getSelectionPath();
         if (path == null) {
              // Nothing selected, nothing to drag
              System.out.println("Nothing selected - beep");
              tree.getToolkit().beep();
         } else {
              DefaultMutableTreeNode selection = (DefaultMutableTreeNode) path
                   .getLastPathComponent();
              if (selection.isLeaf()) {
              TransferableTreeNode node = new TransferableTreeNode(
                   selection);
              dragGestureEvent.startDrag(DragSource.DefaultCopyDrop,
                   node, new MyDragSourceListener());
              } else {
              System.out.println("Not a leaf - beep");
              tree.getToolkit().beep();
    }

  • Need help with Blog, Wiki and Gallery

    Hi Team,
    Need help with Blog, Wiki and Gallery startup. I have newly started visiting forums and quite interested to contribute towards these areas also.
    Please help.
    Thanks,
    Santosh Singh
    Santosh Singh

    Hello Santhosh,
    Blog is for Microsoft employees only. However, you can contribute towards WIKI and GALLERY using the below links.
    http://social.technet.microsoft.com/wiki/
    http://gallery.technet.microsoft.com/

  • What's the phone number I should call for help with my iPhone and ihome dock?

    What's the phone number I should call for help with my iPhone and ihome dock?

    http://www.ihomeaudio.com/support/

  • Help with photoshop quitting and AMD graphics

    help with photoshop quitting and AMD graphics
    im not a techy, but it appears i have to do someting with my amd graphics card - this might be why my software is crashing - ive no idea what to do though

    Hi Chris
    I have tried to go on the website, then i tried to download the automatic detect because i wasnt sure which driver i had or needed - but it has just downloaded a load of game software - which i dont want ( i dont think)
    i have find out my laptop has a amd radeon HD 8750M card, but i dont know what im doing! i would hate to mess my computer up as i am in thailand with no one to help me!
    its frustrating as i am paying for CC but cant use it!

  • Execute Immediate and the in list

    Hello,
    How do I format the in list when i am executing a query with execute immediate ?
    I want to check if a character value is in ('5', '6', '7') ? Execute immediate treats my in list as a string instead of checking to see if the given value is in ny list of values or not. Please see the code / output below.
    SQL> declare
    2
    3 v_result VARCHAR2 (1) := 'N';
    4 v_num_list1 VARCHAR2 (40) := '''5''';
    5 v_num_list2 VARCHAR2 (40) := '''5'',''6'',''7''';
    6
    7 v_in VARCHAR2 (100)
    8 := 'BEGIN IF (:txn_value IN (:case_list)) THEN :result := ''Y''; END IF; END;';
    9 v_ctrl_no varchar2(40) := '''5''';
    10 BEGIN
    11
    12 DBMS_OUTPUT.PUT_LINE ('txn_value: ' || v_ctrl_no);
    13 DBMS_OUTPUT.PUT_LINE ('case_list: ' || v_num_list1);
    14
    15 EXECUTE IMMEDIATE v_in
    16 USING IN v_ctrl_no, v_num_list1, OUT v_result;
    17
    18 DBMS_OUTPUT.PUT_LINE ('result is ''' || v_result || '''');
    19 v_result := 'N';
    20
    21 DBMS_OUTPUT.PUT_LINE ('txn_value: ' || v_ctrl_no);
    22 DBMS_OUTPUT.PUT_LINE ('case_list: ' || v_num_list2);
    23
    24 EXECUTE IMMEDIATE v_in
    25 USING IN v_ctrl_no, v_num_list2, OUT v_result;
    26
    27 DBMS_OUTPUT.PUT_LINE ('result is ''' || v_result || '''');
    28
    29 END;
    30 /
    txn_value: '5'
    case_list: '5'
    result is 'Y'
    txn_value: '5'
    case_list: '5','6','7'
    result is 'N'
    Thanks,
    Anna

    you can't use a bind variable for an in-list string.
    you can rebuild the dynamic statement each time, without a bind variable:
    sql := '... in ( ' || in_list_var ||' )...
    or, you can use instr:
    sql := ' ... instr(:in_list_var, :txn_val) > 0 ...'
    using ','||in_list, ','||txn_val||','; -- notice the extra commas

  • Difference between regular update and update with execute immediate

    Hi everyone, I have seen some code where developers have executed insert and update statement using execute immediate.
    for example :
    execute immediate ('Update employees set employee_salary = :x');
    I can update record using the following statement where x is a number (salary)
    update employee
    set employee_salary = x;
    It works fine as well
    Whats the difference? and what way is recommended
    Thanks

    My guess is that sqlplus does a commit on exit:
    In session 1:
    SQL> create table test (col1 number);
    Table created.
    SQL> begin
      2    execute immediate 'insert into test values (1)';
      3  end;
      4  /
    PL/SQL procedure successfully completed.In session 2:
    SQL> select * from test;
    no rows selectedIn session 1:
    SQL> exec execute immediate 'insert into test values (2)';
    PL/SQL procedure successfully completed.In session 2:
    SQL> select * from test;
    no rows selectedIn session 1:
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, Oracle Label Security, OLAP and Data Mining optionsIn session 2:
    SQL> select * from test;
          COL1
             1
             2

Maybe you are looking for

  • ITunes update failed to reinstall on 64-bit Windows 7 Home Premium

    Never had problems before with iTunes update. I never had to do anything besides accepting the agreement, followed the prompts, and clicked "Finish" at the end of the installation. But the update that came 3 days ago failed to install, with a message

  • New folder created in Windows explorer not visible in Bridge.

    If I create a new folder in My Pictures folder using Windows Explorer, it doesn't show up in Bridge . I do it that way because selecting Get Photos from Camera doesn't allow me to select only the photos I want from the card. Why does Bridge not show

  • How do I change the name that appears on my comments on the photo streaming?

    When I first bought and configured my iphone 4, my husband used his name to create an apple account. I was able to change it most everywhere, but when I post a comment on a photo streaming it appears his name instead of mine. How do I fix it? When I

  • Note of credit (return) with MIRO during use of two currencies (changeover)

    Hello: We have a problem with the MIRO when we do a second partial note of credit with the new currency VEF (the purchase is in VEB) Now provisionally we work with two currencys: VEB (local currency) and VEF (transaction currency). When there is real

  • 'Upgraded' email is a big step back!

    I used to be able to set up an icon on my Firefox taskbar to take me straight into BT's Yahoo webmail, but not now, oh no, I'm just presented with a BT login screen EVERY time. Progress, not for me, that's for sure. Is there a workaround or should I