Pl Dynamic sql help needed

Hello Everyone
I am using database 11g. Can someone pl suggest what are the rules for putting single quotes for dynamic sql like
1) how many single quotes before/after a sql statement .
2) Rules for putting single quotes if there exists i) a variable in the sql statement
ii) a constant for e.g 100 in the sql statment.
If you could give the answers with a simple select statement, it will be even better !!!
Thanks and regards
Gautam

ms wrote:
Hello Everyone
I am using database 11g. Can someone pl suggest what are the rules for putting single quotes for dynamic sql like
1) how many single quotes before/after a sql statement .
2) Rules for putting single quotes if there exists i) a variable in the sql statement
ii) a constant for e.g 100 in the sql statment.
If you could give the answers with a simple select statement, it will be even better !!!
Thanks and regards
Gautamwrite the SQL statement as you would for any SQL client & enclose it using Q-quote
http://askanantha.blogspot.com/2007/12/q-quote-operator-introduced-in-oracle.html
Handle:     ms
Status Level:     Newbie
Registered:     Jun 3, 2007
Total Posts:     46
Total Questions:     17 (17 unresolved)
WOW!
*NEVER got any answer in 5+ years & still wasting time here again, still!
You must be an eternal optimist.
I hope I get credited for your FIRST answer.

Similar Messages

  • Dynamic SQL help!

    I'm trying to build a update statement with different operator which setup from a table and passed. Not sure how to build it. Please help
    PROCEDURE my_update
      p_id            IN NUMBER,
      p_var1          IN NUMBER,
      my_value        IN VARCHAR2,
      my_operator     IN VARCHAR2,
      x_return_status OUT VARCHAR2,
      x_errors        OUT VARCHAR2
    ) IS
      l_dynamic_string VARCHAR2(4000);
    BEGIN
    l_dynamic_string := table_b.col2 ||
                        rec.my_operator  /* value as: "=" OR "LIKE" */ ||
                        my_value /* VALUE AS "2233"  OR "900%" */
      UPDATE table_b
         SET col1 = ''
       WHERE id = p_id
         AND l_dynamic_string
         AND id = (SELECT table_a.id
                     FROM table_a
                    WHERE id = p_id
                      AND col_a = p_var1);
    EXCEPTION
      WHEN OTHERS THEN
        NULL;
    END my_update;

    Hi,
    What you posted can probably be done without dynamic SQL. If the expression after LIKE does not conatin a wild-card, then LIKE behaves just like =. You can probably arrange things so that the query always uses LIKE.
    If you need dynamic SQL, then use EXECUTE IMMEDIATE to perform it.
    I think you want something like this:
    PROCEDURE my_update
      p_id            IN NUMBER,
      p_var1          IN NUMBER,
      my_value        IN VARCHAR2,
      my_operator     IN VARCHAR2,
      x_return_status OUT VARCHAR2,
      x_errors        OUT VARCHAR2
    ) IS
      l_dynamic_string VARCHAR2 (4000);
      l_update_txt        VARCHAR2 (4000);
    BEGIN
        l_dynamic_string := table_b.col2 || ' '     -- If my_operator is LIKE you'll need a space here
                                        || my_operator               /* value as: "=" OR "LIKE" */
                             || Q'< '>'
                             || my_value            /* VALUE AS "2233"  OR "900%" */
                             || Q'<' >'
        l_update_txt := 'UPDATE table_b'
                    || '   SET col1 = NULL'
                  || ' WHERE id = p_id'
                    || '   AND ' || l_dynamic_string
                    || '   AND id = (SELECT table_a.id'
                     || '                     FROM table_a'
                     || '             WHERE id = p_id
                     || '               AND col_a = p_var1)';
        dbms_output.put_line (l_update_txt || ' = l_update_txt in my_update');
    --  EXECUTE IMMEDIATE  l_update_txt;
    --     No EXCEPTION hider
    END my_update;While writing dynamic SQL, it's a good idea to display the dynamic text. I used put_line to do that. Remember to comment out (or remove) the display code when testing is finished.
    Notice that the EXECUTE IMMEDIATE command is commented out. Only after you've tested some, and you think l_update_txt is correct, should you un-commnet that line.
    Never say "EXCEPTION WHEN OTHERS THEN NULL;"
    Error messages help you, especially duting development when you're likely to have lots of coding errors.
    If you really need to keep the program running after encountering certain errors, then it's okay to have an EXCEPTION block, but your use of either "WHEN OTHERS" or "THEN NULL" should be very limited, and you should not use both of them together.

  • Dynamic Action-help needed

    Hi ,
    My requirement is in dynamic Action I need to delimit all records in a Subtype of an Infotype and create New record for these records with BEGDA as ENDDA + 1 of the delimited records.
    Iam able to delimit all records in the Subtype but , Iam not able to create new records.
    My code for delimiting is as given below, in T588Z,
    9901 2 06 801 P P9901-SUBTY='2'
    9901 2 06 802 P PSYST-IOPER='MOD'
    9901 2 06 803 P P9901-STATS='X'
    9901 2 06 804 P P9901-PREAS='91'
    9901 2 06 805 F DELIMIT_DTE(ZHSRAS_T588Z_9901)
    9901 2 06 806 W P9901-ENDDA=RP50D-ZZDATE3
    9901 2 06 807 I MOD,9901,3
    9901 3 06 808 P SY-UCOMM='UPD'
    9901 3 06 809 F DELIMIT_DTE(ZHSRAS_T588Z_9901)
    9901 3 06 810 W P9901-ENDDA=RP50D-ZZDATE3
    The above code is working fine.
    My code for creating new record is as given below, even though the control is oing to the subroutine, INS statement is not working, and hence new record is not getting created.
    9901 3 06 811 P SY-UCOMM='UPD'
    9901 3 06 812 P PSAVE-ENDDA<>P9901-ENDDA
    9901 3 06 813 P P9901-STATS<>'X'
    9901 3 06 814 I INS,9901,3
    9901 3 06 815 F BEGIN_DATE(ZHSRAS_T588Z_9901)
    9901 3 06 816 W P9901-BEGDA=RP50D-ZZDATE3
    9901 3 06 817 W P9901-ENDDA='99991231'
    Kindly help me on this.
    Thanks in Advance

    hi,
    thankyou for all ur valuable replies.
    Time constraint for this custom infotype is 2.
    It is not allowing to create a new subtype record if 1 exists.
    Here scenerio is
    Each Subtype ,ie, Subtp 2 ad 3 has got 4 records each with distinct OBJPS field.
    when STATS field of subtype 2 is changed for any 1 record in Subtype 2, corresponding record in Subtype 3 should get delimited .
    And, rest of the records of Subtype 3 should get created again with new start date.
    The code I have written for this is ,
    9901     2          06     800           *BEG*****DEATH OF WIDOW*****************
    9901     2          06     801     P     P9901-SUBTY='2'
    9901     2          06     802     P     PSYST-IOPER='MOD'
    9901     2          06     803     P     P9901-STATS='X'
    9901     2          06     804     F     DELIMIT_DTE(ZHSRAS_T588Z_9901)
    9901     2          06     805     W     P9901-ENDDA=RP50D-ZZDATE3
    9901     2          06     806     *     ****PSAVE-ENDDA<>P9901-ENDDA
    9901     2          06     807     F     LOCK_REC3(ZHSRAS_T588Z_0015)
    9901     2          06     808     I     <b>MOD,9901,3,P9901-OBJPS,(P9901-BEGDA),(P9901-ENDDA)</b>
    9901     2          06     812     *     *BEGCREATE NEW REC FOR SURVIVING WIDOWS******
    9901     2          06     813     *     *
    9901     2          06     814     P     P9901-STATS<>'X'
    9901     2          06     815     F     BEGIN_DATE(ZHSRAS_T588Z_9901)
    9901     2          06     816     W     P9901-BEGDA=RP50D-ZZDATE3
    9901     2          06     817     W     P9901-ENDDA='99991231'
    9901     2          06     818     I     <b>COP,9901,3,P9901-OBJPS,(P9901-BEGDA),(P9901-ENDDA)</b>
    9901     2          06     819     *     *ENDCREATE NEW REC FOR SURVIVING WIDOWS*****
    9901     2          06     830     *     ***END*****DEATH OF WIDOW*****************
    Control is going to all routines, but
    MOD,9901,3,P9901-OBJPS,(P9901-BEGDA),(P9901-ENDDA)  and
    COP,9901,3,P9901-OBJPS,(P9901-BEGDA),(P9901-ENDDA) is not working.
    Message was edited by: Shahana Shahul
    Message was edited by: Shahana Shahul

  • Dynamic SQL Help - Getting Errors

    Basically I have a table with employee data, and I'm trying to create a dynamic PL / SQL block that creates a new table and copies over the data from employee table to the new one.
    I'm teaching myself dynamic SQL so this is practice. Please don't offer "better solutions" because I'm sure there are plenty - I'm just looking to complete the code as is so I better understand this query language.
    Here is my code:
    set serveroutput on size 10000
    declare
    cursor c is
    select table_name, tablespace_name
    from user_tables where table_name = 'EMP';
    cursor c2 is
    select table_name, column_name, data_length, data_type, data_precision
    from user_tab_cols where table_name = 'EMP';
    cursor c3 is
    select *
    from emp;
    counter number(3);
    counter := 0;
    begin
    for i in c loop
    if (counter = 0) then
    create table emp2;
    insert into emp2 table_name, tablespace_name;
    for i in c2 loop
    insert into emp2 table_name, column_name, data_length, data_type, data_precision;
    counter := counter + 1;
    end loop;
    end loop;
    for i in c3 loop
    insert into emp2 empno, ename, job, mgr, hiredate, sal, comm, deptno;
    end loop;
    end;
    Here are my errors:
    Error starting at line 3 in command:
    declare
    cursor c is
    select table_name, tablespace_name
    from user_tables where table_name = 'EMP';
    cursor c2 is
    select table_name, column_name, data_length, data_type, data_precision
    from user_tab_cols where table_name = 'EMP';
    cursor c3 is
    select *
    from emp;
    counter number(3);
    counter := 0;
    begin
    for i in c loop
    if (counter = 0) then
    create table emp2;
    insert into emp2 table_name, tablespace_name;
    for i in c2 loop
    insert into emp2 table_name, column_name, data_length, data_type, data_precision;
    counter := counter + 1;
    end loop;
    end loop;
    for i in c3 loop
    insert into emp2 empno, ename, job, mgr, hiredate, sal, comm, deptno;
    end loop;
    end;
    Error report:
    ORA-06550: line 14, column 13:
    PLS-00103: Encountered the symbol "=" when expecting one of the following:
    constant exception <an identifier>
    <a double-quoted delimited-identifier> table long double ref
    char time timestamp interval date binary national character
    nchar
    The symbol "<an identifier>" was substituted for "=" to continue.
    ORA-06550: line 19, column 7:
    PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
    ( begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifi
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause:    Usually a PL/SQL compilation error.
    *Action:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Start reading the Documents
    There are basic errors in your code, some are pointed out below
    declare
      cursor c is
        select table_name, tablespace_name
        from user_tables where table_name = 'EMP';
      cursor c2 is
        select table_name, column_name, data_length, data_type, data_precision
        from user_tab_cols where table_name = 'EMP';
      cursor c3 is
        select *
        from emp;
      counter number(3);
      counter := 0; --"You cannot initiate variable like this"
    begin
      for i in c loop
       if (counter = 0) then
         create table emp2; --"You cannot create tables directly in PL/SQL. Need to use dynamic SQL.Syntax also wrong. "
         insert into emp2 table_name, tablespace_name; --"Values caluse missing"
         for i in c2 loop
            insert into emp2 table_name, column_name, --"Values caluse missing"
               data_length, data_type, data_precision; --"Record syntax not used"
            counter := counter + 1;
      end loop;
      end loop;
      for i in c3 loop
        insert into emp2 empno, ename,
         job, mgr, hiredate, sal, comm, deptno; --"Values caluse missing"
      end loop;
    end;

  • Grouping Rules in PL/SQL Help needed

    Hi I have a requirement where I wan to group based on the below scenario
    I have a Table_A
    Table_A strcuture:
    create table table_a
    code number,
    name varchar2 (100),
    city varchar2 (100),
    dept varchar2 (100));;
    insert into table_a
    values
    1,'ABC','EA','A');
    insert into table_a
    values
    1,'ABC','EA1','A');
    insert into table_a
    values
    2,'BCD','EA2','A');
    insert into table_a
    values
    2,'ABC','EA3','A'');
    insert into table_a
    values
    3,'KBC','EA,'A');
    insert into table_a
    values
    3,'ABC','EA,'A');
    wan to group the above table data based on name,city,dept
    I wan the data  as
    1           ABC             EA1    A
                 BCD            EA2     A
    2           BCD            EA2     A
                 ABC            EA3     A
    3           KBC            EA      A
                 BCD            EA      A
    Kindly any help will be needful for me

    This is more of a presentation layer problem I would not handle it in SQL. For example if the presentation layer is SQL Plus you can use BREAK command, like this.
    SQL> select * from table_a;
          CODE NAME       CITY       DEPT
             1 ABC        EA         A
             1 ABC        EA1        A
             2 BCD        EA2        A
             2 ABC        EA3        A
             3 KBC        EA         A
             3 ABC        EA         A
    6 rows selected.
    SQL> break on code
    SQL>
    SQL> select * from table_a order by code;
          CODE NAME       CITY       DEPT
             1 ABC        EA         A
               ABC        EA1        A
             2 BCD        EA2        A
               ABC        EA3        A
             3 KBC        EA         A
               ABC        EA         A
    6 rows selected.
    But if you still wish to do it in SQL the right way is to use ROW_NUMBER like this.
    SQL> clear breaks
    breaks cleared
    SQL>
    SQL> select * from table_a;
          CODE NAME       CITY       DEPT
             1 ABC        EA         A
             1 ABC        EA1        A
             2 BCD        EA2        A
             2 ABC        EA3        A
             3 KBC        EA         A
             3 ABC        EA         A
    6 rows selected.
    SQL> select decode(rno, 1, code) code
      2       , name
      3       , city
      4       , dept
      5    from (
      6           select row_number() over(partition by code order by name) rno
      7                , t.*
      8             from table_a t
      9         )
    10  /
          CODE NAME       CITY       DEPT
             1 ABC        EA         A
               ABC        EA1        A
             2 ABC        EA3        A
               BCD        EA2        A
             3 ABC        EA         A
               KBC        EA         A
    6 rows selected.

  • Creating a byte Array dynamically.Urgent Help needed.

    Hi there,
    I need to create a byte Array with the values
    derived from the array and then am passing this byte array
    to a method.
    Example :
    public static void main(String[] args) throws IOException {
    char chars[] = {'a','j','a','y'};
    byte[] b = {
    (byte) chars[0],(byte) chars[1],(byte) chars[2],(byte) chars[3],
    //** Send name to a server.
    sendRequest(b);
    This is all right.
    But here I know the size of the character array chars.
    If it had more than 4 characters or less than 4,
    is there a way to create the byte array dynamically based on the values in the character array?
    Please can some one help me with creating a byte array on the fly?
    Has anyone understood my question please?
    A response is much much appreciated.

    The actual problem is this.
    The byte array already has some fixed values to it
    and i need to append the values of the character array
    to this byte array
    ie
    char chars[] = {'a','j','a','y'};
    byte b[] = {
    // Predefined values
    (byte) 0x01, (byte) 0x7E, (byte)0x03
    // I have to add the values from the array here
    (byte) chars[0], (byte) chars[1]....
    How can I add these values.? The size of the character array
    can vary

  • SQL HELP NEEDED IN QUERY FOR COUNT

    I Have this Query
    SUM (CASE WHEN b.VET_OTHR_ELIG_CDE IN ('02', '03', '04') THEN 1 END) AS VET_YES,
    SUM (CASE WHEN b.VET_OTHR_ELIG_CDE = '01' THEN 1 END) VET_NO, COUNT (E.ACTV_CDE) AS CNT_ACTV_CDE
    Now i need to Add two more columns from the same Query Showing the count of VET_YES and VET_NO i.e count of TOTAL Veterans And TOTAL Non Veterans
    those two columns i will be using as summary columns in my report.The bolded columns are those which i need to show the total column .anyone please help in this issue ..
    ACTV_DESC ACTV_CDE VET_YES VET_NO CNT_ACTV_CDE
    INACT DUE 13993 2 1 3
    NOW I NEED TO MAKE IT LIKE THIS
    ACTV_DESC ACTV_CDE VET_YES VET_NO CNT_VET CNT_NONVET CNT_ACTV_CDE (This is the total count)
    INACT DUE 13993 2 1 2 1 3
    Thanks in Advance,
    Dev Kishore.T
    Message was edited by:
    Dev Kishore
    Message was edited by:
    Dev Kishore

    Check this link.
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14223/aggreg.htm#sthref1612
    Regards
    Raj

  • Dynamic Calendar help needed

    I am trying to convert a static events calendar to dynamic
    and I have run
    into a couple of snags that I don't seem to be able to figure
    out (darned
    Newbies!)
    The big problem that I am having is to have the Month/Year
    header display
    only one time for all the events in that month.
    The second problem is displaying a range of dates for one
    event (...Sept
    9-12)
    Example:
    September 2006
    Sept 1 - event 1, location
    Sept 9-12 - event 2, location
    Sept 14-16 - event 3, location
    October 2006
    Oct 3-4 - event 1, location
    Oct 23 - event 2, location
    This is the type of calendar I'm trying to dynamisize looks
    like this one
    http://internationalsoaringeaglesministries.org/calendar.htm
    It is not loaded with all sorts of dates so I chose to
    display only dates
    with events on them.
    Any help would be much appreciated!!
    Thanks
    Dave

    I am trying to convert a static events calendar to dynamic
    and I have run
    into a couple of snags that I don't seem to be able to figure
    out (darned
    Newbies!)
    The big problem that I am having is to have the Month/Year
    header display
    only one time for all the events in that month.
    The second problem is displaying a range of dates for one
    event (...Sept
    9-12)
    Example:
    September 2006
    Sept 1 - event 1, location
    Sept 9-12 - event 2, location
    Sept 14-16 - event 3, location
    October 2006
    Oct 3-4 - event 1, location
    Oct 23 - event 2, location
    This is the type of calendar I'm trying to dynamisize looks
    like this one
    http://internationalsoaringeaglesministries.org/calendar.htm
    It is not loaded with all sorts of dates so I chose to
    display only dates
    with events on them.
    Any help would be much appreciated!!
    Thanks
    Dave

  • Re: Including Applet in JSP with Dynamic input| Help needed

    Hi All,
    We are into a project in Oracle Portal Server where in we want to embed a result of a standalone application in Portal page.
    We can do that once we can embed the result of the standalone application which generates applet based on the input it gets from the current application's database.
    If it was static we could have used jsp:plugin but, it fails in our case!
    We are clueless as to how to embed an applet which will pick up the data dynamically.
    Can anyone of you help me in this regard?
    Thanks & Regards
    Arthi

    Hi Arthi,
    I think this might help you to get an idea why jsp:plugin tag does not allow for dynamically called applets.
    <jsp:plugin type=applet height="100%" width="100%"
    archive="myjarfile.jar,myotherjar.jar"
    codebase="/applets"
    code="com.foo.MyApplet" >
    <jsp:params>
    <jsp:param name="enableDebug" value="true" />
    </jsp:params>
    <jsp:fallback>
    Your browser does not support applets.
    </jsp:fallback>
    </jsp:plugin>
    The plugin example illustrates a <html> uniform way of embedding applets in a web page. Before the advent of the <OBJECT> tag, there was no common way of embedding applets. This tag is poorly designed and hopefully future specs will allow for dynamic attributes (height="${param.height}", code="${chart}", etc) and dynamic parameters. Currently, the jsp:plugin tag does not allow for dynamically called applets. For example, if you have a charting applet that requires the data points to be passed in as parameters, you can't use jsp:params unless the number of data points are constant. You can't, for example, loop through a ResultSet to create the jsp:param tags. You have to hand code each jsp:param tag. Each of those jsp:param tags however can have a dynamic name and a dynamic value.
    I think you can get better information if you look in to the below link
    http://pdf.coreservlets.com/CSAJSP-Chapter12.pdf
    Many Thanks,
    Ramesh.

  • Dynamic Form Help Needed !!

    Hi Guys,
    I need a form that has the following how do i code it in
    dreamweaver ?
    name :
    email address :
    phone number :
    status: item are New, Contacted, Appointment Scheduled, Sold
    ( This would be a dropdown and depending on what the user chooses
    the options below show up )
    commission amount (only shows if the status is changed to
    "Sold")
    Thumbnail Calendar (only shows if Appointment Scheduled is
    the status)

    Depends on what sort of server side processing you're going
    to be using for
    your dynamic form...
    Do you have that info??
    "NYCKIDDbx" <[email protected]> wrote in
    message
    news:fmip1k$rhv$[email protected]..
    > Hi Guys,
    >
    > I need a form that has the following :
    >
    > name :
    > email address :
    > phone number :
    > status: item are New, Contacted, Appointment Scheduled,
    Sold ( This would
    > be a
    > dropdown and depending on what the user chooses the
    options below show
    > up )
    > commission amount (only shows if the status is changed
    to "Sold")
    > Thumbnail Calendar (only shows if Appointment Scheduled
    is the
    > status)
    >

  • Dynamic Reports Help Needed

    Could someone please point me in the direction of a tutorial
    or a book on how to create a hyperlink which will dynamically run
    an Access report and display in a web page? None of the reference
    books I own cover how to do this. I know this is pretty darn basic
    but I've never done this particular task before. can someone
    help??

    Could someone please point me in the direction of a tutorial
    or a book on how to create a hyperlink which will dynamically run
    an Access report and display in a web page? None of the reference
    books I own cover how to do this. I know this is pretty darn basic
    but I've never done this particular task before. can someone
    help??

  • Dynamic VTI help needed!

    Hi all,
    I currently have an "ordinary" site-to-site VPN with static crypto maps at the spokes and a dynamic crypto map at the headend.
    What I'd like to do is replace this with static VTIs at the spokes and a dynamic VTI at the headend. I don't need any of the "flash" of DMVPN, just as straight a swap as I can possibly get.
    The static VTIs are no problem, but I'm really confused about how to set up the dynamic VTI at the headend. I don't see how the DVTI gets associated with an interface, and which IP address the spoke should use to initiate the tunnel.
    Could anybody please post a simple (but complete) config for a DVTI hub and a SVTI spoke?
    many thanks,
    alec

    Configuring the Cisco IOS? Server Load Balancer (SLB) feature to distribute large numbers of IP Security (IPsec) tunnels onto a Cisco 7200/7301 IPsec server farm. The server farm hubs are configured with dynamic Virtual Tunnel Interface (VTI) while the remote spokes can be configured using VTI or crypto maps (supporting single proxy).
    http://www.cisco.com/en/US/products/ps6635/products_white_paper0900aecd8045b552.shtml

  • Dynamic sort help needed

    I am trying to implement a dynamic sort using pl/sql procedure
    with two IN params, which tell what column to sort by
    and wich direction. smth. like this
    procedure getEmployees (p_dept_no in employee.dept_no%type,
    p_sortBy in varchar2,
    p_sortDir in varchar2
    p_empl_cur in out emplCur
    ) is
    begin
    OPEN p_empl_cur
    FOR
    SELECT EMP_ID, F_NAME, L_NAME
    FROM EMPLOYEE
    WHERE DEPT_NO=p_dept_no
    ORDER BY p_sortBy p_sortDir ; --> this is the part that does not work
    -- I make sure that the params values are correct
    -- possible p_sortBy values: EMP_ID, F_NAME, L_NAME
    -- and p_sortDir: 'ASC' or 'DESC'
    end getEmployees;
    Thank you in advance.

    Try execute immediate.
    Some thing like this:
    PROCEDURE GETEMPLOYEES (P_DEPT_NO IN EMPLOYEE.DEPT_NO%TYPE,
    P_SORTBY IN VARCHAR2,
    P_SORTDIR IN VARCHAR2
    P_EMPL_CUR IN OUT EMPLCUR
    ) IS
    BEGIN
    OPEN P_EMPL_CUR
    FOR
    SORT_SQL := NULL;
    SORT_SQL := 'SELECT EMP_ID, F_NAME, L_NAME FROM EMPLOYEE'||
    ' WHERE DEPT_NO=P_DEPT_NO '||
    ' ORDER BY '||P_SORTBY||' '||P_SORTDIR||';'
    EXECUTE IMMEDIATE SORT_SQL INTO P_EMPL_CUR;
    Thanks
    Vasu
    I am trying to implement a dynamic sort using pl/sql procedure
    with two IN params, which tell what column to sort by
    and wich direction. smth. like this
    procedure getEmployees (p_dept_no in employee.dept_no%type,
    p_sortBy in varchar2,
    p_sortDir in varchar2
    p_empl_cur in out emplCur
    ) is
    begin
    OPEN p_empl_cur
    FOR
    SELECT EMP_ID, F_NAME, L_NAME
    FROM EMPLOYEE
    WHERE DEPT_NO=p_dept_no
    ORDER BY p_sortBy p_sortDir ; --> this is the part that does not work
    -- I make sure that the params values are correct
    -- possible p_sortBy values: EMP_ID, F_NAME, L_NAME
    -- and p_sortDir: 'ASC' or 'DESC'
    end getEmployees;
    Thank you in advance.

  • Sql help needed

    sql gurus
    Oracle 11.2.0.2
    OS : AIX
    Requirement: I have a sql which generates rows between 100 and 150 daily. Changes depending on the dml.
    I need to generate 3 reports
    Report 1
    ex :
    if total rows =120
    1st report contain starting from row 1 upto row (total div 3)
    Row 1 to Row 40
    Report 2
    Row (total div 3) +1 to (total div 3) *2
    Report
    Row ((total div 3) *2) + 1 to Total rows.
    Currently the process of identifying this manual
    apart from using plsql
    Is it possible to do thru sql to get this done
    pl. let me know.
    I hope I have explained the problem clearly

    Hi,
    gl**** wrote:
    ... I hope I have explained the problem clearlyNo matter how clearly you explain a problem, you still ought to post CREATE TABLE and INSERT statements for some sample data, and the results you want from that data, as Hoek said. Explain how you get the results you want from that data. For example, you talk about getting rows 1 through (N/3), but you haven't said what determines the order of the rows. (In the query below, I assume it's a column called column_1.)
    Simplify the problem when you can. For example, instead of having 100 to 150 rows, post a problem that involves 6 to 8 rows.
    One way to do this in pure SQL is to use the NTILE function to divide the results evenly (as evenly as possible) into 3 groups, and only display one of the groups at a time, like this:
    WITH   got_third     AS
         SELECT     x.*
         ,     NTILE (3) OVER (ORDER BY  column_1)     AS third
         FROM     table_x  x
         WHERE     ...      -- If you need any filtering, put it here
    SELECT     *     -- Or list all columns except third
    FROM     got_third
    WHERE     third     = :third_wanted
    ;It would be more efficient if you generated all of the results at once, and then divided the output file into 3 parts, but an inefficient solution might be acceptable in this case.

  • XML SQL help needed

    I am having trouble using OracleXML getXML, after
    setting all the path variables in env.csh I try
    java OracleXML getXML -user "user/passwd" "select a, b from blog"
    but get the following error.
    ORA-01019: unable to allocate memory in the user side
    The same error occurs for jdk1.1.7 and jdk1.2
    null

    Hi Dean,
    It might be something to do with connecting through oci8 to the
    Oracle executable. ( I am not sure since I dont know ur
    configuration etc..). BTW what release of Oracle is this?
    One thing for you to try out would be to write a small java
    program against the OracleXMLQuery class to see if that works.
    I have attached a very simple program below:-
    import java.sql.*;
    import java.math.*;
    import oracle.xml.sql.query.*;
    import oracle.jdbc.*;
    import oracle.jdbc.driver.*;
    public class testXML{
    public static void main(String args[]) throws SQLException
    DriverManager.registerDriver
    (new oracle.jdbc.driver.OracleDriver());
    Connection conn = (Connection)
    DriverManager.getConnection("jdbc:oracle:oci8:scott/tiger@");
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("select * from emp");
    OracleXMLQuery qry = new OracleXMLQuery(conn,rset);
    String xmlString = qry.getXMLString();
    System.out.println(" OUPUT IS "+xmlString);
    This code does a select from emp table available in scott/tiger
    schema. U can change the login and the table names
    appropriately. SEtup all the environment variables etc.. (see
    release notes), save this as testXML.java, run javac to get the
    class and execute it using "java testXML". If this doesnt work,
    try changing the getConnection line to use the thin jdbc, such
    as,
    DriverManager.getConnection
    ("jdbc:oracle:thin:@","scott","tiger");
    You can check out the JDBC documentation for how to specify
    your connection for your particular setup (such as specifying
    the port number etc.. if needed).
    Lemme know if it works,
    Murali
    Dean Kuo (guest) wrote:
    : I am having trouble using OracleXML getXML, after
    : setting all the path variables in env.csh I try
    : java OracleXML getXML -user "user/passwd" "select a, b from
    blog"
    : but get the following error.
    : ORA-01019: unable to allocate memory in the user side
    : The same error occurs for jdk1.1.7 and jdk1.2
    null

Maybe you are looking for

  • 30gb Video error message "Attempting to copy to disk "Ipod" failed.

    I have a 30gb ipod video and over the past day it is come up with this error message when I have tried to put songs from itunes into it. "Attempting to copy to disk "Ipod" failed. This disc could not be read from or written to". I've tried restarting

  • Submitting of smartforms in background

    Hi all, Can any one explain me how to submit smartform in background. Explain me in details. Thanks In Advance Ramana Prasad

  • IE64 and adobe flash player

    I need to download Adobe flash player to Windo ws 7. I need to have Internet Explorer. I only can find IE64 or

  • Error starting message

    Dear all, i hope any one can help me since i just download Nux Radio from Blackberry App world and the download done successfully, but when i want to run the application, i found error message: Error starting Nux_Radio: Module 'net_rim_bb_qm_platform

  • Sales Pro Business Process

    Hello, My company is interested in implementing CRM lead, opportunity and quotation processing. If anyone is using these transactions and would like to share any thoughts or lessonu2019s learned it would be greatly appreciated. Thanks! George