SQL that passes to the procedure as a parameter query

I'm trying to accomplish what seems so simple and yet I can't do things. I want to pass a sql query via a parameter to a procedure. In this procedure, I want to loop through the results and create options for a selection list. I tried to use EXECUTE IMMEDIATELY, sliders, SYS_REFCURSOR, etc, but nothing seems to be quite right. Any ideas on how to achieve this? Thank you!


PROCEDURE Dropdown
(
  nam
IN VARCHAR2,
  qry
IN VARCHAR2,
)
IS
  html VARCHAR2
(1000);
BEGIN
  html
:= '<select id="test" name="test">';

 
/* ?? */

  html
:= html || '<option value="' || val || '">' || descrip ||'</option>';

  html
:= html || '</select>';
  htp
.p(html); 
END Dropdown;

A variation would be to use DBMS_SQL to ANALYZE and DESCRIBE the results.

In this way, you can check to make sure that you have found a SELECT statement that returns only 2 columns.

MK

Tags: Database

Similar Questions

  • Anyone wishing to share SQL that will pull the text of the business unit that is attached to a language specification?

    Anyone wishing to share SQL that will pull the text of the business unit that is attached to a language specification?

    Select s.SpecNum, s.IssueNum, SpecSummary n.name s

    inner join gsmApprovedUsage on s.SpecID = au.fkSpecID and au.fkSpecID as 5816% AU '

    gsmApprovedUsageBUJoin j j.fkApprovedUsage = au.pkid inner join

    inner join commonBusinessUnitName on n.fkSpecBusinessUnit = j.fkBusinessUnit and n.langID = 0 n;

  • 15 n series Pavilion: Pavilion 15 computer n097sa laptop. L and R audio that passes through the two speakers at the same time.

    Hi, so basically, I just upgraded to this laptop 15 n097sa (new to me) of my old sucks, and it's so much better.
    Only, I just noticed that when his left or right is out at the same time the two speakers. I noticed you access with your headphones. the left certainly comes out the left a little more and the right thus respectively, but they always come out of two speakers much.
    To clarify that, the only left channel is coming from the two speakers at the same time, instead of just the left speaker. And similarly for the right channel.
    I only did a real test on youtube videos of stereo test, even I tested it on my old acer before, that came out of the correct speakers.
    I have a sound dts, no matter who is and it could be reduced to just change the settings, but I don't think that's it.
    Does anyone else have or had this problem too?
    I know I'm a sucker for pc, but please go steady on me, your.
    Win pro 8.1.

    will you please and thank you very much indeed, couch.

    Malygris1 wrote:

    Hi there @SofaQueue

    Welcome to the Forums of HP Support! It's a good place to find the help you need, so many other users, the HP experts and other members of the support staff.

    I understand that you are having problems with the audio balance on your laptop, and I am happy to help you with this. First of all, I would say reinstall the audio driver.

    ETC.

    Let me know if you still have problems and view the details of what happens.

    I will mark it as resolved now. Very useful, thanks.
    What I found was the following: I have really no problem at all, it was the parameters of the audio DTS after all.
    Simply turn off the audio improvements and testing showed once again that's all it was.

    Thanks again though, nice to see people are willing to help so much!

    Edit: Is PS it OK to mark my answer as a solution? I don't care if or whatnot, it just is the right answer and makes sense. I'll do it if he lets me.

  • HP Officejet Pro 8600 Premium - black line on pages that pass through the document feeder

    Hello! I have a HP Officejet Pro 8600 Premium. Any time that I scan, fax or copy via the document feeder a black line appears on the document created. Anyone know how to fix this?

    Thank you in advance,

    Lynn

    Hello Lynn_Fritschi.

    I see that you encounter errors of quality on your prints when you use the Officejet Pro 8600.

    Here are two links that should be useful for you. The first is to support your product page and the second is a document that explains errors output quality and the ways to solve them.

    HP Officejet Pro 8600 Support

    Vertical stripes, lines or streaks on Copies, faxes or scan

    Please let me know if they help you.

    -Chauntain

  • good SEO of the elements being passed to the procedure.

    I'm moving the values of the following page: P3_LAST_NAME and: P3_BUSINESS_UNIT in a procedure, but they are not saved in the database. I can hardcode a value and it works. Is it good SEO as shown below?

    DECLARE
    v_return_string VARCHAR2 (500);
    BEGIN
    v_return_string: = ddb_utils_pkg.f_cs_box_assign(:P3_LAST_NAME,2,:P3_BUSINESS_UNIT);

    end;


    Thank you

    Chris

    How are you points P3_LAST_NAME and P3_BUSINESS_UNIT defined?

    In my last example, P297_BUDGET_HEADER_SEQ, display text (State record)

    Source used - always, replacing all existing...
    Source - type static assignment...

  • The procedure to upgrade SQL Express to SQL 2005 for VC4.1

    Hello

    Weeks, I successfully passed the VC to 4.1 with the bundled SQL Express. But now I need to spend the VC to save the log more view.  If an upgrade to DB from SQL Express to SQL 2005/2008 is reqired.

    I'm totally unfamiliar with SQL, could someone provide the procedure or steps in detail for the upgrade SQL database in VC 4.1?

    Thank you

    Mark

    See also this KB:

    http://kb.vmware.com/kb/7960893 - movement of the VirtualCenter SQL database

  • SQL that are based on the values of the corresponding fields.

    Hi my name is Hawk.

    I'm new to the Forum, and I wanted to just introduce myself and say hi.

    I have a daunting task to summarize values and filling in a spreadsheet with columns. I have 600 lines to go, and I was wondering if

    someone knows a way in sql to sum (a body of numbers) based on the existence of a value being the same on another field of varchar2.

    For example, here is an example of the data table that I have.

    CREATE TABLE EXAMPLE

    ("FIRSTNAME", VARCHAR2 (20 BYTE),

    VARCHAR2 (20 BYTE) "LASTNAME."

    NUMBER OF "SUMVALUE."

    NUMBER OF "ROW_ID".

    );

    Insert into SAMPLE (FIRSTNAME, LASTNAME, SUMVALUE, ROW_ID) values ('Charlie', 'chocolate factory', 100, 1);

    Insert into SAMPLE values (FIRSTNAME, LASTNAME, SUMVALUE, ROW_ID) ('Johnny', 'Desire', 200, 2);

    Insert into SAMPLE (FIRSTNAME, LASTNAME, SUMVALUE, ROW_ID) values ('P', 'Frankenstein', 300, 3);

    Insert into SAMPLE (FIRSTNAME, LASTNAME, SUMVALUE, ROW_ID) values ("Charlie", "chocolate factory", 400, 4);

    Insert into SAMPLE (FIRSTNAME, LASTNAME, SUMVALUE, ROW_ID) values ("Charlie", "chocolate factory", 500, 5);

    and Yes, I have 600 lines having to ask and things to the top score on manually, it's just bs data...

    So what I do is the following.

    Write some sql that will total the number field (sumvalue) based on data with firstname = lastname = chocolate factory and Charlie.

    It seems so simple, but still I can not understand how do.

    Is that what I'm trying to make sense?  Also, I hope this is the right place to post this. I looked on this before I posted to make sure.

    Hawk.

    Hi, Hawk,

    Here's one way:

    SELECT SUM (sumvalue) AS total_sumvalue

    SAMPLE

    WHERE firstname = 'Charlie '.

    AND lastname = 'chocolate factory '.

    ;

    Welcome to the forum!

    There are those who use the forum for years and have not yet learned to post CREATES instructions TABLE and INSERT for their sample data, as you did.  Keep up the good work!

    You should also post the exact results you want from the data provided.  For example

    TOTAL_SUMVALUE

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

    1000

    (this is what produces the query I posted).  As you can see, without that David and I came with 2 different interpretations of what you want and maybe aren't exactly what you need.

  • The procedure with parameter output from test object type

    I have the sub object created with spec and body type.

    I need to test the procedure seen ino parameter object type.

    could you please help me test the procedure!

    create or replace type typ_obj_test as object
    (
       a_date   date,
       a_type   varchar2(10),
       a_status varchar2(2),
       descr    varchar2(10),
       a_id     number(10),
       constructor function typ_obj_test(a_date   date
                                        ,a_type   varchar2 default null
                                        ,a_status varchar2 default null
                                        ,descr    varchar2 default null
                                        ,a_id     number default null) return self as result
    );
    /
    create or replace type body typ_obj_test is
       constructor function typ_obj_test(a_date   date
                                        ,a_type   varchar2 default null
                                        ,a_status varchar2 default null
                                        ,descr    varchar2 default null
                                        ,a_id     number default null) return self as result is
          v_test varchar2(1);
          v_id   number(10);
       begin
          self.a_date   := a_date;
          self.a_type   := a_type;
          self.a_status := a_status;
          self.descr    := descr;
          self.a_id     := a_id;
          return;
       end;
    end;
    /
    create or replace procedure p_obj_test(p_obj_param in out typ_obj_test) is
    begin
       dbms_output.put_line('Checking the object type' || p_obj_param.a_date || '@' || p_obj_param.a_type || '@' || p_obj_param.a_status || '@' ||
                            p_obj_param.descr || '@' || p_obj_param.a_id);
    end;
    /
    

    You seem to be missing a table that could hold the object. See the next topic, especially the line # 43:

    Connected to:
    Oracle Database 11g Release 11.2.0.3.0 - 64bit Production
    
    SQL> create or replace type typ_obj_test as object
      2  (
      3    a_date  date,
      4    a_type  varchar2(10),
      5    a_status varchar2(2),
      6    descr    varchar2(10),
      7    a_id    number(10),
      8    constructor function typ_obj_test(a_date  date
      9                                      ,a_type  varchar2 default null
    10                                      ,a_status varchar2 default null
    11                                      ,descr    varchar2 default null
    12                                      ,a_id    number default null) return self as result
    13  );
    14  /
    
    Type created.
    
    SQL> create or replace type body typ_obj_test is
      2    constructor function typ_obj_test(a_date  date
      3                                      ,a_type  varchar2 default null
      4                                      ,a_status varchar2 default null
      5                                      ,descr    varchar2 default null
      6                                      ,a_id    number default null) return self as result is
      7        v_test varchar2(1);
      8        v_id  number(10);
      9    begin
    10        self.a_date  := a_date;
    11        self.a_type  := a_type;
    12        self.a_status := a_status;
    13        self.descr    := descr;
    14        self.a_id    := a_id;
    15        return;
    16    end;
    17  end;
    18  /
    
    Type body created.
    
    -- Create a Nested table type array of above object type
    SQL> create or replace type nt_typ_obj_test as table of typ_obj_test;
      2  /
    
    Type created.
    
    -- Keep in out parameter's type as the nested table type
    -- modified the proc to do loop so that multiple records can be passed via object type
    SQL> create or replace procedure p_obj_test(p_obj_param in out nt_typ_obj_test) is
      2  begin
      3  for i in p_obj_param.first..p_obj_param.last
      4  loop
      5    dbms_output.put_line('Checking the object type' || p_obj_param(i).a_date || '@' || p_obj_param(i).a_type || '@' || p_obj_param(i).a_status || '@' ||
      6                          p_obj_param(i).descr || '@' || p_obj_param(i).a_id);
      7  end loop;
      8  end;
      9  /
    
    Procedure created.
    
    --Call the procedure
    SQL> set serveroutput on
    SQL> declare
      2  i_nt_typ nt_typ_obj_test ;
      3  begin
      4  i_nt_typ:=nt_typ_obj_test(typ_obj_test(sysdate,'A','Y','Descr',23),typ_obj_test(sysdate,'X','Z','ewe',55));
      5  p_obj_test(i_nt_typ);
      6  end;
      7  /
    Checking the object type26-MAR-15@A@Y@Descr@23
    Checking the object type26-MAR-15@X@Z@ewe@55
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
  • Invalid identifier in the procedure

    Hi all

    I have an example of how I'm trying to pass two arguments.

    Unfortunately, when I do that, I get the below error:
    ORA-00904: "V_END_DATE": invalid identifier
    ORA-06512: at "PROCEXAMPLE", line 10
    ORA-06512: at line 2

    Before I remove the rest of my hair, is - it possible to let me know what goes wrong? I know what means the error but I don't see where I have, I got an invalid identifier. Even on line 10. : P


    ARGUMENTS TO PASS TO THE PROCEDURE
    BEGIN
        procExample (   p_start_date => '01/01/2011', 
                            p_end_date => '07/01/2011') ;
    END  
    ;
    PROCEDURE
    {
    CREATE OR REPLACE PROCEDURE procExample (p_start_date in varchar2, p_end_date in varchar2) is
    date of v_start_date;
    date of v_end_date;

    Start
    v_start_date: = to_date(p_start_date,'dd/mm/yyyy');
    v_end_date: = to_date(p_end_date,'dd/mm/yyyy');

    EXECUTE IMMEDIATE ' CREATE TABLE test_a AS
    SELECT v_start_date, v_end_date FROM DUAL';
    end procExample;
    }

    Hello

    When you use EXECUTE IMMEDIATE, you pass a string to the database must be executed in the database engine, where nothing is known about local variables in your procedure, such as v_start_date. There are ways to pass variables in an EXECUTE IMMEDIATE statement, but not in the context of the deifinitions column. About the closest thing you can do is:

    CREATE OR REPLACE PROCEDURE procExample ( p_start_date IN VARCHAR2
                                            , p_end_date   IN VARCHAR2
                             )
    IS
        sql_txt         VARCHAR2 (500);
    begin
        sql_txt := 'CREATE TABLE test_a '
                 || 'AS '
             || 'SELECT  TO_DATE (''' || p_start_date || ''', ''dd/mm/yyyy'') AS dt_1 '
             || ',       TO_DATE (''' || p_end_date   || ''', ''dd/mm/yyyy'') AS dt_2 '
             || 'FROM     dual';
    
        dbms_output.put_line (sql_txt || ' = sql_txt');     -- For debugging
    
        EXECUTE IMMEDIATE sql_txt;
    end procExample;
    /
    SHOW ERRORS
    

    Creating tables in procedures is not usually a good idea. Why do you need to do this in PL/SQL?

    Since you know that the columns are DATEs, you can simply create the table with two columns DATE and not use CREATE TABLE As. It would be less prone, although you would need to separate INSERT statements.
    Don't forget to provide names for the columns.

    Whenever you write dynamic SQL code, it is a good idea to put all the text in a variable, so that you can view before you run, for debugging purposes. After the test is finished, you can comment or remove the call to dbms_output.put_line.

  • The "procedure entry point sqlite3_prepare_v2 could not be found in the dynamic link library sqlite3.dll.

    I try to run Rosetta Stone software, however whenever I click on the application link (or shortcut) this annoying message keeps popping up that, according to the "procedure entry point sqlite3_prepare_v2 could not be found in the dynamic link library sqlite3.dll. I studied this before, and there seems to be a problem with Apple/iTunes. But when I deleted iTunes, this question always arises. If there is someone out there or in the it Department which can be useful with this question please help!

    Thank you in advance!

    Hello

    1. are you able to launch the program?

    2. What is the version of iTunes installed on your computer?

    Please follow the methods.

    Method 1:

    Run the Microsoft fixit to uninstall iTunes and check.

    See the link.

    http://support.Microsoft.com/mats/program_install_and_uninstall/

    Method 2:

    Copy the file in the Common Files\Apple\Apple Application Support folder in the Common Apple Mobile Device Support folder and check if it works very well.

  • the exception in the procedure call management

    Hello

    I have a package where currently make phone calls to private public process procedures.

    and the senario is: -.

    create package body p_tst
    is

    ex_failed exception;

    -It's private proc
    procedure p_private
    is
    Start
    .
    .
    raise ex_failed;
    exception
    When ex_failed
    then
    lift;
    .........
    end p_private;

    procedure p_public
    is
    Start
    ....
    -nomaking appeal to the private sector
    -procedure
    p_private;

    -Here, I need to catch
    -the exception thrown
    -past of callee
    -procedure
    When ex_failed
    ...
    end p_public;

    end;

    Basically, I want to catch any exception of procedure called passed to the procedure call and raise the same exception by calling procedure.

    is it possible to intercept the exception even in the calling procedure?

    Yes, p_private throws the exception, it will be taken by p_public and the program stops after dbms_output.

  • What is the setting of State regarding the procedures of the Oracle

    You seem like a good place to ask.

    explain the term "Parameter Status" regarding the procedures for Oracle? I am a student rehearsal-review and can't answer

    from what I understand this has nothing to do with the procedures

    a report parameter indicates the overall percentage of a work complete "DataPump.

    *-
    You're right, 'Parameter Status' nothing to do with procedures, unless it's a real parameter called status defined (used) in a particular procedure.

    However, the 'status' column in table _OBJECTS all THEwill show if a procedure is "VALID" or "INVALID" according to whether it compiled without error (s).

    Good luck! : p
    +

  • make sure that the procedure, called pl/sql from apex DURATION

    Hi gang,.

    I was wondering what the thoughts of the people where assuring him a packaged procedure is called in a session of runtime Apex, as opposed to sql * more or elsewhere.

    For example, how apex_mail.send to validate and output the following if executed from sql * more:
    ORA-20001: this procedure must be called from a session of the application.

    A simple call to check v ('APP_USER') wouldn't is not null enough?

    See you soon,.

    ScottWE

    Hello

    I think you could use the APEX_CUSTOM_AUTH.IS_SESSION_VALID function
    http://download.Oracle.com/docs/CD/E14373_01/apirefs.32/e13369/apex_auth.htm#BABHDFII

    Example of

    CREATE OR REPLACE PROCEDURE my_procedure(p_poaram1 VARCHAR2)
    AS
    BEGIN
    IF APEX_CUSTOM_AUTH.IS_SESSION_VALID THEN
     -- do stuff here when session is valid
    
    ELSE
     raise_application_error(20001,'Session is not valid');
    END;
    

    BR, Jari

  • How to assign values to the nested table and passes as a parameter for the procedure?

    How to assign values to the nested table and passes as a parameter for the procedure?

    Here are the object and its type

    create or replace type test_object1 as an object
    (
    val1 varchar2 (50).
    val2 varchar2 (50).
    VARCHAR2 (50) val3
    );


    create or replace type test_type1 is table of the test_object1;


    create or replace type test_object2 as an object
    (
    val1 varchar2 (50).
    val2 varchar2 (50).
    VARCHAR2 (50) val3
    );


    create or replace type test_type2 is table of the test_object2;


    GRANT ALL ON test_object1 to PUBLIC;


    GRANT ALL ON test_type1 to PUBLIC;


    GRANT ALL ON test_object2 to PUBLIC;


    GRANT ALL ON test_type2 to PUBLIC;

    Here is the table object type:

    create the table test_object_tpe
    (
    sl_num NUMBER,
    Description VARCHAR2 (100),
    main_val1 test_type1,
    main_val2 test_type2
    )


    NESTED TABLE main_val1 STORE AS tot1
    NESTED TABLE main_val2 STORE AS earlier2;


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

    Here is the procedure that inserts values into the nested table:

    PROCEDURE INSERT_TEST_DATA (sl_num in NUMBER,
    Description in VARCHAR2,
    p_main_val1 IN test_type1,
    p_main_val2 IN test_type2
    )
    IS
    BEGIN

    FOR rec in p_main_val1.first... p_main_val1. Last
    LOOP

    INSERT INTO xxdl.test_object_tpe
    (
    sl_num,
    Description,
    main_val1,
    main_val2
    )
    VALUES
    (
    sl_num
    description
    test_type1 (test_object1)
    p_main_val1 .val1 (CRE),
    p_main_val1 .val2 (CRE),
    p_main_val1 .val3 (rec)
    )
    )
    test_type2 (test_object2 (p_main_val2 .val1 (CRE),
    p_main_val2 .val2 (CRE),
    p_main_val2 .val3 (rec)
    )
    )

    );

    END LOOP;

    commit;

    END INSERT_TEST_DATA;

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

    Here are the block anonymoys what values attributed to the object type and pass values in the procedure:

    Set serveroutput on;

    declare

    p_sl_num NUMBER: = 1001;
    p_description VARCHAR2 (50): = 'Test Val1;

    inval1 test_type1: = test_type1();
    inval2 test_type2: = test_type2();

    Start


    inval1 (1) .val1: = "testx1";
    inval1 (1) .val2: = "testx2";
    inval1 (1) .val3: = "testx3";

    inval2 (1) .val1: = "testy1";
    inval2 (1) .val2: = "testy2";
    inval2 (1) .val3: = "testy3";

    CSI_PKG. INSERT_TEST_DATA (sl_num = > p_sl_num,)
    Description = > p_description,
    p_main_val1 = > inval1,
    p_main_val2 = > inval2
    );

    end;
    /
    Someone can correct me.

    Thank you
    Lavan

    Thanks for posting the DOF and the sample code but whenever you post provide your Oracle version 4-digit (result of SELECT * FROM V$ VERSION).
    >
    How to assign values to the nested table and passes as a parameter for the procedure?
    >
    Well you do almost everything bad that could be hurt.

    Here is the code that works to insert data into your table (the procedure is not even necessary).

    declare
    p_sl_num NUMBER := 1001;
    p_description VARCHAR2(50) := 'Testing Val1';
    inval1 test_type1 := test_type1();
    inval2 test_type2 := test_type2();
    begin
    inval1.extend();
    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    inval2.extend();
    inval2(1) := test_object2('testy1', 'testy2', 'testy3');
    
    INSERT INTO test_object_tpe
    (
    sl_num,
    description,
    main_val1,
    main_val2
    )
    VALUES
    (p_sl_num, p_description, inval1, inval2);
    commit;
    end;
    /
    

    See example 5-15 making reference to an element of nested Table Chapter 5 using PL/SQL collections and records in the PL/SQL doc
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/Collections.htm#CJABEBEA

    1. you don't even have the procedure because it is a simple INSERTION in the table you can do directly (see my above code)

    inval1(1).val1 := 'testx1';
    

    Since you have not yet created all the elements, there is no element 1 "inval1". You need EXTEND the collection to add an element

    inval1.extend();
    

    And then, there is an empty element, but "inval1" is a container for objects of type 'test_object1' not for scalars as "val1", "val2", and "val3".
    If you can not do

    inval1(1).val1 := 'testx1';
    

    You must create an instance of 'test_object1 '.

    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    

    And so on for the other collection

    You don't need the procedure (as my code example shows), but once you fill in the variables correctly it will work.

  • Do not pass the datetime value to store the procedure

    Hello

    I have a stored procedure that will receive the date passmeter and I write it as follows:

    < IsDefined ("form.yy") cfif >

    < cfsqltype cfprocparam = "CF_SQL_TIMESTAMP" value = "#CreateDate (form.yy, form.mm, form.dd) #" >

    < cfelse >

    < cfprocparam cfsqltype = "CF_SQL_TIMESTAMP" value = "null" null = "yes" >

    < / cfif >

    When I do not seized the day, it runs correctly.

    However, it returns me error when I entered the day:

    Conversion failed when converting datetime from character string.

    How can I solve the problem?

    Finally, I find that I can pass the parameter correctly. The problem is the dynamic sql in the stored procedure and already solved using CAST and CONVERT. Thank you.

Maybe you are looking for

  • Audio book on iPhone 4S

    I bought an audio book on my Mac, but I can't find it on my iPhone. In iTunes, there is no option for audio books. Can you help me please?

  • New application of Crayola does not install

    It's the kind of thing that really gripes me.  The new 'App of the week,"yet another application of Crayola, is probably ready to download.  I push the button downoad and, after an hour or two, I like the program is downloaded and installed.  However

  • Add account causes the desktop icons disappear

    I added a second administrator account on my computer windows vista laptop and when I connect to my original account almost all my desktop icons disappear.  I do a restore to a previous point and they come back but I lose the second account.  Any sug

  • xvidcore.dll not found

    Try to watch an AVI video file from my camera and an error box pops up saying xvidcore.dll not found. I'm using vista on a computer hp laptop. Windows vista Home premium sp2.HP G60 laptopDual-core AMD Athlon QL-62 2.00 GHz3.00 GB Ram32-bit operating

  • Error 0 x 80070020 while trying to upgrade to Windows 10

    Original title: iWINDOWS 10 UPDATE UM Hey guys can help you with the problem regarding on my installation of windows 10 there seems to be an error code 0 x 80070020 I didn't know why? can someone lend a good idea how to solve this problem, thank you