With the clause in a procedure stored with update

create table TEMP_STAGE as
(select ' 111111' student_id, ' don't TMP_TEST FROM DUAL ")
UNION
Select '111111' student_id, ' don't TMP_TEST FROM DUAL
UNION
Select ' 222222' student_id, ' don't TMP_TEST FROM DUAL;
)

CREATE OR REPLACE PROCEDURE TEMP_SEC_TEST
AS
BEGIN
UPDATE TEMP_STAGE S
SET S.TMP_TEST = 'Y '.
WHERE STUDENT_ID IN
(
WITH MARK AS
(
SELECT '111111' DOUBLE STUDENT_ID
)
Select STUDENT_ID in BRAND
);
END;

I have a huge SQL statement with several "with" of tables in the statement. It works if I run it as a script but it doesn't work when I put it in a stored procedure.
When I run the above, it gives me an error...
Syntax error (8:9) check
Found 'BOOKMARK' waiting...

It gives me an error the TSF online brand...

I have to do it in the stored procedure that the statement is very complicated...

Help, please.

Which tool you use to create the procedure? Error syntax Check (8:9) is not a mistake, Oracle, or what I know from any Oracle product.

It works very well in sqlplus.

SQL> CREATE procedure my_p AS
  2  BEGIN
  3     UPDATE t
  4     SET descr = 'Un'
  5     WHERE id IN (WITH tmp AS (
  6                     SELECT 1 x FROM dual)
  7                  SELECT x FROM tmp);
  8  END;
  9  /

Procedure created.

SQL> SELECT * FROM t;

        ID DESCR
---------- ----------
         1 One

SQL> exec my_p;

PL/SQL procedure successfully completed.

SQL> SELECT * FROM t;

        ID DESCR
---------- ----------
         1 Un

John

Tags: Database

