How to convert my query in SQL procedure

Hi all

I run a SQL query in my process of page to set a few articles on my page.

Start
declare
l_vc_arr2 APEX_APPLICATION_GLOBAL. VC_ARR2;
Start

IF APEX_APPLICATION. G_F01. COUNT = 0 THEN
RAISE_APPLICATION_ERROR (-20001, 'Please select a model of e-mail to change!');
END IF;

IF APEX_APPLICATION. G_F01. COUNT > 1 THEN
RAISE_APPLICATION_ERROR (-20001, 'Please select a model unique to change both message!');
END IF;

BECAUSE me in 1.APEX_APPLICATION. G_F01. Count
LOOP
l_vc_arr2: = APEX_UTIL. STRING_TO_TABLE (APEX_APPLICATION. G_F01 (i),' $');
: P32_SUBJECT: = l_vc_arr2 (1);
: P32_TYPE: = l_vc_arr2 (2);
: P32_BODY: = l_vc_arr2 (3);
END LOOP;
end;
end;

It works perfectly fine. Now, I want to turn this query in custom procedure. I write the following code to create the SQL procedure,

create or replace
procedure Edit_EmailTemplate as
Start
declare
l_vc_arr2 APEX_APPLICATION_GLOBAL. VC_ARR2;
Start

IF APEX_APPLICATION. G_F01. COUNT = 0 THEN
RAISE_APPLICATION_ERROR (-20001, 'Please select a model of e-mail to change!');
END IF;

IF APEX_APPLICATION. G_F01. COUNT > 1 THEN
RAISE_APPLICATION_ERROR (-20001, 'Please select a model unique to change both message!');
END IF;

BECAUSE me in 1.APEX_APPLICATION. G_F01. Count
LOOP
l_vc_arr2: = APEX_UTIL. STRING_TO_TABLE (APEX_APPLICATION. G_F01 (i),' $');
v (P32_SUBJECT): = l_vc_arr2 (1);
v (P32_TYPE): = l_vc_arr2 (2);
v (P32_BODY): = l_vc_arr2 (3);
END LOOP;
end;
end;

but it is not compiling. Someone knows what's the problem?


With respect,
Sunil Bhatia

Hi Sunil,

You cannot use the function v ('P32_BODY') to assign values.

you will need to use:
apex_util.set_session_state ('P32_BODY', l_vc_arr2 (3));

Concerning

Michael

Tags: Database

