update happens inside the anonymous PL/SQL block

Hello

I use oracle 10g 3.2.
I'll have a report with checkbox (separate column) so that only certain lines that I chose, I am able to update db.
At the click of a button following the anonymous PL/SQL block, I'll call you.

I use the "anonymous PL/SQL block following. The update happens.

F112_CHECKBOX is a level applocation element

Start
: F112_CHECKBOX: = HTMLDB_UTIL. TABLE_TO_STRING (HTMLDB_APPLICATION. G_F01, ",");

Insert into dumy values(:F112_CHECKBOX);
commit;

update set patient_id_code = '123' exp where f_id = 1 and patient_id_code = '12345' and method_internal_index in (: F112_CHECKBOX);
end;

The problem is with F112_CHECKBOX. The values I get in F112_Checkbox properly (in the dumy table I checked it shows) but by updating its not taking.
Can someone tell me something wrong with the syntax of update? method_internal_index column is varchar2 (100).

Thank you
Olivier

The problem is that: F112_CHECKBOX is a string that contains a list of values that you want to update.
You cannot use it in an IN clause because in doing so, you are running something like:

update exp
set patient_id_code='123'
where f_id=1
and patient_id_code='12345'
and method_internal_index in ('111,222,333,444');

This is equivalent to:

update exp
set patient_id_code='123'
where f_id=1
and patient_id_code='12345'
and method_internal_index = '111,222,333,444';

And cannot find any line to be updated.

You can change your update in this way:

update exp
set patient_id_code='123'
where f_id=1
and patient_id_code='12345'
and ','||:F112_CHECKBOX||',' like '%,'||method_internal_index||',%' ;

Ensure that: F112_CHECKBOX contains no spaces...

Max
http://oracleitalia.WordPress.com

Tags: Database

