Bind Variables in a insert

I want to use a bind variable in order to insert a binary data in a raw field.
I do this in a C# app., using parameters, in Oracle Server it works successfully
but when I change the conection to a Oracle Lite Data Base the bd returns
the error "37000[POL-5228]: Syntaxis Error".
The sql is like this: "insert into GENERIC_TABLE (id, data) values ("+id.ToString()+", :Data)"
And after I insert the parameter.
Does someone know if in Lite the bind variables syntaxis is diferent?
Could you help me? What's happend in lite version?
Thanks in advance

Hi,
As far I know, SQL Statements, metadata, user names, etc... in fact every string that is not binded or defined can only be ANSI or UTF16.

Similar Messages

  • Inserting a LINESTRING with a bind variable

    Hello - I am trying to insert a LINESTRING with a bind variable. Here is my query that works:
    INSERT INTO EDGE (pts)
    VALUES (SDO_GEOMETRY('LINESTRING(-71.110157 42.513495, -71.110159 42.51359)',8307));
    But if I want to pass in the pts as a bind variable, as follows:
    INSERT INTO EDGE (pts)
    VALUES (SDO_GEOMETRY(LINESTRING(:pts),8307));
    When prompted in sqlDeveloper I set the bind variable to: -71.110157 42.513495, -71.110159 42.51359
    I get the following error: PLS-306: wrong number of types of arguments.
    Thanks!

    Thanks - Your reply worked well, but I ran into another snag. If the linestring is greater than 4000 chars, I get another error.
    ORA-01461: can bind a LONG value only for insert into a LONG column
    Are there any work arounds for this?? Below is the string I am using for the bind/insert:
    LINESTRING(
    6.169746 50.348667,6.169377 50.348584,6.168800 50.348460,6.168807 50.348434,
    6.168901 50.348392,6.168972 50.348330,6.168994 50.348279,6.168985 50.348228,
    6.168896 50.348179,6.168784 50.348150,6.168664 50.348151,6.168569 50.348183,
    6.168460 50.348251,6.168366 50.348257,6.168278 50.348243,6.168197 50.348184,
    6.168052 50.348109,6.167844 50.348082,6.167660 50.348059,6.167611 50.348019,
    6.167600 50.347887,6.167544 50.347873,6.167432 50.347869,6.167338 50.347921,
    6.167093 50.348021,6.166934 50.348044,6.166768 50.348062,6.166625 50.348084,
    6.166568 50.348065,6.166487 50.347984,6.166261 50.347901,6.166006 50.347879,
    6.165871 50.347912,6.165865 50.347968,6.165883 50.348059,6.165868 50.348090,
    6.165755 50.348041,6.165562 50.347993,6.165450 50.347974,6.165355 50.347980,
    6.165253 50.348048,6.165263 50.348109,6.165328 50.348184,6.165282 50.348231,
    6.165218 50.348252,6.165148 50.348319,6.165166 50.348395,6.165135 50.348431,
    6.165032 50.348463,6.164905 50.348460,6.164818 50.348507,6.164701 50.348610,
    6.164615 50.348647,6.164551 50.348648,6.164478 50.348614,6.164421 50.348548,
    6.164276 50.348484,6.164164 50.348471,6.163996 50.348468,6.163919 50.348550,
    6.163863 50.348572,6.163808 50.348577,6.163727 50.348548,6.163678 50.348498,
    6.163636 50.348417,6.163546 50.348301,6.163457 50.348267,6.163337 50.348254,
    6.163249 50.348235,6.163192 50.348200,6.163175 50.348139,6.163206 50.348103,
    6.163278 50.348102,6.163446 50.348130,6.163557 50.348139,6.163637 50.348122,
    6.163644 50.348092,6.163602 50.348026,6.163482 50.347982,6.163393 50.347922,
    6.163316 50.347907,6.163249 50.347894,6.163026 50.347907,6.162725 50.347983,
    6.162319 50.348029,6.161930 50.348081,6.161645 50.348130,6.161526 50.348183,
    6.161512 50.348265,6.161593 50.348304,6.161667 50.348379,6.161693 50.348491,
    6.161736 50.348587,6.161817 50.348662,6.161922 50.348691,6.162050 50.348720,
    6.162050 50.348735,6.161963 50.348757,6.161933 50.348833,6.161871 50.348885,
    6.161744 50.348928,6.161435 50.348978,6.161293 50.349026,6.161262 50.349067,
    6.161264 50.349148,6.161194 50.349225,6.161180 50.349297,6.161246 50.349372,
    6.161271 50.349438,6.161194 50.349536,6.161059 50.349568,6.160987 50.349549,
    6.160953 50.349478,6.160949 50.349300,6.160915 50.349240,6.160850 50.349185,
    6.160730 50.349156,6.160627 50.349173,6.160470 50.349292,6.160369 50.349380,
    6.160331 50.349451,6.160316 50.349482,6.160268 50.349488,6.160219 50.349443,
    6.160131 50.349434,6.160045 50.349506,6.159926 50.349539,6.159839 50.349530,
    6.159669 50.349466,6.159493 50.349428,6.159278 50.349411,6.159237 50.349381,
    6.159220 50.349325,6.159266 50.349278,6.159322 50.349278,6.159426 50.349292,
    6.159594 50.349325,6.159649 50.349304,6.159640 50.349243,6.159567 50.349193,
    6.159326 50.349130,6.159142 50.349107,6.159078 50.349078,6.159068 50.348986,
    6.159074 50.348925,6.159050 50.348895,6.158905 50.348841,6.158722 50.348844,
    6.158532 50.348908,6.158368 50.349032,6.158345 50.349088,6.158319 50.349297,
    6.158201 50.349375,6.158122 50.349392,6.158057 50.349377,6.157977 50.349353,
    6.157874 50.349370,6.157565 50.349466,6.156989 50.349667,6.156790 50.349685,
    6.156702 50.349682,6.156550 50.349648,6.156383 50.349651,6.156230 50.349612,
    6.156095 50.349599,6.156040 50.349635,6.156025 50.349706,6.156059 50.349777,
    6.156188 50.349852,6.156246 50.349912,6.156208 50.350009,6.156130 50.350051,
    6.155971 50.350089,6.155940 50.350120,6.155925 50.350155,6.155975 50.350221,
    6.156137 50.350300,6.156140 50.350407,6.156118 50.350504,6.155938 50.350633,
    6.155742 50.350763,6.155647 50.350780,6.155559 50.350771,6.155486 50.350737,
    6.155469 50.350686,6.155491 50.350604,6.155552 50.350507,6.155549 50.350380,
    6.155522 50.350304,6.155438 50.350290,6.155343 50.350321,6.155273 50.350387,
    6.155197 50.350465,6.155157 50.350534,6.155038 50.350574,6.154890 50.350603,
    6.154675 50.350606,6.154411 50.350587,6.154088 50.350565,6.153878 50.350522,
    6.153637 50.350468,6.153367 50.350438,6.153135 50.350464,6.152772 50.350519,
    6.152581 50.350529,6.152377 50.350513,6.152038 50.350445,6.151744 50.350396,
    6.151587 50.350356,6.151550 50.350303,6.151542 50.350239,6.151512 50.350193,
    6.151445 50.350168,6.151355 50.350157,6.151240 50.350087,6.151102 50.350073,
    6.150917 50.350095,6.150792 50.350104,6.150714 50.350075,6.150634 50.349996,
    6.150627 50.349950,6.150590 50.349901,6.150529 50.349879,6.150368 50.349897,
    6.150267 50.349894,6.150194 50.349846,6.150180 50.349781,6.150184 50.349697,
    6.150176 50.349613,6.150113 50.349504,6.149984 50.349418,6.149737 50.349330,
    6.149503 50.349287,6.149288 50.349290,6.149097 50.349335,6.148890 50.349407,
    6.148666 50.349521,6.148502 50.349660,6.148486 50.349725,6.148511 50.349778,
    6.148572 50.349823,6.148609 50.349869,6.148610 50.349918,6.148546 50.349988,
    6.148392 50.350043,6.148126 50.350150,6.148036 50.350163,6.147970 50.350145,
    6.147957 50.350111,6.147966 50.349973,6.148038 50.349770,6.148167 50.349673,
    6.148279 50.349599,6.148290 50.349545,6.148252 50.349465,6.148161 50.349425,
    6.148065 50.349403,6.147947 50.349455,6.147900 50.349509,6.147801 50.349609,
    6.147620 50.349791,6.147555 50.349811,6.147460 50.349839,6.147366 50.349909,
    6.147313 50.349948,6.147236 50.349957,6.147140 50.349947,6.147079 50.349902,
    6.147053 50.349811,6.147002 50.349701,6.146936 50.349675,6.146846 50.349684,
    6.146745 50.349712,6.146603 50.349764,6.146472 50.349781,6.146251 50.349761,
    6.146131 50.349778,6.146037 50.349818,6.146020 50.349871,6.146045 50.349909,
    6.146154 50.349965,6.146317 50.350031,6.146426 50.350068,6.146450 50.350105,
    6.146409 50.350140,6.146338 50.350145,6.146145 50.350094,6.145899 50.350045,
    6.145797 50.350046,6.145709 50.350085,6.145675 50.350189,6.145671 50.350258,
    6.145624 50.350293,6.145487 50.350321,6.145290 50.350324,6.145153 50.350318,
    6.145026 50.350282,6.144929 50.350207,6.144856 50.350159,6.144754 50.350149,
    6.144653 50.350165,6.144504 50.350206,6.144427 50.350214,6.144349 50.350200,
    6.144249 50.350143)

  • Oracle bind variable

    Can i use an item which type is image as bind variable in the insert statement?
    When i pass image item of oracle form as a bind variable in the insert statement then "Bad bind variable error" occurs.
    Please help me.
    - ashraf

    Hello,
    No, you cannot. If the image item points to a database BLOB column, Forms will store the image in this column at commit time.
    Francois

  • How to update bind variable and restrict values in a Model Driven LOV?

    Hi Guys,
    Using JDev 11.1.1.2.0
    I've recreated an excellent Frank Nimphius article about restricting values derived from a model driven LOV (http://www.oracle.com/technetwork/developer-tools/adf/learnmore/44-restrict-lov-169186.pdf)
    But my bind variable isn't updating. Deleting the bind variable gets me the entire LOV. Activate the code below and insert a bind variable into the where clause like Frank says and I get nothing back. Bind variable is blank. Any ideas? Code wasn't supplied with the article. It seems simple enough but the bind variable isn't updating in the SQL, even though the updated value shows up here...
      public void onLovLaunch(LaunchPopupEvent launchPopupEvent)
        BindingContext bctx = BindingContext.getCurrent();
        BindingContainer bindings = bctx.getCurrentBindingsEntry();
        FacesCtrlLOVBinding lov = (FacesCtrlLOVBinding)bindings.get("DepartmentId");
        lov.getListIterBinding().getViewObject().setNamedWhereClauseParam("deptId","60");
        System.out.println("lov name: " + lov.getName().toString());
        System.out.println("lov Param Attrs: " + lov.getListIterBinding().getViewObject().getNamedWhereClauseParams().getAttribute("deptId").toString());
        System.out.println("lov View Object: " + lov.getListIterBinding().getViewObject().getName().toString());
        System.out.println("lov IterBinding: " + lov.getListIterBinding().getName().toString());
       }Gets me ...
    lov name: DepartmentId
    lov Param Attrs: 60
    lov View Object: _LOCAL_VIEW_USAGE_lov_model_queries_EmployeesView_DepartmentsView
    lov IterBinding: DepartmentIdList_2

    That's a good idea, but it's still not working. Here is how I implemented it. It might be different from your suggestion as I'm still pretty new to this.
    I have a recursive tree table. You select a node. You then click a button which calls the listener below. "findParents" is a method call to the AppModuleImpl class and it finds all parent nodes of your selection. "restrictPartBomLOV", also of the AppModuleImpl class, then modifies the model driven lists' View Object (partBomLOV) to exclude those parent node values.
    The resulting model driven LOV on the popup should be updated, yeah? But it still isn't udpating. If I manually type in the updated Where clause in PartBomLOV.xml query tab, it works, but it doesn't programmatically.
      public void insertPopupFetchListener(PopupFetchEvent popupFetchEvent)
        BindingContainer bindings = getBindings();
        OperationBinding operationBinding = bindings.getOperationBinding("findParents");
        parents = (List)operationBinding.execute();
        operationBinding = bindings.getOperationBinding("restrictPartBomLOV");
        operationBinding.execute();
       public void restrictPartBomLOV(List parents)
          ViewObjectImpl vo = getPartBomLOV();
          String wcl = "";
          Object[]   p = parents.toArray();
          for(int i = 0; i < p.length; i++)
             if (i == 0)
                wcl = wcl + "PNUM <> '" + p.toString() + "'";
    else
    wcl = wcl + "AND PNUM <> '" + p[i].toString() + "'";
    vo.setWhereClause(wcl);
    System.out.println(vo.getWhereClause().toString());
    vo.executeQuery();
    Edited by: LovettWB on Nov 11, 2010 11:23 PM

  • Can Oracle convert literals to bind variables?

    Good morning everyone.
    I have a procedure similar to this in our database:
        FUNCTION Get_Tag_Element_Id_For_Set(Element_Attr_Id_Table_In   in    ATTRIBUTE_TABLE_ID_TAB) RETURN NUMBER IS
          v_Select_Statement                    VARCHAR2(32767);
          v_Element_Id                             ELEMENT.Element_Id%TYPE;
        BEGIN
          FOR I IN 1..Element_Attr_Id_Table_In.COUNT LOOP
            IF v_Select_Statement IS NULL THEN
              v_Select_Statement := 'SELECT distinct Element_Id FROM ELEMENT_ATTRIBUTE_MANY_2_MANY WHERE Element_Attribute_Id = ' || Element_Attr_Id_Tab_In(i);
            ELSE
              v_Select_Statement := v_Select_Statement || ' intersect ' ||
                                    'SELECT distinct Element_Id FROM ELEMENT_ATTRIBUTE_MANY_2_MANY WHERE Element_Attribute_Id = ' || Element_Attr_Id_Table_In(i);
            END IF;
          END LOOP;
          EXECUTE IMMEDIATE v_Select_Statement INTO v_Element_id;
          RETURN v_Element_Id;
        END;What this does is to create a query similar to this:
    SELECT distinct Element_Id FROM ELEMENT_ATTRIBUTE_MANY_2_MANY WHERE Tag_Element_Attribute_Id = 1 intersect
    SELECT distinct Element_Id FROM ELEMENT_ATTRIBUTE_MANY_2_MANY WHERE Tag_Element_Attribute_Id = 2 intersect
    SELECT distinct Element_Id FROM ELEMENT_ATTRIBUTE_MANY_2_MANY WHERE Tag_Element_Attribute_Id = 3 intersect
    SELECT distinct Element_Id FROM ELEMENT_ATTRIBUTE_MANY_2_MANY WHERE Tag_Element_Attribute_Id = 4 intersect
    SELECT distinct Element_Id FROM ELEMENT_ATTRIBUTE_MANY_2_MANY WHERE Tag_Element_Attribute_Id = 5;
    I am using Dynamic SQL because the number of intersect pieces can vary from 1 to 15 and in the future it can grow.
    The problem that I have is that because the literals are part of the string, the query is being hard parsed every single time. In our production environment this means 100s of thousands of times per day which according to our DBA has added 15% plus to our average load. I know that I can come up with a rewrite to avoid this, but I was wondering if there is a parameter I can set at the session or at the database level where the database itself can convert this kind of query into one with bind variables.
    Thanks,
    Tom
    Edited by: Thomas Morgan on May 3, 2013 8:21 PM

    Thomas Morgan wrote:
    Basically I have an XML document.
    The document has ELEMENTS.
    ELEMENTS can have attributes.
    There is a many to many relationship between ELEMENT and ATTRIBUTES so I have a XREF table to represent this relationship.
    When I receive a new document, I need to determine if a group of ATTRIBUTES already exist together in the XREF table so I have to find their common ELEMENT_ID or NULL in which case I would create a new ELEMENT and associate the new set of attributes to the new ELEMENT.
    Since the number of attributes can vary from 1 to around 15 for now, I had to dynamically build the query that find the common ID(intersect) if it exists.
    Here is some DDL and inserts:
    CREATE TABLE ELEMENT(ELEMENT_ID NUMBER NOT NULL);
    CREATE TABLE ELEMENT_ELEMENT_ATTRIBUTE_XREF(Element_Id NUMBER NOT NULL, Element_Attribute_Id NUMBER NOT NULL);
    ALTER TABLE ELEMENT_ELEMENT_ATTRIBUTE_XREF ADD CONSTRAINT ELEMENT_ATTR_MANY_2_MANY_PK PRIMARY KEY(Element_Id, Element_Attribute_Id);
    ALTER TABLE ELEMENT ADD CONSTRAINT ELEMENT_PK PRIMARY KEY(Element_Id);
    INSERT INTO ELEMENT VALUES(1);
    INSERT INTO ELEMENT VALUES(2);
    INSERT INTO ELEMENT VALUES(3);
    INSERT INTO ELEMENT VALUES(4);
    INSERT INTO ELEMENT_ELEMENT_ATTRIBUTE_XREF VALUES(1, 1);
    INSERT INTO ELEMENT_ELEMENT_ATTRIBUTE_XREF VALUES(1, 2);
    INSERT INTO ELEMENT_ELEMENT_ATTRIBUTE_XREF VALUES(2, 1);
    INSERT INTO ELEMENT_ELEMENT_ATTRIBUTE_XREF VALUES(3, 1);
    INSERT INTO ELEMENT_ELEMENT_ATTRIBUTE_XREF VALUES(3, 3);
    INSERT INTO ELEMENT_ELEMENT_ATTRIBUTE_XREF VALUES(3, 4);
    INSERT INTO ELEMENT_ELEMENT_ATTRIBUTE_XREF VALUES(3, 5);
    INSERT INTO ELEMENT_ELEMENT_ATTRIBUTE_XREF VALUES(4, 6);
    INSERT INTO ELEMENT_ELEMENT_ATTRIBUTE_XREF VALUES(4, 7);
    So for instance if I passed an array (Attribute ID Tab) containing ELEMENT_ATTRIBUTE_ID list 6 and 7 I would get 4 as the answer.
    Hope this helps,
    Thanks,
    TomAwesome, thanks!
    I'm not sure this works 100% for what you need, but I thought I'd give it a shot. I've used a built in array (sys.odcinumberlist) that you should have access to on your installation (assuming you have a relatively recent version of Oracle).
    I left out the part where you would loop through the array you are currently passing in to your procedure to build up this new array that you can use in a SQL statement.
    Cheers,
    create or replace procedure maybe_this
       in_list           sys.odcinumberlist
    is
       l_commonality     number;
    begin
       begin
          select
             distinct
                xref.element_id
          into
             l_commonality
          from
                table(cast(in_list as sys.odcinumberlist))  list
            ,  element_element_attribute_xref   xref
          where
             xref.element_attribute_id = list.column_value;
          dbms_output.put_line('match on element_id = ' || l_commonality);
       exception
          when too_many_rows or no_data_found
          then
             dbms_output.put_line('no match');
       end;
    end;
    ME_TUBBZ?exec maybe_this(sys.odcinumberlist(1,2));
    no match
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.01
    ME_TUBBZ?exec maybe_this(sys.odcinumberlist(6,7));
    match on element_id = 4
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.01

  • SLOW report performance with bind variable

    Environment: 11.1.0.7.2, Apex 4.01.
    I've got a simplified report page where the report runs slowly compared to running the same query in sqldeveloper. The report region is based on a pl/sql function returning a query. If I use a bind variable in the query inside apex it takes 13 seconds to run, and if I hard code a string it takes only a few hundredths of a second. The query returns one row from a table which has 1.6 million rows. Statistics are up-to-date and the columns in the joins and where clause are indexed.
    I've run traces using p_trace=YES from Apex for both the bind variable and hard coded strings. They are below.
    The sqldeveloper explain plan is identical to the bind variable plan from the trace, yet the query runs in 0.0x seconds in sqldeveloper.
    What is it about bind variable syntax in Apex that is causing the bad execution plan? Apex Bug? 11g bug? Ideas?
    tkprof output from Apex trace with bind variable is below...
    select p.master_id link, p.first_name||' '||p.middle_name||' '||p.last_name||' '||p.suffix personname,
    p.gender||' '||p.date_of_birth g_dob, p.master_id||'*****'||substr(p.ssn,-4) ssn, p.status status
    from persons p
    where
       p.person_id in (select ps.person_id from person_systems ps where ps.source_key  like  LTRIM(RTRIM(:P71_SEARCH_SOURCE1)))
    order by 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.01          0          1         27           0
    Fetch        2     13.15      13.22      67694      72865          0           1
    total        4     13.15      13.23      67694      72866         27           1
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 62  (ODPS_PRIVACYVAULT)   (recursive depth: 1)
    Rows     Row Source Operation
          1  SORT ORDER BY (cr=72869 pr=67694 pw=0 time=0 us cost=29615 size=14255040 card=178188)
          1   FILTER  (cr=72869 pr=67694 pw=0 time=0 us)
          1    HASH JOIN RIGHT SEMI (cr=72865 pr=67694 pw=0 time=0 us cost=26308 size=14255040 card=178188)
          1     INDEX FAST FULL SCAN IDX$$_0A300001 (cr=18545 pr=13379 pw=0 time=0 us cost=4993 size=2937776 card=183611)(object id 68485)
    1696485     TABLE ACCESS FULL PERSONS (cr=54320 pr=54315 pw=0 time=21965 us cost=14958 size=108575040 card=1696485)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          1   SORT (ORDER BY)
          1    FILTER
          1     HASH JOIN (RIGHT SEMI)
          1      INDEX   MODE: ANALYZED (FAST FULL SCAN) OF
                     'IDX$$_0A300001' (INDEX)
    1696485      TABLE ACCESS   MODE: ANALYZED (FULL) OF 'PERSONS' (TABLE)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file scattered read                       1276        0.00          0.16
      db file sequential read                       812        0.00          0.02
      direct path read                             1552        0.00          0.61
    ********************************************************************************Here's the tkprof output with a hard coded string:
    select p.master_id link, p.first_name||' '||p.middle_name||' '||p.last_name||' '||p.suffix personname,
    p.gender||' '||p.date_of_birth g_dob, p.master_id||'*****'||substr(p.ssn,-4) ssn, p.status status
    from persons p
    where
       p.person_id in (select ps.person_id from person_systems ps where ps.source_key  like  LTRIM(RTRIM('0b')))
    order by 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.02       0.04          0          0          0           0
    Execute      1      0.00       0.00          0          0         13           0
    Fetch        2      0.00       0.00          0          8          0           1
    total        4      0.02       0.04          0          8         13           1
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 62  (ODPS_PRIVACYVAULT)   (recursive depth: 1)
    Rows     Row Source Operation
          1  SORT ORDER BY (cr=10 pr=0 pw=0 time=0 us cost=9 size=80 card=1)
          1   FILTER  (cr=10 pr=0 pw=0 time=0 us)
          1    NESTED LOOPS  (cr=8 pr=0 pw=0 time=0 us)
          1     NESTED LOOPS  (cr=7 pr=0 pw=0 time=0 us cost=8 size=80 card=1)
          1      SORT UNIQUE (cr=4 pr=0 pw=0 time=0 us cost=5 size=16 card=1)
          1       TABLE ACCESS BY INDEX ROWID PERSON_SYSTEMS (cr=4 pr=0 pw=0 time=0 us cost=5 size=16 card=1)
          1        INDEX RANGE SCAN IDX_PERSON_SYSTEMS_SOURCE_KEY (cr=3 pr=0 pw=0 time=0 us cost=3 size=0 card=1)(object id 68561)
          1      INDEX UNIQUE SCAN PK_PERSONS (cr=3 pr=0 pw=0 time=0 us cost=1 size=0 card=1)(object id 68506)
          1     TABLE ACCESS BY INDEX ROWID PERSONS (cr=1 pr=0 pw=0 time=0 us cost=2 size=64 card=1)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
          1   SORT (ORDER BY)
          1    FILTER
          1     NESTED LOOPS
          1      NESTED LOOPS
          1       SORT (UNIQUE)
          1        TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF
                       'PERSON_SYSTEMS' (TABLE)
          1         INDEX   MODE: ANALYZED (RANGE SCAN) OF
                        'IDX_PERSON_SYSTEMS_SOURCE_KEY' (INDEX)
          1       INDEX   MODE: ANALYZED (UNIQUE SCAN) OF 'PK_PERSONS'
                      (INDEX (UNIQUE))
          1      TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF
                     'PERSONS' (TABLE)

    Patrick, interesting insight. Thank you.
    The optimizer must be peeking at my bind variables with it's eyes closed. I'm the only one testing and I've never passed %anything as a bind value. :)
    Here's what I've learned since my last post:
    I don't think that sqldeveloper is actually using the explain plan it says it is. When I run explain plan in sqldeveloper (with a bind variable) it shows me the exact same plan as Apex with a bind variable. However, when I run autotrace in sqldeveloper, it takes a path that matches the hard coded values, and returns results in half a second. That autotrace run is consistent with actually running the query outside of autotrace. So, I think either sqldeveloper isn't really using bind variables, OR it is using them in some other way that Apex does not, or maybe optimizer peeking works in sqldeveloper?
    Using optimizer hints to tweak the plan helps. I've tried both /*+ FIRST_ROWS */ and /*+ index(ps pk_persons) */ and both drop the query to about a second. However, I'm loath to use hints because of the very dynamic nature of the query (and Tom Kyte doesn't like them either). The hints may end up hurting other variations on the query.
    I also tested the query by wrapping it in a select count(1) from ([long query]) and testing the performance in sqldeveloper and in Apex. The performance in that case is identical with both bind variables and hard coded variables for both Apex and SqlDeveloper. That to me was very interesting and I went so far as to set up two bind variable report regions on the same page. One region wrapped the long query with select count(1) from (...) and the other didn't. The wrapped query ran in 0.01 seconds, the unwrapped took 15ish seconds with no other optimizations. Very strange.
    To get performance up to acceptable levels I have changed my function returning query to:
    1) Set the equality operator to "=" for values without wildcards and "like" for user input with wildcards. This makes a HUGE difference IF no wildcard is used.
    2) Insert a /*+ FIRST_ROWS */ hint when users chose the column that requires the sub-query. This obviously changes the optimizer's plan and improves query speed from 15 seconds to 1.5 seconds even with wildcards.
    I will NOT be hard coding any user supplied values in the query string. As you can probably tell by the query, this is an application where sql injection would be very bad.
    Jeff, regarding your question about "like '%' || :P71_SEARCH_SOURCE1 || '%'". I've found that putting wildcards around values, particularly at the beginning will negate any indexing on the column in question and slows performance even more.
    I'm still left wondering if there isn't something in Apex that is breaking the optimizer "peeking" that Patrick describes. Perhaps something in the way it switches contexts from apex_public_user to the workspace schema?

  • ADF Groovy Expression with bind variable and ResourceBundle

    Now I have ViewObject which have WHERE clause with bind variable.
    This bind variable is for language. Within bind variable I can change Value Type to Expression and into Value: I put +(ResourceBundle.getBundle("model.ModelBundle")).getString("language")+.
    Now if I run Oracle Business Component Browser (on AppModule) this works. In my ModelBundle.properties there is language=1 name-value pair. And with different locale I have different language number.
    Now if I put that ViewObject on one JSF, this bind variable expression does not work any more. Error:
    *oracle.jbo.JboException: JBO-29000: Unexpected exception caught: java.util.MissingResourceException, msg=Can't find bundle for base name model.ModelBundle, locale my_locale*
    Any ideas?
    10x
    Zmeda

    The most wierd thing is that, if I make ViewObjectImpl and insert this method
    public String getLanguage() {
    return (ResourceBundle.getBundle("model.ModelBundle")).getString("language");
    and call it in Bind Variable Expression Value: viewObject.getLanguage()
    IT WORKS!
    But why with groovy expression it does not work?
    Zmeda

  • SQL query with Bind variable with slower execution plan

    I have a 'normal' sql select-insert statement (not using bind variable) and it yields the following execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=7 Card=1 Bytes=148)
    1 0 HASH JOIN (Cost=7 Card=1 Bytes=148)
    2 1 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=4 Card=1 Bytes=100)
    3 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=3 Card=1)
    4 1 INDEX (FAST FULL SCAN) OF 'TABLEB_IDX_003' (NON-UNIQUE)
    (Cost=2 Card=135 Bytes=6480)
    Statistics
    0 recursive calls
    18 db block gets
    15558 consistent gets
    47 physical reads
    9896 redo size
    423 bytes sent via SQL*Net to client
    1095 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    I have the same query but instead running using bind variable (I test it with both oracle form and SQL*plus), it takes considerably longer with a different execution plan:-
    Execution Plan
    0 INSERT STATEMENT Optimizer=CHOOSE (Cost=407 Card=1 Bytes=148)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'TABLEA' (Cost=3 Card=1 Bytes=100)
    2 1 NESTED LOOPS (Cost=407 Card=1 Bytes=148)
    3 2 INDEX (FAST FULL SCAN) OF TABLEB_IDX_003' (NON-UNIQUE) (Cost=2 Card=135 Bytes=6480)
    4 2 INDEX (RANGE SCAN) OF 'TABLEA_IDX_2' (NON-UNIQUE) (Cost=2 Card=1)
    Statistics
    0 recursive calls
    12 db block gets
    3003199 consistent gets
    54 physical reads
    9448 redo size
    423 bytes sent via SQL*Net to client
    1258 bytes received via SQL*Net from client
    3 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    55 rows processed
    TABLEA has around 3million record while TABLEB has 300 records. Is there anyway I can improve the speed of the sql query with bind variable? I have DBA Access to the database
    Regards
    Ivan

    Many thanks for your reply.
    I have run the statistic already for the both tableA and tableB as well all the indexes associated with both table (using dbms_stats, I am on 9i db ) but not the indexed columns.
    for table I use:-
    begin
    dbms_stats.gather_table_stats(ownname=> 'IVAN', tabname=> 'TABLEA', partname=> NULL);
    end;
    for index I use:-
    begin
    dbms_stats.gather_index_stats(ownname=> 'IVAN', indname=> 'TABLEB_IDX_003', partname=> NULL);
    end;
    Is it possible to show me a sample of how to collect statisc for INDEX columns stats?
    regards
    Ivan

  • Bind Variables in SPARQL Queries

    Hi,
    I am interested in bind variables and their use between queries, however while I see the concept behind the example given in the documentation (http://docs.oracle.com/cd/E11882_01/appdev.112/e25609/sem_jena.htm#autoId15) I am not able to grasp how to exactly pass the results of a query_1 for an ?x variable to another query query_2.
    Would it be possible to offer a more detailed explanation and a working simple code about how to do this using Jena Adapater.
    Thank you.

    Hi,
    I am using the Java API to run SPARQL update queries, this is an example of what I am trying to achieve :
    public static void runTestUpdateBinding() throws SQLException {
        String[] modelNames = new String[] { };
        String[] rulebases = new String[] { };
        OracleDataSource ods = new OracleDataSource();
        ods.setURL("ORACLE CONNECTION STRING");
        OracleConnection oc = (OracleConnection)ods.getConnection();
        Oracle oracle = new Oracle(oc);
        Attachment attachment =
            Attachment.createInstance(modelNames, rulebases, InferenceMaintenanceMode.NO_UPDATE, QueryOptions.ALLOW_QUERY_INVALID_AND_DUP);
        GraphOracleSem graph = new GraphOracleSem(oracle, "in_oracle", attachment, true);
        ModelOracleSem model = new ModelOracleSem(graph);
        //Insert few triples
        String updateQuery = "INSERT DATA {                                        " +
                             "  <http://sub/a>  <http://pred/a>  <http://obj/a> .\n" +
                             "  <http://sub/b>  <http://pred/b>  <http://obj/b> .\n" +
                             "  <http://sub/c>  <http://pred/c>  <http://obj/c>    " +
        UpdateAction.parseExecute(updateQuery, model);
        //Run the update query
        updateQuery = "PREFIX    ORACLE_SEM_UEAP_NS:    <http://oracle.com/semtech#s$RDFVID%20IN(ORACLE_ORARDF_RES2VID(?),ORACLE_ORARDF_RES2VID(?))> \n" +
                      "PREFIX    ORACLE_SEM_UEPJ_NS:    <http://oracle.com/semtech#s$RDFVID> \n" +
                      "PREFIX    ORACLE_SEM_UEBV_NS:    <http://oracle.com/semtech#http%3A%2F%2Fsub%2Fa,http%3A%2F%2Fsub%2Fc> \n" +
                      "INSERT { <http://sub/UPDATED_SUBJECT>    ?p    ?o } \n" +
                      "WHERE  { ?s    ?p    ?o }";
        UpdateAction.parseExecute(updateQuery, model);
        model.close();
    Basically, I am expecting only "<http://sub/a>  <http://pred/a>  <http://obj/a>" and "<http://sub/c>  <http://pred/c>  <http://obj/c>" to match, however, "<http://sub/b>  <http://pred/b>  <http://obj/b>" also matches as you can see from the following results
    | s                            | p               | o              |
    ===================================================================
    | <http://sub/c>               | <http://pred/c> | <http://obj/c> |
    | <http://sub/UPDATED_SUBJECT> | <http://pred/c> | <http://obj/c> |
    | <http://sub/b>               | <http://pred/b> | <http://obj/b> |
    | <http://sub/UPDATED_SUBJECT> | <http://pred/b> | <http://obj/b> |
    | <http://sub/a>               | <http://pred/a> | <http://obj/a> |
    | <http://sub/UPDATED_SUBJECT> | <http://pred/a> | <http://obj/a> |
    Also, in the underlying generated SQL, there is no restriction on s$RDFVID as in SELECT queries (i.e: ...where (s$RDFVID IN(ORACLE_ORARDF_RES2VID(?),ORACLE_ORARDF_RES2VID(?))) )

  • $a_report to refresh a report but it is not picking up the bind variable

    Hi
    APEX          -     Application Express 4.1.0
    Browsers     -     All
    Database     -     11g2
    I have a tree region on a page. When a user clicks a leaf of the tree I want to be able to use the ID to refresh a report in a different region on the same page
    Code for when the user clicks the leaf
    $('div.tree li a').click( function() {
    node_id = $(this).parents('li:first').attr('id');
    if (node_id.substr(0,node_id.indexOf('|')) == 'Y')
    $s('P4_SELECTED_VALUE',node_id.substr(node_id.indexOf('|')+1));
    alert('Value Set: ' + $v('P4_SELECTED_VALUE'));
    //$a_report('28576803999973770','1','20','20');
    $a_report($v('P4_REPORT_ID'),'1','20','20');
    SQL Statement
    SELECT *
    FROM PRODS p WHERE PROD_CODE = :P4_SELECTED_VALUE
    The problem I have is that when the report is run (I know it is refreshing) the P4_SELECTED_VALUE bind variable is set to NULL.
    The alert pop contains the correct value and when I make the P4_SELECTED_VALUE visible it also contains the value?
    Any help is much appreciated
    Rob

    Rob,
    You need to insert P4_SELECTED_VALUE value into APEX session before refreshing the report.
    Add following JS function in your page
    //insert value into session using JS
    function fnSetSessionState(pItem, pValue) {
        var vAjaxDummy = new htmldb_Get(null, $v('pFlowId'), null, 0);
        vAjaxDummy.add(pItem, pValue);
        var vDummy = vAjaxDummy.get();
        vAjaxDummy = null;
    }and your code..
    $('div.tree li a').click( function() {
    node_id = $(this).parents('li:first').attr('id');
    if (node_id.substr(0,node_id.indexOf('|')) == 'Y')
    $s('P4_SELECTED_VALUE',node_id.substr(node_id.indexOf('|')+1));
    alert('Value Set: ' + $v('P4_SELECTED_VALUE'));
    fnSetSessionState('P4_SELECTED_VALUE',$v('P4_SELECTED_VALUE'));
    //$a_report('28576803999973770','1','20','20');
    $a_report($v('P4_REPORT_ID'),'1','20','20');
    });This is how I used to do in version 3.2 or before. But now I prefer to use Declarative dynamic actions..
    Regards,
    Hari

  • Bind Variable in SELECT statement and get the value  in PL/SQL block

    Hi All,
    I would like  pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
    Please seee below
    I want to get the below value
    Expected result:
    select  distinct empno ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    100, HR
    select  distinct ename ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    TEST, HR
    select  distinct loc ,pr.dept   from emp pr, dept ps where   ps.dept like '%IT'  and pr.empno =100
    NYC, HR
    Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
    Please suggest
    ----- TABLE LIST
    CREATE TABLE EMP(
    EMPNO NUMBER,
    ENAME VARCHAR2(255),
    DEPT VARCHAR2(255),
    LOC    VARCHAR2(255)
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
    INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
    COMMIT;
    CREATE TABLE COLUMNAMES(
    COLUMNAME VARCHAR2(255)
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
    INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
    COMMIT;
    CREATE TABLE DEPT(
    DEPT VARCHAR2(255),
    DNAME VARCHAR2(255)
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
    INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
    COMMIT;
    PL/SQL BLOCK
    DECLARE
      TYPE EMPCurTyp  IS REF CURSOR;
      v_EMP_cursor    EMPCurTyp;
      l_col_val           EMP.ENAME%type;
      l_ENAME_val       EMP.ENAME%type;
    l_col_ddl varchar2(4000);
    l_col_name varchar2(60);
    l_tab_name varchar2(60);
    l_empno number ;
    b_l_col_name VARCHAR2(255);
    b_l_empno NUMBER;
    begin
    for rec00 in (
    select EMPNO aa from  EMP
    loop
    l_empno := rec00.aa;
    for rec in (select COLUMNAME as column_name  from  columnames
    loop
    l_col_name := rec.column_name;
    begin
      l_col_val :=null;
       l_col_ddl := 'select  distinct :b_l_col_name ,pr.dept ' ||'  from emp pr, dept ps where   ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
       dbms_output.put_line('DDL ...'||l_col_ddl);
       OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
    LOOP
        l_col_val :=null;
        FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
        EXIT WHEN v_EMP_cursor%NOTFOUND;
          dbms_output.put_line('l_col_name='||l_col_name ||'  empno ='||l_empno);
       END LOOP;
    CLOSE v_EMP_cursor;
    END;
    END LOOP;
    END LOOP;
    END;

    user1758353 wrote:
    Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
    As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
    However, the data structures are just that - structured. Logical.
    Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
    There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model.

  • Using Bind Variable in a SELECT

    Hi,
    I'm trying to build up my SQL query at run-time using bind variables and in the Oracle® Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1) it says that 'After defining the bind variables, the next step is to reference them in the SQL statement. While SQL syntax allows bind variables to appear both in the SELECT list and in the WHERE clause, you'll typically use them in the latter context, as part of your WHERE clause.'.
    However, when I try to use the bind variables in my SELECT list because I've had to set a type for the variable to String the variable gets inserted with inverted commas either side e.g. SELECT 'Service' FROM TestTable. Is it possible to use bind variables to insert a value into my select list without these inverted commas around it?
    Thanks in advance,
    Tom

    OK, thanks for your response. Do you know of a way then where I can control my SELECT parameters programmatically? I'm currently trying to do it using the information in the chapter '35.9 Using Programmatic View Objects for Alternative Data Sources' from the Oracle® Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework 11g Release 1 (11.1.1). I think I'm part way there, would this be the correct way of acheiving what I want?
    Cheers, Tom

  • A problem with bind variables in a shuttle

    Hi
    After days of research I cannot come up with a solution to this problem which I hope will be easy to describe.
    I'm working on an apex.oracle.com workspace (4.02).
    I have a page with
    a) a region with tree which works well populated by a list of roles and users
    b) a region with a shuttle with the following sql
    List of values
    select SOB_DISPNAME, SOB_ID
    from VIEW_SYSTEMOBJECT
    order by SOB_DISPNAME
    Source
    SELECT SOB_ID FROM VIEW_OBJECTSECURITY_GRANTED WHERE U_ID = :P19_SELECTED_ID
    :P19_SELECTED_ID is a hidden textbox with the currently selected users id.
    The above works very well - I select a user from the tree and the shuttle lhs populates with unselected object names and the rhs with objects selected for the user. A submit button drives a page process which clears out and then inserts the selection into a the table (objectsecurity)
    So far so good.
    I added a list box to the shuttle region (:P19_SOB_TYPE_LIST) so that the data being worked on could be filtered by type, its driven by a LOV that produces a value or 'PAGE', 'REPORT' ... etc.
    I updated the above SQL to be
    List of Values
    select SOB_DISPNAME, SOB_ID
    from VIEW_SYSTEMOBJECT WHERE SOB_TYPE = :P19_SOB_TYPE_LIST
    order by SOB_DISPNAME
    and the source
    SELECT SOB_ID FROM VIEW_OBJECTSECURITY_GRANTED WHERE U_ID = :P19_SELECTED_ID AND SOB_TYPE = :P19_SOB_TYPE_LIST
    So now I would expect that if 'PAGE' is selected in the list box then only objects that are pages will be seen.
    However nothing at all appears.
    If I substitute the bind variable :P19_SOB_TYPE_LIST for 'PAGE' ... WHERE SOB_TYPE = 'PAGE' it works perfectly. So why does :P19_SELECTED_ID do it's job but not P19_SOB_TYPE_LIST ?
    I am probably making some ridiculously simple mistake but I just cannot spot it; is my syntax wrong?.
    The session state is persisting so that I can see the value of :P19_SOB_TYPE_LIST being set to PAGE
    Any help with this would be very much appreciated.

    Hi Dirk
    Thanks for that which looked promising!
    I added P19_SOB_TYPE_LIST as the Cascading LOV Parent Item and removed it from the where clauses of both SQL's and the result was that all types are shown; corresponding to my original position.
    I then added the where clause back to the LOV SQL and both shuttle boxes are blank again
    I added back to the source SQL and again both boxes empty
    Finally I removed the where clause from the LOV SQL (the only other combination) and again lhs box populated with all rows (not filtered) and rhs box blank.
    So unfortunately that doesn't seem to have fixed it.
    Many thanks for the help and any more will be greatly appreciated.
    Regards
    Charles

  • Asking for bind variable where none is needed

    Good Morning,
    I am still working these regexp date_time project.
    I have a problem where oracle is asking for a bind variable where it doesn't need any as far as I can see. I am trying to capture various date times in a column and formatting them into one default format used by oracle. Here is what I got which works before I wrap it in the TO_DATE function
    There are many when then's but I am using only one here.
    select case
    when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
    then regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')
    else date_time
    end as new_time
    from raw_data;
    The above statement works
    Now when I want to format the date that I found with this:
    select case
    when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
    then TO_DATE('regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')','MM/DD/YYYY')
    else date_time
    end as new_time
    from raw_data;
    I get a request to insert a value for the digit as a bind variable. The digit should be populated from the when statement when it returns not null when a date is found.
    Could some one please tell me even if what I wrote here is even possible or make a suggestion to the syntax to get around this issue?
    All this is going to be incorporated into an update statement later on.
    I am running this on sql developer, oracle 11g.
    Thanks for your help in this matter in advance.
    regards,
    Al

    From looking at the code, as you have not supplied any scripts to create a table and demonstrate the error...
    Your case statement is trying to return two types
    select case
    when regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}') is not null
    then TO_DATE('regexp_substr(date_time,'^(0?[1-9]|1[0-2])/(0?[1-9]|[1-2][0-9]|3[0-1])/9[[:digit:]]{4}')','MM/DD/YYYY')
    else date_time
    end as new_time
    from raw_data;or simply
    select case when <expr>
                then <RETURN A DATE>
                else <RETURN A VARCHAR2>
            end as new_time
      from raw_data;The column cannot be both.
    Sorry I don't know your requirements.
    You could drop the else part and just return the converted date.
    You could fetch it back in two columns, the ones you can convert in one column (Which would be an oracle date type),
    the ones you cannot convert in another (which would be varchar2).
    Cheers,
    GP>

  • Combine select and update into single statement,without bind-variable

    I have a problem, that I think is not possible to solve the way I want to, but I just wanted to check before leaving the idea...
    I am looking for a way to combine the select and the update statement into one single statement. This is what I wan't to achive: select some data, and update the data selected before returning them.
    On this site http://www.psoug.org/reference/update.html I see that the following are possible:
    var bnd1 NUMBER
    var bnd2 VARCHAR2(30)
    var bnd3 NUMBER
    UPDATE employees
    SET job_id ='SA_MAN', salary = salary + 1000,
    department_id = 140
    WHERE last_name = 'Jones'
    RETURNING salary*0.25, last_name, department_id
    INTO :bnd1, :bnd2, :bnd3;
    I need to have this as a single statement, and cannot use bind-variables. So I was hoping that something like this could be possible:
    UPDATE customer c
    SET c.HAS_CREDIT ='1'
    WHERE c.HAS_CREDIT = '0'
    RETURNING c.CUSTOMER_NO, c.FIRSTNAME, c.LASTNAME
    where c.HAS_CREDIT = '1'
    But this doesn't compile, complaining of missing into (ORA-00925: missing INTO keyword). And even though I would like this to be possible because this would solve my current problem, I think it would be very confusing. For instance; would the where clause of the returning part be operating after the update or before?
    Any comments or suggestions on how to get it work in a single statement, or should I just leave this path straight away?

    Hi,
    RETURNING only works with bind variables, see
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/returninginto_clause.htm#sthref3006
    The real problem is that the form of RETURNING clause with bind variables is only valid for single row update or insert statements.
    To update (or insert) multiple rows and return the data, you will need to use
    RETURNING BULK COLLECT INTO clause. See
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2236
    Cheers,
    Colin

Maybe you are looking for

  • How to get the variable value while starting a session?

    When to execute an interface or scenario, if there are variables related, the session will keep the value of those variables in case to restart the session after failure. However I can't find where they are stored in ODI Repository. Could anyone give

  • Compiler not embedding current assets / cache cleaning

    dear all, In FlashBuilder 4.7 (beta + release), it consistently happens that linked assets aren't (re)loaded when compiling. Cleaning the project doesn't seem to help. Restarting FB, then cleaning + building mostly reloads the assets. Is there a way

  • File not found after restart

    Hello, We have a web application that reads in a .ini file. This works great. But, when we have to restart tomcat (for example after the database has been restarted) sometimes tomcat throws a file not found exception for that file. The only way to ge

  • HT1602 How do I delete a run that was accidentally tracked too long?

    I accidentally tracked a 24 hour run on Nike plus. How do I delete it?

  • Invisible Sony Hanycam

    Sony Handycam DCR-DVD108 (DVD video/ memory stick stills)USB connect only. Trying to get video from my daughter's camcorder onto my Mac but the Handycam doesn't show up anywhere : desktop, System Profile, not to mention Image Capture, iMovie or iPhot