Similar Questions

  • How to call the OFA PL/SQL procedure.

    Hello

    I'll call the pl/sql stored procedure of the OAF page (AM). the procedure is content parameter 3 IN 1 OUT parameter. all the parameters of character type is integer.


    I put the output parameter and it's returning the value, but I don't have how to configure the setting IN because the settings IN, I need to convert the INT data type number in java.

    Please help me.


    int in_parm1 = 0;
    Number in_param;
    Request_id number;
    request_id = new Number (0);
    getDBTransaction () .commit ();
    TXN OADBTransaction = getOADBTransaction();
    int l_user_id = txn.getUserId ();
    int l_resp_id = txn.getResponsibilityId ();
    int l_resp_appl_id = txn.getResponsibilityApplicationId ();
    Number of ln_user_id = new Number (l_user_id);
    Number of ln_resp_id = new Number (l_resp_id);
    Number of ln_resp_appl_id = new Number (l_resp_appl_id);
    CallableStatement cs = txn.createCallableStatement ("start oaf_request(:1,:2,:3,:4); end; ", 1) ;
    Try
    {
    System.out.println ("run ahead");
    cs.registerOutParameter (3, Types.VARCHAR, 0, 100);
    cs.registerOutParameter(1,in_param);
    cs.registerOutParameter(4,Types.NUMERIC);
    DSI Execute();
    in_parm1 = cs.getInt (4);
    request_id = new Number (in_parm1);
    System.out.println ("Request ID" + in_parm1);
    System.out.println ("run after");
    DSI Close();
    System.out.println ("result");
    }
    catch (System.Exception e)
    {

    throw OAException.wrapperException (e);

    }

    I would tell you to go through the "appeal of PL/SQL procedures and functions" Section in the User Guide.
    Example and the details are there reference.

    Thank you

  • How to use my bellows PL/SQL PROCEDURE to export data to a directory with a button in the ADF?

    Mr President.

    Any body give me advice step by step that how can I use my pl/sql below procedure to take the small schema oracle backup with a touch of the adf.

    DECLARE  
       h1   NUMBER;  
       dt   VARCHAR2 (20);  
       myschema VARCHAR2(32):='SCOTT';  
    BEGIN  
       SELECT TO_CHAR (SYSDATE, 'YYYYMMDD')  
         INTO dt  
         FROM DUAL;  
      
      
       h1 :=  
          DBMS_DATAPUMP.OPEN (operation      => 'EXPORT',  
                              job_mode       => 'SCHEMA',  
                              job_name       => myschema||'_EXP_' || dt,  
                              VERSION        => 'COMPATIBLE'  
                             );  
       DBMS_DATAPUMP.set_parallel (handle => h1, DEGREE => 1);  
       DBMS_DATAPUMP.add_file (handle         => h1,  
                               filename       => myschema||'_EXP.LOG',  
                               DIRECTORY      => 'ADMIN_DIR',  
                               filetype       => 3  
                              );  
       DBMS_DATAPUMP.set_parameter (handle      => h1,  
                                    NAME        => 'KEEP_MASTER',  
                                    VALUE       => 0  
                                   );  
       DBMS_DATAPUMP.metadata_filter (handle      => h1,  
                                      NAME        => myschema||'_EXPR',  
                                      VALUE       => 'IN('''||myschema||''')'  
                                     );  
       DBMS_DATAPUMP.add_file (handle         => h1,  
                               filename       => myschema||'_EXP_' || dt || '.DMP',  
                               DIRECTORY      => 'DATA_PUMP_DIR',  
                               filetype       => 1  
                              );  
       DBMS_DATAPUMP.set_parameter (handle      => h1,  
                                    NAME        => 'INCLUDE_METADATA',  
                                    VALUE       => 1  
                                   );  
       DBMS_DATAPUMP.set_parameter (handle      => h1,  
                                    NAME        => 'DATA_ACCESS_METHOD',  
                                    VALUE       => 'AUTOMATIC'  
                                   );  
       DBMS_DATAPUMP.set_parameter (handle      => h1,  
                                    NAME        => 'ESTIMATE',  
                                    VALUE       => 'BLOCKS'  
                                   );  
       DBMS_DATAPUMP.start_job (handle => h1, skip_current => 0, abort_step => 0);  
       DBMS_DATAPUMP.detach (handle => h1);  
    END;  
    /  
    
    
    

    Concerning

    Hello world!

    It's the simple code to call an appModule procedure

        public void callStoreprocedureWithoutInput() {
                String stmt = "BEGIN\n" +
                "  \"dbBackup\"();\n" +
                "--rollback; \n" +
                "END;";
                PreparedStatement st = null;
                try {
                    st = getDBTransaction().createPreparedStatement(stmt, 0);
                    st.executeUpdate();
                    st.close();
    
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
    

    Concerning

  • How to convert the number to SQL?

    How can I convert the number in SQL?
    The problem is that I use .NET and the Oraclenumber seems to be too big.

    Number of database - what I get when I select
    -----------'12'--------------------------------------'12'
    -12, 1-12, 10' <-this 0 should not be there
    -----------'12,12'-----------------------------------'12,12'
    -12, 123'---12, 1230' <-this 0 should not be there
    -----------'12,1234'-------------------------------- '12,1234'


    I don't know why this happens?

    Now, I tried to select with to_char (COLUMN1), but when I have values like "' 0,15 ' in the base, I get in select ', 15' when I convert with to_char?"

    Anyone know a solution?

    Kind regards
    Simon

    Edited by: user3654758 the 30.09.2010 02:02

    with mytable as
    (select 12 n of all the double union)
    Select 12.1 in union double all the
    Select 12.12 in union double all the
    Select 12.123 in all the double union
    Select double 12.1234)
    Select case when trunc (n) = n then
    TO_CHAR (n, 'FM9999999999999999999')
    on the other
    TO_CHAR (n, 'FM9999999999999999999D9999999')
    end
    FROM MyTable;

    Edited by: hartmutm the 30.09.2010 02:21

    I changed it a bit, because you have a problem with the separator decimal escape in the previous code.

  • How to simplify this query in sql simple select stmt

    Hello

    Please simplify the query

    I want to convert this query in a single select statement. Is this possible?
    If uarserq_choice_ind is not null then

    Select ubbwbst_cust_code
    From ubbwbst,utrchoi
    Where utrchoi_prop_code=ubbwbst_cancel_prod
    Else

    Select max(utvsrvc_ranking)
    From utvsrvc,ubbwbst
    Where utvsrvc_code=ubbwbst_cancel_prod
    End if
    Select ubbwbst_cust_code as val
    From   ubbwbst,utrchoi
    Where  utrchoi_prop_code=ubbwbst_cancel_prod
    AND    uarserq_choice_ind is not null
    union all
    Select max(utvsrvc_ranking) as val
    From   utvsrvc,ubbwbst
    Where  utvsrvc_code=ubbwbst_cancel_prod
    and    uarserq_choice_ind is null
    

    Without more information, we are unable to combine the two queries in 1 without a union.
    Looks like you select values totally disperate of totally different tables

  • How to write a pl/sql procedure that checks the remote db?

    Hi all

    I have one criticism PROD remote database I want to check every 10 minutes for its connectivity. If the connection fails then an email and a text Message is sent to me.
    My question is what is the best way to check if the remote database is running?

    Can I use sqlplus system/manager@PROD? But sometimes this has taken so long and suspended. I want the best response time?

    How can I write a pl/sql procedure control connection? What do something like the ff:

    I created a table for my tnsname.ora entries.
    cursor is c1 select dbname from tnsnames_tbl;
    begin
        connect system/[email protected];
        print c1.dbname || 'DB Connection OK';
        exception
           when others;
            print c1.dbname || 'DB Connection Not OK';
        end;
    end;
    Something like that?

    Thank you
    Kinz

    Not really feasible at the level of PL/SQL.

    The reason is that the greatest strength of TCP's robustness. TCP will try as hard as possible to succeed, before failing. It was designed to still work on the severely damaged or broken communication as a result of nuclear infrastructure. A TCP connection can take up to 15 minutes, maybe even more, before failing. It can be as slow as a turtle-, but he's wearing a hardshell. (unlike the UDP, which is the opposite)

    So if you want to test the TCP connectivity, you must design your own custom code to implement your assumptions about the latency of packets, earthquakes and drops and so on.

    Otherwise, you will need to use a standard TCP socket, set a time limit, try to login - and hope for the best.

    This approach, I have demonstrated in {message identifier: = 10111306}.

    If the TCP test works, it means that the listener is in place. Does not mean that the database itself is in place. Which means then using a database link to be tested. And this in turn can hang due to problems with archive record being stuck, not enough idle servers shared, etc..

  • SQL to PL/SQL procedure

    Hello

    I'm trying to convert a sql in a pl/sql procedure. I have a simple as sql "select ename, empno, sal from emp where empno in (7839,7364,1200);

    I need to convert to a pl/sql procedure: exec get_emp_data (7839,7364,1200);

    The number of values passed would be dynamic. I mean, it could be ' exec get_emp_data (7839,7364); "or" exec get_emp_data (7839); "and so on. He needs recover the data accordingly.

    No limit on the number of values of input not passed, but each of them would be values for the column empno only.

    How would I go to do this?

    Thank you

    -Fx

    Welcome to the forums!

    Go to this blog: the Blog of Tom Kyte: varying in lists...

    You can take the solution depending on version provided in the link and then wrap a procedure around it.

    I hope this helps!

  • How to optimize the query with a join of virtual tables

    I'm working on a query that is get the data of virtual tables 2 and b
    one is formed by the Union, all say 4 queries and b is formed by the Union, all say 3 queries
    then these two virtual tables and b are joined on a column common and data are extracted from their part.
    Problem is that there is about 1 minutes each in the two virtual tables has and b. If individual a and b queries virtual takes about 5 seconds to retrieve data
    but the join on column takes about 25 seconds to retrieve data.
    Can someone guide me how to optimize the recovery of joining 2 virtual tables having large data

    Thank you

    Please read these:

    When your query takes too long
    When your query takes too long...

    How to post a SQL tuning request
    HOW to: Validate a query of SQL statement tuning - model showing

  • How to convert the hierarchical query of SQL Server (CTE) to Oracle?

    How to convert the hierarchical query of SQL Server (CTE) to Oracle?

    WITH cte (col1, col2) AS
    (
    SELECT col1, col2
    FROM dbo. [tb1]
    WHERE col1 = 12
    UNION ALL
    SELECT c.col1, c.col2
    FROM dbo. [tb1] AS c INNER JOIN cte AS p ON c.col2 = p.col1
    )
    DELETE one
    FROM dbo. [tb1] AS an INNER JOIN b cte
    ON a.col1 = b.col1

    Hello
    Something like this maybe:

    DELETE FROM dbo.tb1 a
     WHERE EXISTS (
      SELECT 1
        FROM dbo.tb1 b
      WHERE a.co11 = b.col1
          AND a.col2 = b.col2
       START WITH b.col1 = 12
      CONNECT BY b.col2 = PRIOR b.col1)
    

    Although you need to do here is to check that CONNECT it BY SELECT, returns records you wait first, then the DELETION should work too.

  • How to convert this SQL PL/SQL query

    Basically, I need to create an anonymous block that will display the name of each student, family name and the number of students who scored less than test 1 that the student.

    So basically you need to find the number of students scoring less than this particular student and we do it for all students of the table.

    So, for this particular query, I designed my code in SQL

    Select g1.gr_fname, g1.gr_lname, count (*)
    grade g1, g2 grade
    where g1.gr_t1 > g2.gr_t1 and
    G1.std_code = g2.std_code
    G1.gr_fname group, g1.gr_lname;

    But I am unable to get the logic of how to run it in PL/SQL, something missing a minor detail to run the same in PL/SQL

    could someone help me please with the logic.

    Thank you

    You can write it in pl/sql like this

    begin
      for i in (
                select g1.gr_fname, g1.gr_lname, count(*) cnt
                  from grade g1,
                       grade g2
                 where g1.gr_t1 > g2.gr_t1
                   and g1.std_code = g2.std_code
                 group by g1.gr_fname, g1.gr_lname;
               )
      loop
        -- I have just wirtern the output into the buffer. You can do what ever you want here.
        dbms_output.put_line(i.gr_fname||'/'||i.gr_lname||'/'||i.cnt);
      end loop;
    end;
    
  • How to convert Oracle DB SQL?

    Hello everyone, nice to meet you!

    First of all I apologize for:

    -my pretty terrible English

    -the fact that I am a complete novice in databases and that my question may sound like proof full for most of you

    -the fact that there are probably a billion discussions on this subject, but after many hours lost in the research in this forum or elsewhere, I just dropped...

    So now that these points are mentioned, here's my problem with my own green words:

    Goal: Be able to log in and then convert it using SSMA SQL restore an Oracle DB from a dump file (.dmp).

    My first step was to be able to install Oracle Databese Express 11 GR 2.

    Then, I installed MASA and launch it to reach my goal.

    To connect to Oracle, I now have to choose a mode of connection, including one of these two ( https://msdn.microsoft.com/en-us/library/hh313203(v=sql.110).aspx text):

    1. If you select the Standard mode, provide the following values:
      1. In the server name box, type or select the name or the IP address of the database server.
      2. If the database server is not configured to accept connections on the default port (1521), type the port number that is used for connections in the Oracle Server port box.
      3. In the Oracle SID , enter the system identifier.
      4. In the user name box, enter an Oracle account that has the necessary permissions.
      5. In the password box, enter the password for the specified username.
    2. If you select the TNSNAME mode, provide the following values:
      1. Of the login , enter connect (aka TNS) of the database identifier.
      2. In the user name box, enter an Oracle account that has the necessary permissions.
      3. In the password box, enter the password for the specified username.

    .. .but I don't know even how to find the SID of the Oracle... I tried with the name of the server: localhost, Oracle SID: XE and SYSTEM and password, but it didn't work.

    So I tried with the TNSNAME, identifier of connection mode: XE (found on my default tnsnames.ora file), SYSTEM/password and it still does not work.

    It would be really nice of you to reflect on this and share your ideas on how to get through this stage of the process and the weather, you have an idea to do the rest (BD restoration/conversion) too!

    Thank you very much.

    VMAT wrote:

    EdStevens wrote:

    [...] or if the database IS local, an ORACLE_SID incorrectly specified.  [...]

    This is my point of view. I don't know what means the "ORACLE_SID". "XE"? Something else? I don't know where to find it!

    Everything we've seen up to this says that your ORACLE_SID is XE.

    BTW, ORACLE_SID is the name of an environment variable.  The value associated with this variable should be "XE".

    As I said, I'm stuck at level zero here.

    I certainly miss to run a crucial step for, I don't know, to create a standard database where I could connect or something I don't know, but the fact is that I can not even use impdp on my .dmp file because I can't seem to log on before...

    Everything that I did is to install Oracle DB Express and MASA in practice. I missed something to do after that?

    If your installation of Oracle DB Express went well, you should have a database named XE and you should be able to connect to it.

  • How to expose a pl/sql procedure via slot shape of apex

    Hi gurus

    I have a form that is create from a procedure.

    I put the auth to pubic_user if it is available to the public.

    So now I need is to know how to find a way to imitate the button submit and draw the corresponding URL

    while I can expose my PL/SQL via a URL through apex procedure.

    I have attached a screenshot of my form

    Thx for all the help.

    Here's the URL of my pl/sql

    https://Apex.Oracle.com/pls/Apex/f?p=30141:1:5404118417577:

    and I look at the code with tool from dev on chrome for the Send button

    If only show.

    < a href = "javascript:apex.submit ('SUBMIT'); "class ="uButton"id ="B67074418713946955629"role ="button"> < span > Submit </span > < /a >

    So how do I know what return? Thx for all the help

    expose_plsql_via_apex.JPG

    Hi Kazuneric,

    kazuneric wrote:

    https://Apex.Oracle.com/pls/Apex/sdev.verify_user?p_user=Spring9111&P_Code=E7FB725F11A62BAFDCFB28C30653B72B

    I intend to pass the parameter in the URL for a user to click through

    You will find the following useful threads:

    Call a rendering of APEX (EPG) form of procedure within the error

    403 Forbidden error URL the PL/SQL procedure call

    I hope this helps!

    Kind regards

    Kiran

  • How to convert a SQL with variable

    Can Hello, please how I convert the underside with a dominant

    I need to be able to generate a plan to explain it, I think I should use cast.



    SELECT TO_NUMBER (OIL. REBALANCE_ORDER_ID UNIQUE_ID),
    OIL. ORDER_QTY,
    OIL. ORDER_TYPE,
    OIL. ORDER_SIDE,
    OIL. POSITION_TYPE,
    OIL. AVAILABLE_QTY AVAILABLE_QUANTITY,
    OIL. GROSS_AMOUNT ORDER_AMT,
    OIL.NET_AMOUNT NET_AMOUNT,
    OIL. FEE_AMT FEE_AMOUNT,
    OIL. ACCRUED_INTEREST_AMT ACCRUED_INTEREST
    TABLE (: B6) OIL

    >
    I need to be able to generate a plan to explain it, I think I should use cast.

    SELECT TO_NUMBER (OIL. REBALANCE_ORDER_ID UNIQUE_ID),
    OIL. ORDER_QTY,
    OIL. ORDER_TYPE,
    OIL. ORDER_SIDE,
    OIL. POSITION_TYPE,
    OIL. AVAILABLE_QTY AVAILABLE_QUANTITY,
    OIL. GROSS_AMOUNT ORDER_AMT,
    OIL.NET_AMOUNT NET_AMOUNT,
    OIL. FEE_AMT FEE_AMOUNT,
    OIL. ACCRUED_INTEREST_AMT ACCRUED_INTEREST
    TABLE (: B6) OIL
    >
    You're right - mount the bind as the appropriate type. I have a SQL type named emp_table_type so that it works

    explain plan for select * from table(cast (:e1 as emp_table_type))
    

    The models involved are

    CREATE OR REPLACE TYPE SCOTT.emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
      )
    /
    
    CREATE OR REPLACE TYPE SCOTT.emp_table_type as table of emp_scalar_type
    /
    
  • How export (unload) result of the query without running query on sql developer

    Hello

    I want to know how export (unload) result of the query without running query on sql developer.

    I know this way.
    1. execution of query
    2. click on "Download" on the results tab
    http://i.stack.imgur.com/CQ4Qb.jpg


    Is he available unload a query result before the race?

    No, but you can do this ask the developer SQL change however, for other users can vote and add weight to the possible future implementation.

    Kind regards
    K.

  • How to call sql loader control file with in the pl/sql procedure

    Hi friends,

    I am doing a project in relation to the transfer data using queues. In the queue, I'll get a data delimited by tabs in the form of CLOB variable/message. I don't want to keep this dat in the oracle table.
    During the updating of the data in the table.

    1. don't want to write data to a file. (You want to access directly after the specific queue).

    2. as the data is in the form of delimited by tabs, I want to use sql loader concept.

    How can I call the ctrl charger sql file with in my pl/sql procedure. When I searched, most forums recommending the external procedure or a Java program.

    Please guide me on this issue. My preferrence is pl sql, but don't know the external procedure. If no other way, I'll try Java.

    I'm using oracle 9.2.0.8.0.

    Thanks in advance,
    Vimal...

    Or SQL * Loader, or external tables are designed to read data from a CLOB stored in the database. They both work on files stored on the file system. If you don't want the data to be written to a file, you have to roll your own parsing code. It is certainly possible. But it will be much less effective than SQL * Loader or external tables. And it is likely to lead to a little more code.

    The simplest possible thing that might work would be to use something like Tom Kyte string tokenization package to read a line in the CLOB, divide the component parts and save the different chips in a significant collection (i.e. an object type or a record type that matches the table definition). Of course, you need manage things like the conversion of strings to numbers or dates, rejecting the lines, writing to log files, etc.

    Justin

Maybe you are looking for

  • Satellite A60-352 - little or no connectivity to the internet

    Okay, to be honest, I'm really bad at using the computer so when it comes to change the internet or install... It's bad I have the computer more old never the SA60-352 probably actually exists is no more in the market, but I need to use it for a whil

  • Reading/Controlling Arduino with iPhone Dashboard

    Hello I'm new using Dashboard OR so please bear with me. I'm working on the installer is a TCP/IP connection between my computer and an Arduino with WiFi shield. The computer has a VI that connects to the Arduino, currently the Arduino is the server

  • Can we create a folder in the internal memory.

    Hi all as file / / /: sdcard can we create a folder in file:///store...which should visible to the user.

  • BlackBerry smartphones can not understand...

    at the top of my blackberry, to the left of the time, right next to the new message envelope, there is a yellow world looking for the thing. It looks like the Explorer, but I can't understand what this means. I searched on my phone and I can't unders

  • WebCenter content get lost after the redeployment of the application

    Hi allWe have a portal web Center running application to our company. After it has been deployed in the production environment, a member of the admin team added some content on some pages using the Oracle WebCenter Portal administration Console. Now,