Similar Questions

  • Problem with the Entity Framework by using stored procedures

    I am developing a project with Oracle DB and Entity Framework.
    Due to performance issues, for some querys I uses procedures stored instead of LINQ queryies,
    When I try to add my model EF procedure, the procedure is added but the Model Designer
    It does not acknowledge the columns returned by the procedure.
    so I can't create something complex to the user the results of the procedure
    in a domain service

    Here's the relevant readme which has some tips: http://www.oracle.com/technetwork/topics/dotnet/tech-info/default-338300.html#mozTocId610465

    If you do a forum search there is further discussion of the issues, and the readme file provided with version beta has also some information.

    But I agree with the general theme: using stored procedures in the EF is a PITA. :( I really hope they do something to make it easier in the future because this is probably the single most important weakness in the implementation of Oracle EF and establishment of a complex type is your time and picky it's ridiculous. (I found it less problematic if your procedure returns a complete picture that your model has already an entity for, because you can get away with only add the entry to one of the configurations for the cursor rather than one for each column.)

    Even an external tool where direct you to the procedure and it creates the configuration entries to be able to copy and paste would be a huge improvement.

  • WITH THE CLAUSE

    Hi all

    I'm using oracle 11.2.0.4

    I m using this for the purpose of learning

    Below is my table and insert statement

    CREATE TABLE COMPANY (NUMBER EMPLOYEE_ID, EMPLOYEE_NAME VARCHAR2 (30), NUMBER OF MANAGER_ID)

    INSERT INTO THE COMPANY'S VALUES (1, 'FRED', ");

    SOCIETY VALUES (2, 'BARNEY', '1');

    SOCIETY VALUES (3, 'WILMA', '1');

    SOCIETY VALUES (4, 'BETTY', '3');

    INSERT IN THE VALUES(5,'PEBBLES','3') SOCIETY;

    INSERT IN THE VALUES(6,'BAM-BAM','4') SOCIETY;

    INSERT IN THE VALUES(7,'DINO','4') SOCIETY;

    INSERT IN THE VALUES(8,'HOPPY','4') SOCIETY;

    WITH RSFC(CK,PK,LVL,HIER) AS

    (SELECT EMPLOYE_ID, MANAGER_ID, 0 AS LVL, EMPLOYEE_NAME LIKE YESTERDAY)

    SOCIETY

    WHERE MANAGER_ID IS NULL

    UNION ALL

    SELECT EMPLOYE_ID, MANAGER_ID, LVL + 1, YESTERDAY. '/' || EMPLOYEE_NAME

    OF THE RSFC R INNER JOIN COMPANY F

    ON R.CK = F.MANAGER_ID

    )

    WIDTH OF SEARCH FIRST BY CK ORDR SET

    SELECT A.LVL, A.CK, A.PK, A.HIER, ORDR

    THE RSFC HAS

    ORDER BY ORDR

    01FRED1
    121FRED/BARNEY2
    131FRED/WILMA3
    243FRED/WILMA/BETTY4
    253FRED/WILMA/PEBBLES5
    364FRED/WILMA/BETTY/BAM-BAM6
    374FRED, WILMA, BETTY, DINO7
    384FRED, WILMA, BETTY, HOPPY8

    First part, I believe, as well, explains Frank

    hierarchical queries

    next part in bold, I need to understand

    Thanks and respect.

    Guylaine

    Hi, lyly,

    You said that you did not understand the part highlighted in your query.  It looks like the 2 lines are highlighted:

    WIDTH OF SEARCH FIRST BY CK ORDR SET

    SELECT A.LVL, A.CK, A.PK, A.HIER, ORDR

    I guess that it's a typo.  The 2nd day of these lines is just the main SELECT clause; This is the 1st line, the clause of the SEARCH, who really needs an explanation.

    As far as I know, the SEARCH clause is only for the sorting of the results.  In other words, the a WITH recursive clause results will be the same, no matter what you put in the SEARCH clause, or if you omit the clause of RESEARCH.  The only purpose of the clause of RESEARCH is to generate the column command (ORDR in your example), which reflects where each row fits in the graph defined by your recursive query.  (Maybe, if you use non-deterministic user-defined functions, it can be a difference in the results.  Chances are, you never have to worry about this).

    If you do not use a clause in RESEARCH at all, it seems like by default

    WIDTH OF SEARCH FIRST BY NULL...

    In other words, the lines appear in order by level and in no particular order after that.  In your case, that would mean 'FRED' would come first, then "BARNEY" and "WILMA" (not necessarily in that order), followed by all the children of 'BARNEY' or 'WILMA' and so on.  No column order would be generated, so you could not guarantee order in the ORDER BY clause.

    I'm not sure that there is nothing you can do with a clause of RESEARCH that you can not do without a.  In other words, the SEARCH clause automatically generates a command column.  I believe you can still create an equivalent ordering column in the recursive query itself.  In your example, you could say

    ORDER BY lvl, ck

    to get the results sorted the same way.  Sometimes, using a SEARCH clause is much more convenient, and I bet that sometimes it is therefore more effective, too.

    2937991 wrote:

    Hi all

    I'm using oracle 11.2.0.4

    I m using this for the purpose of learning

    Below is my table and insert statement

    CREATE TABLE COMPANY (NUMBER EMPLOYEE_ID, EMPLOYEE_NAME VARCHAR2 (30), NUMBER OF MANAGER_ID)

    INSERT INTO THE COMPANY'S VALUES (1, 'FRED', ");

    SOCIETY VALUES (2, 'BARNEY', '1');

    ...

    As always, thank you for posting this information: it really helps!

    Manager_id is a NUMBER, it would be better if you don't quote it.  In other words, it would be more clear, more effective and less prone to say:

    INSERT INTO COMPANY (EMPLOYE_ID, EMPLOYEE_NAME, MANAGER_ID) VALUES (1, 'FRED', NULL);

    INSERT INTO COMPANY (EMPLOYE_ID, EMPLOYEE_NAME, MANAGER_ID) VALUES (2, 'BARNEY', 1);

    ...

    In this example, the unnecessary quotation marks do not hurt a lot, but they do not help all.

  • with the use of the clause in the cursor

    is it possible to use with the clause in the cursor declaration.

    See the simple example below.

    It gives an error.



    declare

    cursor t is

    (with Salvation as

    (select * from pepole)


    Select distinct hi.id of salvation where id = 55);


    Start


    null;


    end;

    Remove the outdoor set of parentheses.

    declare
    
    cursor t is
    with hi as
    (select * from emp )
    select distinct sal from hi;
    begin
    null;
    end;
    
  • This will strain you! I can't download the PDF file that is stored on my site FTP with Internet Explorer

    I can't download the PDF file that is stored on my site FTP with Internet Explorer, but I can't with Chrome, Safari, FireFox etc. Error message: museutils.js Code: 0

    My page: http://creditunionone.org/applications---forms.html

    and this page as: http://petfoodpantryokc.org/get-assistance.html

    Help, please! I get 20-30 presentations of members. customers / clients claiming that they are unable to download the forms.

    adding: Pop up says: Windows Internet Explorer errors on this site it may not work properly. A security problem has occurred. museutils.js Code: 0

    URI: http://www.creditunionone.org/scripts/1.1/museutils.js?110351884

    Links to PDF files are incorrectly formatted for example. http:// contribute000011n @creditunionone.org/forms/membershipcardstaticpdf.pdf IE do not like. Remove the part highlighted links and re - post pages.

    Thank you

    Vinayak

  • WITH the clause as inline view

    I m using oracle DB 11.2.0.2.0
    I have a question about usage WITH the clause which made a temporary transformation (Materializing) automatically.
    I want the query to operate as a point of view WITH clause online because the transactions table materailizing would kill performance.
    I m able to see the transformation of the temporary table in the explain output plan.
    Have we not all suspicion to stop the transformation of Temp table?

    Here is an example of the sample
    I have the query union multi (2 requests), couple of table is common to all the union queries. the request should not be materialized. It must operate as a point of view common inline.

    WITH ORDERS AS
    (SELECT h.order_number,
    l.line_number,
    l.line_id
    order_headers h, order_lines l)
    SELECT...
    COMMANDS, X, Y
    WHERE THE...
    UNION ALL
    SELECT...
    ORDERS, A, B, C
    WHERE THE...

    Try this...

    WITH ORDERS AS
    (SELECT /*+ inline */ h.order_number,
    l.line_number,
    l.line_id
    from order_headers h, order_lines l)
    ...
    

    To achieve the opposite effect, you can use SELECT / * + materialize * /.

    However, keep in mind that these tips are undocumented, so use them at your own risk. If you think that Oracle is to choose a bad execution plan, you must sign a deal with Oracle Support to see if this is a bug.

    Kind regards
    Bob

  • with the Clause in a function

    Hi all

    I use oracle 10 g 2.

    I have a sql query that begins with a "WITH Clause"... Can of use this directly in a function?

    I tried copy paste in the new feature after the BEGIN... but it errors saying CLAUSE provided for in select... when I try including IN the clause... it gives different error...

    Enjoy your sugessions

    Thanks in advance
    H

    You can, perhaps you could post your code so we can take a look?

    See you soon

    Ben

  • Can we use type multiset and with the clause the two

    Please let me know how to use the multiset type and with the clause.

    You need more inlining, as for example in:

    SQL> select *
    from table (cast (multiset (select *
                                from (with t as (select deptno from dept)
                                      select * from t)) as sys.dbms_debug_vc2coll))
    /
    COLUMN_VALUE
    ----------------------------------------
    10
    20
    30
    40
    50                                      
    
    5 rows selected.
    
  • How to use an index with the clause 'in '.

    Hi all

    I have a sql statement with "" * in the clause * "."

    for example:
    select emp_id from emp where ename in ("vikas", "krishna", "John", "scott");
    When I check the plan explain he uses the index here even if the statistics was entered. He always goes for the full table scan.
    There is an index created for the ename column.

    Please tell me a technique on how to make use of the index here.


    Thank you and best regards,
    Vikas Krishna

    Vikas,

    What version of Oracle you are running.
    CLAUSE IN will use the index as appropriate.
    In your example Optimizer may decide to use FTS (Full Tablle Scan) for various reasons. May be that the table is very small.
    SE for example below where he uses an index on the CLAUSE IN...
    The essential point being that I made "wide enough" table (in this case including a column of type CHAR) makes use of INDEX more effective than a FTS.

    select * from v$version where rownum < 2;
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    
    create table bigt (c int, s char(100));
    
    insert into bigt select level, 'X' from dual connect by level < 501;
    
    create index bigt_in1 on bigt (c );
    
    exec dbms_stats.GATHER_TABLE_STATS('SUDHAKAR', 'BIGT');
    
    explain plan for select c,s from bigt
    where c in (1,2,3,43,5);
    
    select * from table(dbms_xplan.display);
    
    PLAN_TABLE_OUTPUT
    
    Plan hash value: 238667275
    
    -----------------------------------------------------------------------------------------
    | Id  | Operation                    | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT             |          |     5 |   520 |     3   (0)| 00:00:01 |
    |   1 |  INLIST ITERATOR             |          |       |       |            |          |
    |   2 |   TABLE ACCESS BY INDEX ROWID| BIGT     |     5 |   520 |     3   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN          | BIGT_IN1 |     5 |       |     2   (0)| 00:00:01 |
    -----------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - access("C"=1 OR "C"=2 OR "C"=3 OR "C"=5 OR "C"=43)
    

    VR,
    Sudhakar B.

  • Problem with REPLACING the clause in Sybase

    I am facing a problem with REPLACING the clause in embedded SQL with a Sybase database.

    My Cold Fusion Server is MX 7.

    The database is the Adaptive Enterprise/12.5.0.3/EBF 10689 IR/P/Sun_svr4/OS Server 5.8/rel12503/1915/64-bit/FBO/Thu 23 Jan 16:05:19 2003

    That is the problem. I have a variable bureau_incode of Cold Fusion, which I use to set the values in my IN clause. When I comment on my request and display this value in the HTML page, bureau_incode has the following value:

    ('TAB', 'OGC', 'BIG', 'OLA', "MDG", "SEO", "OSP", "ANOTHER OWD ',' ', 'PSHSB", "CAT", "WTB")

    My CFQUERY embedded SQL looks like this:

    Quote:
    < name cfquery = "qResults" datasource = "#request.dsn #" >
    Select Name,
    bureau_code,
    Telephone,
    Mobile phone,
    Pager,
    E-mail
    Availability,
    Explanation,
    Password,
    Admin,
    last_login = convert (varchar (20), last_login, 0)
    of PAMS where availability = ' don't
    < #request.seltype # cfif IS NOT "ALL" >
    and bureau_code IN #bureau_incode #.
    < / cfif >
    < / cfquery >
  • Help with the clause of "default".

    Hi all

    I have a scenario where there is a table with 75 columns. out of the 75 columns, 30 are varchar and 30 are digital. The remaining columns are other types of data when creating the table, that I forgot to mention the default values to varchar and numeric columns.

    Now, approximately 20,000 records are inserted into the table where some records contain NULL varchar and numeric. Now, I want to replace the null with varchar values and digital default values respectively.

    I can change the columns by adding the clause by default now and update the lines of NULL for the default values accordingly. But this process could be very heavy.

    Is there a better way to do this. Please help me.

    Thanks in advance,
    Rambeau

    I want to know that is it possible to set the default values for all columns of type varchar, both using a single SQL statement. Then you can update all the values NULL with default values.

    You are looking for something like this?

    SQL> create table t (empno default 1, ename default 'x') as select cast(null as integer) empno, cast(null as varchar2(10)) ename  from emp where rownum <= 4
    /
    Table created.
    
    SQL> select * from  t
    /
         EMPNO ENAME
    ---------- ----------
    
    4 rows selected.
    
    SQL> update t set empno = default, ename=default
    /
    4 rows updated.
    
    SQL> select * from  t
    /
         EMPNO ENAME
    ---------- ----------
             1 x
             1 x
             1 x
             1 x         
    
    4 rows selected.
    
  • What is the problem with the format of this procedure

    on the page of the apex I displays a record based on the record number of user input. Now, I need to convert the process in a procedure.

    treat before heading in the apex:
    Select emp_id, emp_name in (: p1_emp_id,: p1_emp_name) of employees where emp_id =: p1_entered_id;




    My unsuccessful attempt of conversion:

    treat before heading in the apex:
    p_find_emp_data (p_emp_id = >: p1_emp_id,)
    p_emp_name = >: p1_emp_name,.
    p_entered = >: p1_entered_id);


    procedure:
    create or replace procedure P_find_emp_data
    (p_emp_id number,
    p_emp_name in varchar2,
    P_entered number)
    is
    Start
    Select emp_id, emp_name in: p_emp_id,: p_emp_name form employees where p_emp_id =: p_entered;
    end

    issues related to the:
    1. to help ' = > ' in a process call, this means match and assign the value? ex: p_emp_name will have p1_emp_name value\data. If Yes
    2. why the compiler of procedure do not like my select statement on: P_emp format, it's like I need to redefine the variables.

    Can you help me? It must be that I misinterpretate the ' = > ' but has not found this notation in doc. This notation was an employee now disappeared.

    Thanks in advance a lot.

    wanwan63,

    First of all, for notation, using the '=> '...

    Means what is pairs name / value. Using this, you can call your procedure with the parameters in any order that you like. Some examples of the appeal of your home with this notation.

    P_find_emp_data (p_emp_id => 1 , p_emp_name => 'DOUG', p_entered => 123232);
    p_find_emp_data(p_emp_name => 'DOUG', p_emp_id => 1, p_entered => 123232);
    

    Two of these calls are equivalent.

    Now, the reason why your selection... in does not work.

    You have all your settings specified as part of the definition, which means that they are used ONLY to pass information in the procedure.

    If you mark as IN OUT or OUT (depending on their use) you'll have better luck that of why, based on the code that you included, the signature of your procedure should be

    create or replace procedure P_find_emp_data
    (p_emp_id OUT number,
     p_emp_name OUT varchar2,
    P_entered IN number)
    is
    begin
    select emp_id,emp_name into p_emp_id, p_emp_name form employees where p_emp_id = p_entered;
    end;
    

    Also note that I removed the colon before the references to parameters. They are not needed, referring to the parameters of the procedure.

    Hope that helps,

    -Doug-

    http://sumnertech.com/

  • With the clause of DML (DEC/insert/insert-all)

    Hello


    I have tables t1, t2, t3, t4

    with w
    (
    Select t1.* from t1, t2
    where t1.c1 = t2.c1
    and t1.c2 = t2.c2
    )


    I need to create or insert data in new tables n1 and n2
    Like this..

    Insert into n1
    Select * from w, t3
    where w.c1 = t3.c1

    Insert into n2
    Select * from w, t4
    where w.c2 = t4.c2
    ----

    I will make references the object 'w' several times.
    My concern is because the inserts above are run independently in the same session, the oracle executes the
    with the clause for each reference or runs one time?

    Essentially of iam looking for an insert-all statement
    where it inserts data into multiple tables from target
    something like that...


    Insert into n1
    When
    Select * from w, t3
    where w.c1 = t3.c1
    Insert into n2
    When
    Select * from w, t4
    where w.c1 = t4.c1
    with w
    (
    Select t1.* from t1, t2
    where t1.c1 = t2.c1
    and t1.c2 = t2.c2
    )

    ----
    Usually, I'm doing my basic work before posting on oracle forums, currently iam unable to connect to one
    Oracle sessions. Can someone help me?


    Thanks in advance.

    If your application will have the same number and type of columns, then you can do something like that.

    SQL> create table t1
      2  as
      3  select level no, 'karthick' name
      4    from dual
      5  connect by level <= 5
      6  /
    
    Table created.
    
    SQL> create table t2
      2  as
      3  select no, 'vimal' name
      4    from t1
      5  /
    
    Table created.
    
    SQL> create table t3
      2  as
      3  select no, 'vijay' name
      4    from t1
      5  /
    
    Table created.
    
    SQL> create table t4
      2  as
      3  select no, 'subha' name
      4    from t1
      5  /
    
    Table created.
    
    SQL> create table n1
      2  as
      3  select * from t1 where 1=2
      4  /
    
    Table created.
    
    SQL> create table n2
      2  as
      3  select * from t1 where 1=2
      4  /
    
    Table created.
    
    SQL> insert when view_name = 'v1' then
      2             into n1 values (no, name)
      3         when view_name = 'v2' then
      4                     into n2 values (no, name)
      5  with v
      6  as
      7  (
      8     select t1.*
      9       from t1, t2
     10      where t1.no = t2.no
     11  ),
     12  v1
     13  as
     14  (  select t3.*, 'v1' view_name
     15       from v, t3
     16      where v.no = t3.no
     17  ),
     18  v2
     19  as
     20  (  select t4.*, 'v2' view_name
     21       from v, t4
     22      where v.no = t4.no
     23  )
     24  select * from v1
     25  union all
     26  select * from v2
     27  /
    
    10 rows created.
    
    SQL> select * from n1
      2  /
    
            NO NAME
    ---------- --------
             1 vijay
             2 vijay
             3 vijay
             4 vijay
             5 vijay
    
    SQL> select * from n2
      2  /
    
            NO NAME
    ---------- --------
             1 subha
             2 subha
             3 subha
             4 subha
             5 subha
    
  • WITH THE CLAUSE DOES NOT WORK

    Hello everyone,
    I have the suite Oracle version:

    SQL & gt; selection of version of $ v; *

    BANNER
    ----------------------------------------------------------------
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production
    PL/SQL Release 9.2.0.8.0 - Production
    CORE Production 9.2.0.8.0
    AMT for Solaris: 9.2.0.8.0 - Production Version
    NLSRTL Version 9.2.0.8.0 - Production

    But when I try to run a query with * 'with the clause"* it gives following error:

    SQL & gt; with sam as (select from asap.triangular_reco_aug) *.
    SP2-0734: beginning of unknown command «with sam a...» "- rest of line is ignored.
    SQL & gt;

    Could someone please why this is happening?

    What is your version of SQL * more? If you are using a version earlier than 9.2 then it is probably intercept the syntax error before it happens even to the database that supports.

  • Problem with the case where the clause

    Hello

    I want to use cases in which clause. I wrote a very simple query to test how it works. However, I always got an error message. Here's what I did.

    Select eid, firstname, lastname from employee where eid = 1 works fine

    Select eid, name, name of the employee

    where

    cases where 1 = 1 then eid = 1

    When 1! = 1 then eid = 2

    end

    I ORA-00905: lack of keyword.

    Did I miss something?

    Thank you

    Jennifer

    Hi, Jennifer.

    Why do you want to use BOX in a WHERE clause?  The wonderful thing about the CASE is that it allows you to do IF-THEN-ELSE logic.  In a SELECT clause, or an ORDER BY clause, this is really useful, but the WHERE clause already allows you to use the IF-THEN-ELSE logic.

    However, if you use the BOX in a WHERE clause, it is as it does nowhere else.  Always BARGAIN instead of a single expression in a SQL data types.  All the clauses THEN (and ELSE, if there is one) must return a single expression, such as the NUMBER.  (There is no BOOLEAN data type in SQL).  So, you can use a CASE statement like this:

    ...

    CASES WHERE

    WHEN 1 = 1 THEN 1

    WHEN 1! = 1 THEN 2

    END = eid

    Here, the CASE expression takes the place of a NUMBER.

    However, if I was not sure if 1 = 1 or not, I would write the condition in this way, without a CASE expression:

    WHERE (1 = 1 AND eid = 1)

    OR (1! = 1 AND eid = 2).

Maybe you are looking for

  • Safari has changed to bing how do I get it back to safari

    I think I downloaded by mistake some malware, now my safari has changed my search engine Bing and I can't understand how to fix it.

  • Question about product key Windows XP Pro on Satellite A135-S4427

    I have an A135-S4427 which came with Windows Vista.As I did not like the vista I formatted and installed Windows Xp Professional with SP2 and got all the drivers working.All I need now is a product key for activation of windows. I tried to use the ke

  • Xperia Z2 worth buying?

    Hey guys, Im a proud owner of Sony Xperia Z (c6603) and I use my Xperia Z for more than two years now. I use my phone for multimedia use as listening to music, watching videos and games (MKX and asphalt) on a daily basis with Wifi connected most of t

  • BB in blackBerry maps GPS Smartphones?

  • VLAN &amp; UC520/CE520

    Hi, I have a problem with routing between VLANs. I have two VLAN data put on the boxes above: 192.168.6.0/24 & 192.168.3.0/24. There's a UC520 box with its default ip address in the range 6.0 and all CE520s (three of them) also have an ip address in