Similar Questions

  • Error when you try to create a region of the page generated by the anonymous pl/sql block

    Hi guys I tried to create a region of the page which is the source and anonymous pl/sql block and I have been making a few mistakes. Basically what I want this region to do, is to give the current user of the application one summarized data compared to there user name which is: app_user the code I used was

    declare

    ven_ret varchar2 (15);

    BEGIN

    ven_ret: = (select u.vendor of USERS4ARCHITEC u )


    where

    u.e_mail = V ('APP_USER')

    and not exists (select null from arch_tbl I where u.vendor = i.vendor and user_id = V ('APP_USER'))

    order u.vendor in ven_ret);

    END;

    /

    the structure of the table to the USERS4ARCHITEC table is

    User varchar2 (15) vendor2 (20)

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

    user@1                                                                          sap

    user@1                                                                          oracle

    user@1                                                                           IBM                                                            <---------sample data

    user@2                                                                          Oracle

    user@2                                                                          cisco

    the structure of the table to the arch_tbl table is

    user                                                     vendor

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

    user@1                                                 sap

    So if user@1 logs in the application of the region using the pl/sql code code above should display oracle and IBM, because these two sellers are always under his username that he has already used a form to insert the sap into the arch_tbl table. Please tell me what I'm doing wrong here. Thank you guys

    Why would you build a type psedu at APEX report MANUALLY when you can just build a relationship with the same selection you use now for your pl/sql dynamic region?  What is the purpose of building your own report when the tool made for you?

    Thank you

    Tony Miller
    Software LuvMuffin
    Ruckersville, WILL

  • Huge performance difference between stored proc and anonymous PL/SQL block.  Why?

    Hello!  I searched various online resources and have been unable to find those who have addressed this problem, so I hope that someone here may be able to offer advice.

    I have a stored procedure that is approximately 300 lines long, takes no parameters, and sets a record and a few types of internal tables.  When I run it on a particular data set, it takes about 50 seconds at the end of my environment.  Unfortunately, it will have to be performed as a block anonymous PL/SQL instead of a stored procedure, because of the policies that exist about the environment which I deployment.  However, when I converted it to an anonymous PL/SQL block, make no other code changes whatsoever and it connecting the same schema that belongs to the stored procedure, it takes about 6.5 minutes (nearly 8 times as long) to complete.  Aside from the burden of analysis and validation, which could add a fraction of a second, can someone please suggest some possible reasons for the large performance difference and offer advice on what I can do about it?  In which case it is important, the procedure uses in bulk binds (for example, in bulk collect, forall) where it makes sense and doesn't call other objects in PL/SQL.  Thanks in advance.

    Without seeing your code, it is difficult for me to contribute more.

    Note also that...

    1 roles are turned on in the anonymous blocks but not (at least not by default) in the stored procedures. This is why the anonymous block could have MORE rights (those granted through roles) probability that you can get more items through anonymous block.

    2. ensure that, in both cases, it does reference the same target tables.

    Debug by calculating the difference of time after certain steps in your code. Who should get an idea on this or activate the trace.

  • "Declaration of execution" and anonymous PL/SQL blocks

    I often use control - enter to execute the statement that the cursor is currently over.  Normally, this works very well.  But it's a little twisted once I added an anonymous PL/SQL block to the worksheet.  As long as the anonymous block is the last thing on the spreadsheet, I can "run statement" as usual.  But if I add a SQL queries after an anonymous block and try to run the statement, rather than just the running query, SQL Developer aims apparently to compile everything since the beginning of the first anonymous block until the current as a block statement.

    For example, if I have a spreadsheet as follows:

    SELECT 1 FROM DUAL;  --run statement on this line works as expected, running just this query
    
    BEGIN  --run statement anywhere within this block works as expected, running just this block
      DBMS_OUTPUT.PUT_LINE('X');
    END;
    
    SELECT 1 FROM DUAL; --run statement on this line goes back to the "BEGIN" on line 3 and gives a compilation error
    

    It is a nuisance major for me, as I have often a mixture of SQL and anonymous blocks on a worksheet.  I know that I can point out that the code I want and execute statement in this way, but I'd rather not have to do.  I was expecting that developer SQL would be smart enough to know where each block begins / ends and realize my current statement is not part of the block above him. Is there a setting that can change this behavior?  Or is it the way it is supposed to work?

    Whatever it is, thanks for the excellent tool.

    Add a ' / ' at line 5 and line 5 to line 6 bump

  • DBMS_ADVANCED_REWRITE can be used to intercept anonymous PL/SQL blocks?

    According to the title, does anyone know if DBMS_ADVANCED_REWRITE be used to intercept anonymous PL/SQL blocks?

    I suspect that the answer is no, because casual attempts to create a simple anonymous PL/SQL block rewrite equivalencies with DBMS_ADVANCED_REWRITE. DECLARE_REWRITE_EQUIVALENCE lead to errors of analysis, but maybe I'm missing some nuance.

    I suspect also that this function is enabled during the phase of hard analysis SQL general rewriting, so would not apply to blocks anonymous, even if such equivalence could be declared, but as I said I did not even declare a still.

    If anyone has had this for work or can add anything, I'd be happy.

    The data warehousing guide got a detailed note on this one:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e10810/qradv.htm#i1010537

    Also, given the documents, it does apply to the SQL and pl/sql blocks.

  • Hi, when I create a text box, and I type text in it, then I resize this text box, I want to see inside moving text at the same time I'm re-sizing of the text box. It does show me not LIVE what is happening inside the text box while I'm re-sizing text

    Hi, when I create a text box, and I type text in it, then I resize this text box, I want to see inside moving text at the same time I'm re-sizing of the text box. It does show me not LIVE what is happening inside the text box while I'm re-sizing of the text box and the same goes for the area of the image, I hope I could clarify my question.

    When resizing of a text box, click and hold for a moment before starting to resize. This will allow to see live redesign.

  • Game animation that happens inside the symbol_2 by clicking symbol_1 located at the stadium

    So basically I want exactly what the title says. I have the stage and two symbols... each symbols contain their own items. Symbol_1 has some static elements that act as buttons and Symbol_2 has images that are animated... at the beginning of each animation of each item, I put a tag (e.g. image1_start, image2_start etc.). And I want that when I click on one of the buttons that are sittuated in Symbol_1 to start an animation of a specific label that happens inside the Symbol_2.How should I do?... If they are all in the same timeline, it's simple by using the sym.play("image1_start") command, but this isn't really what I'm looking for. I hope that I've been pretty accurate. THANK YOU IN ADVANCE!

    P.S.Mostly is how I can do several different timelines to communicate properly.

    Enter the code to run when the composition is fully charged here

    {sym.getSymbol('symbol_1').$('btn1').click (function ()}

    sym.getSymbol('symbol_2').play ('image1_start');

    });

    {sym.getSymbol('symbol_1').$('btn2').click (function ()}

    sym.getSymbol('symbol_2').play ('image2_start');

    });

    {sym.getSymbol('symbol_1').$('btn3').click (function ()}

    sym.getSymbol('symbol_2').play ('image3_start');

    });

    Here is the example:

    https://www.box.com/s/dcpe4xvdu6h9391gy5yd

  • An update of LOOP in a PL/SQL block

    Every afternoon.

    I have a chart of accounts. Some of these accounts will have several numbers associated to them - other accounts will have just the number of accounts. The initial sequence number for each account is already set by another piece of code. There is a column in the table that details the next number in the sequence - so by joining the table to itself and from sequence number one - account I managed to create an exact sequence of account numbers, for each account we have.

    The question I have is that the script is long enough, and new account numbers can be added all the time. If the script must be maintained and added if necessary. There are currently 65 steps in the update below script.

    -UPDATED 2ND SEQUENCE NUMBER
    UPDATE ACCOUNT_LIFECYCLE
    GAME SEQUENCE = 2 WHERE ACCOUNT_NUMBER IN (SELECT B.ACCOUNT_NUMBER FROM ACCOUNT_LIFECYCLE A, ACCOUNT_LIFECYCLE B WHERE A.SEQUENCE = 1 AND A.NEXT_ACC_NO = B.ACCOUNT_NUMBER)
    /

    -UPDATED 3RD SEQUENCE NUMBER
    UPDATE ACCOUNT_LIFECYCLE
    GAME SEQUENCE = 3 WHERE ACCOUNT_NUMBER IN (SELECT B.ACCOUNT_NUMBER FROM ACCOUNT_LIFECYCLE A, ACCOUNT_LIFECYCLE B WHERE A.SEQUENCE = 2 AND A.NEXT_ACC_NO = B.ACCOUNT_NUMBER)

    /
    -UPDATED 4TH SEQUENCE NUMBER
    UPDATE ACCOUNT_LIFECYCLE
    GAME SEQUENCE = 4 WHERE ACCOUNT_NUMBER IN (SELECT B.ACCOUNT_NUMBER FROM ACCOUNT_LIFECYCLE A, ACCOUNT_LIFECYCLE B WHERE A.SEQUENCE = 3 & A.NEXT_ACC_NO = B.ACCOUNT_NUMBER)

    /

    think that this can be achieved in a small PL/SQL block, which would be effectively loop through iterations. I currently run the following query to verify the number of account numbers (to establish if I need to add more steps) - this could be defined as a variable binding?

    Select max (count (original_account_number)) of the ACCOUNT_LIFECYCLE group by original_account_number;

    Anyone has stumbled across any material on the web that may be able to help me in this task, or anyone could possibly give me a hint?

    Thanks in advance

    Hello

    You are absolutely right to avoid any code that must be changed simply because the changed data in a regular and predictable way. It is also a good idea to think of streamline something that has 65 almost identical copies of the same code.

    I think you can do what you want without PL/SQL, using a CONNECTION request BY:

    MERGE INTO     account_lifecycle     dst
    USING ( SELECT     account_number
               ,     LEVEL          AS seq
         FROM     account_lifecycle
         WHERE     LEVEL     > 1
         START WITH     seq          = 1
         CONNECT BY     account_number      = PRIOR next_acc_no
          ) src
    ON    (src.account_number = dst.account_number)
    WHEN MATCHED THEN
    UPDATE  SET     dst.seq = src.seq;
    

    Of course, you can place the MERGE statement above in a PL/SQL procedure, if you want to.

    If CONNECT BY does not work, then you could do what you do now in a loop, where the numbers are variables that is incremented with each pass through the loop. At the end of the loop, check if whatever it is actually got updated and LEAVE the loop if he doesn't.

    If post you a small example of data (CREATE TABLE and INSERT statements) and desired outcomes from these data (i.e., the State of the table once the UPDATE is all done), then I could test it.

  • Need help to build the query/pl-sql block to get the query result and the name of column from DB table in the form of key-value pairs.

    Hi Experts,

    I have a DB table has columns of more than 50.

    I question this table, it should only return one line at any time. as sqldeveloper below image.

    here, I need to build block pl/sql-query, Discover the column in the table as a key and query result as values.

    Eg:     Key                         -  Value

    TASK_EVENT_ID - 1765

    EVENT_TYPE - ASR_UPDATE

    ... etc until all of the columns in my table.

    Experts please comment on that point, appreciate your help on this.

    Thank you

    -Vincent.

    Here is an approach using DBMS_SQL to iterate over the columns of key / value to assign... (Little code snipped for brevity)

    create or replace procedure (task_expired)

    v_store_id in full,

    v_task_action_id in full,

    v_job_id in full

    )

    as

    -[SNIP code...]

    v_sql VARCHAR2 (4000): = ' select * from my_table where PK = 123';  -Your SQL here!

    v_v_val VARCHAR2 (4000);

    v_n_val NUMBER;

    v_d_val DATE;

    v_ret NUMBER;

    c NUMBER;

    d NUMBER;

    col_cnt INTEGER.

    f BOOLEAN;

    rec_tab DBMS_SQL. DESC_TAB;

    col_num NUMBER;

    vAsString VARCHAR2 (4000);

    BEGIN

    -[SNIP code...]

    Message_properties. CORRELATION: = "EDF_EVENT";

    MSG: = SYS. AQ$ _JMS_BYTES_MESSAGE. Construct();

    Msg.set_string_property ('queueName', ' shipping/csi_cth');

    Msg.set_string_property ('MODE', 'CR8');

    c: = DBMS_SQL. OPEN_CURSOR;

    DBMS_SQL. PARSE (c, v_sql, DBMS_SQL. NATIVE);

    d: = DBMS_SQL. Execute (c);

    DBMS_SQL. DESCRIBE_COLUMNS (c, col_cnt, rec_tab);

    1.col_cnt J

    LOOP

    CASE rec_tab (j) .col_type

    WHEN 2 THEN

    DBMS_SQL. DEFINE_COLUMN (c, j, v_n_val);      -Number

    WHEN 12 CAN

    DBMS_SQL. DEFINE_COLUMN (c, j, v_d_val);      -Date

    ON THE OTHER

    DBMS_SQL. DEFINE_COLUMN (c, j, v_v_val, 2000);   -Else treat as varchar2

    END CASE;

    END LOOP;

    LOOP

    v_ret: = DBMS_SQL. FETCH_ROWS (c);

    WHEN OUTPUT v_ret = 0;

    1.col_cnt J

    LOOP

    -Fetch each column to the correct data type based on coltype

    CASE rec_tab (j) .col_type

    WHEN 2 THEN

    DBMS_SQL. COLUMN_VALUE (c, j, v_n_val);

    vAsString: = to_char (v_n_val);

    WHEN 12 CAN

    DBMS_SQL. COLUMN_VALUE (c, j, v_d_val);

    vAsString: = to_char (v_d_val, ' DD/MM/YYYY HH24:MI:SS');

    ON THE OTHER

    DBMS_SQL. COLUMN_VALUE (c, j, v_v_val);

    vAsString: = v_v_val;

    END CASE;

    Msg.set_string_property (rec_tab (j) .col_name, vAsString);

    END LOOP;

    END LOOP;

    DBMS_SQL. CLOSE_CURSOR (c);

    DBMS_AQ. ENQUEUE (queue_name-online 'cbus.aqjms_common',

    Enqueue_options => Enqueue_options,

    Message_properties => Message_properties,

    Payload-online msg,

    Msgid => Message_handle);

    dbms_output.put_line ('00 Msgid =' |) Message_handle);

    dbms_output.put_line('===Done=');

    -[SNIP code...]

    END;

    /

  • Impossible to update anything inside the administrator

    I can connect to administrator very well, but when I try to submit anything, I get an error and it makes me login again... a vicious circle.  It worked, not sure what has changed. Today, I tried to do the download and install and received the following error:

    Clipboard01.jpg

    Additional info:-1: cannot display the location of the error in a CFML template.

    I have 10 ColdFusion with patch 8 is installed.  Any help would be greatly appreciated.  Being new to this know what I screwed up, but do not want to reload, because I have a lot of changes have been entered by the administrator, while it was working properly.

    Bob

    Finally understood the problem by looking at another post... Our network administrator changed the IP not too long ago and it has messed up the link way but if I use the actual IP address to enter the administrator I can change and update things very well.  Now on the latest version.

    Update level: /C:/ColdFusion10/cfusion/lib/updates/chf10000010.jar

    Thanks for the help!

  • Updating JRE after the failure of sysprep

    Hello

    During our deployment of windows 7, we have problems with JRE 7. We can install and update with no problems before sysprep. But after sysprep when a user tries to update it fails with "interrupted installation". We have set up installation logging and found MSI error 1603, with a reference to CustomAction InstallJava. As stated in the newspaper here:

    MSI (s) (0C: 04) [09:55:16:706]: the LastUsedSource value: C:\Users\USERNAME\AppData\LocalLow\Sun\Java\jre1.7.0_45\.

    MSI (s) (0C: 04) [09:55:16:706]: value LastUsedType: n.

    MSI (s) (0C: 04) [09:55:16:706]: A LastUsedIndex: 1.

    MSI (s) (0C: 04) [09:55:16:706]: op of execution: ActionStart (name = InstallJava, Description = registration of Java Runtime Environment),

    Action 09:55:16: InstallJava. Registration of Java Runtime Environment

    MSI (s) (0C: 04) [09:55:16:706]: op of execution: CustomActionSchedule(Action=InstallJava,ActionType=3073,Source=BinaryData,Target=MSIInstallJRE,)

    MSI (s) (0C: F8) [09:55:16:722]: call for a custom action to distance. DLL: C:\Windows\Installer\MSI31AC.tmp, point of entry: MSIInstallJRE

    MSI (s) (0C: 78) [09:55:16:722]: generation random cookie.

    MSI (s) (0C: 78) [09:55:16:738]: created server custom with PID 2180 (0 x 884) Action.

    MSI (s) (0C: 58) [09:55:16:987]: running as a service.

    MSI (s) (0C: 58) [09:55:16:987]: Hello, I am your server custom action high 32 bits.

    CustomAction InstallJava returned error code 1603 (note this is perhaps not 100% accurate if translation happened inside the bin to sand)

    Action ended at 09:55:52: InstallFinalize. Return value 3.

    Any1 have experience with a situation like this?

    We found the problem!

    Our anti-virus program, Symantec Endpoint Protection, apparently had a parameter definition called:

    "To prevent the registration of new Browser Helper Objects (HIPS) [AC15]" that was causing the problem.

    We have disabled this and the problem disappeared completely.

    --

    Kemicaze

  • First execution of pl/sql block is slow.

    Hello

    I've implemented TimesTen to improve performance of an Oracle pl/sql block.

    To do this, I created some cachegroups in TimesTen for caching oracle data.

    After everything is done on TimesTen, when we execute the pl/sql block on TimesTen, I observed that it took 35 seconds for the first run time on Timesten (compared with 48 seconds on Oracle).  The next run of the same pl/sql block with the same parameters take only 6 seconds. I want to achieve the same flow rate (6 sec) when the pl/sql block is executed for the first time. Can you please suggest what exactly I should look into.

    Thank you

    Amit

    Ye, it's a phenomenon known as I mentioned, but the 'hit' on the first run is usually not nearly this big. However, Windows as a platform is suffering more than most from this phenomenon and also Windows supports only not MemoryLock = 4, which further compounds the issue.

    Would you happen to have an available Linux system where you could test this with MemoryLock = 4, just so we can see what the difference between Linux and Windows? I think it would be a very useful thing to study to quantify how much this is due to Windows itself.

    A 'workaround' could be just application make a 'fake' execution of the PL/SQL procedure, immediately after I start and then all 'real' subsequent executions will be fast.

    Chris

  • stop a pl/sql block

    Hi guys,.

    I would like to know, how can I stop an anonymous pl/sql block (what is the command, what rights will I have to run the command, etc.). We use the TOAD to PL/SQL programming and I know that administrators can stop processes of Enterprise Manager.

    But yesterday, I started a block that is in an infinite loop and the admin is on vacation, and the table grows big and bigger and the tablespace will be full sooner or later.

    So help pls.

    Thank you
    Gabor

    Then you should find the sid, session id and the serial(serial#) of the view v$ session_longops... for your anonymous block...

    Then, run the command:
    alter system kill session ','

    Greetings,
    SIM

  • My first while loop inside the PL/SQL block does not, please help

    Hello

    I'm new to PL/sql and struck PL SQL blocks, please help solve this problem.

    declare

    constant v_A number: = 10;
    constant number j: = 3;

    BEGIN

    WHILE j < v_A
    LOOP
    DBMS_OUTPUT. Put_line ('Hai');
    END LOOP;
    END;

    Please help as how to solve this problem.

    Thanks in advance.

    You cannot declare j as in 'permanent' If you want to increment its value. better go to another variable if you intentionally want constant j.

    Something like this:

    declare
    v_A number constant:=10 ;
    j number constant := 3 ;
    i number;
    BEGIN
    i := j;
    WHILE i < v_A
    LOOP
    i := i + 1;
    DBMS_OUTPUT.PUT_LINE('Hai');
    END LOOP;
    END;
    

    ... Vivek

    Published by: Vivek 21 Sep, 2010 02:54

  • Passage of the Arguments to the anonymous block

    I have a unix script that calls an anonymous block / sql file.
    The sql file read a flat file via UTL_FILE utility and insert/update to update these data to the table.
    When calling SQL script, I put
     'SET DEFINE OFF' 
    to get rid of the * '&' * char in the string (input file).
    Now I have to deal with several files on the same trial, I invoke the SQL script from arguments like:

    Invoke:
    start xx.sql FILE_NAME
    Inside to access the xx.sql arguments like:
    declare
    y varchar2(20);
    begin
    dbms_output.put_line('Y= '||y);
    y:='&1';
    dbms_output.put_line('Y= '||y);
    end;
    /
    It only works if I put
     'SET DEFINE ON' 
    In this case no * '&' * char being treated as read from the standard input.
    Create procedure/function is out of reach.
    Someone can suggest... that should be the approach and is there a way to manage it?

    Hello

    Linda wrote:
    I have a unix script that calls an anonymous block / sql file.
    The sql file read a flat file via UTL_FILE utility and insert/update to update these data to the table.
    When calling SQL script, I put

     'SET DEFINE OFF' 
    

    to get rid of the * '&' * char in the string (input file).

    Are your really get into single quotes? If this is not the case, why you put them in this message?

    Now I have to deal with several files on the same trial, I invoke the SQL script from arguments like:

    Invoke:

    start xx.sql FILE_NAME
    

    Who is using SQL * more variable substitution. You must SET SET to retrieve the value of a variable substitution.
    You do not have to use & to mark the substitution variables; If you know iof some other special characters (such as ~) which is not used in your code, you can do the marker by saying:

    SET     DEFINE  ~
    

    Moreover, if the variable represents a value of sclar (wuch as the string "Filename" in your example), you can use bind variables to pass data in your anonymous block.
    For example, at the beginning of xx.sql, you can declare and set a varibale bind like this:

    VARIABLE     arg_1     VARCHAR2 (20);
    
    SET     DEFINE     ON
    
    EXEC :arg_1 := '&1';
    
    SET     DEFINE     OFF
    

    DEFINE must be enabled only for the statement that sets: arg_1.
    After that, your script can use: arg_1 instead of & 1:

    declare
        y varchar2(20);
    begin
        dbms_output.put_line('Y= '||y);
        y:=:arg_1;
        dbms_output.put_line('Y= '||y);
    end;
    /
    

    Note that you do not quote the variable name to bind when it is used. You had to mention the name of substitution variable, because SQL * Plus solves the substitution variables before sending the code for the compiler, but SQL * more passes the variable binding for the compiler, and the compiler can see that: arg_1 is a VARCHAR2.

    You can also define and set the binding variable in the calling script, but the passage of an argument tends to be a better way.

    There are other alternatives (such as escape &s);) We can Explorer if the two methods I described above do not work for you.

Maybe you are looking for