Convert to SQL Query

Hi
On a report there is a function "Convert to SQL Query", I have tryed the function and get the SQL statment for the report, is it the only thing to get in "text" instead of the more "graphic" way to show it?
Best Regrads
Jesper Vels

Jesper,
is it the only thing to get in "text" This is correct.The "Convert to SQL Query" link is available for report that are built using the Wizard. Selecting this will give you the underlying SQL Query that you can edit/modify if required.
more "graphic" way to show itWhat do you mean by this? Please elaborate?
-Amitabh

Similar Messages

  • Convert T-SQL query to DB2 query

    I am trying to convert a T-SQL query to DB2 (v.9.7) query but have no luck.
    I have tested following T-SQL query using query tool of SQL Server Management Studio and it works fine as expected.
    SELECT CASE WHEN (EXISTS (SELECT NULL FROM "CUSTOMERS" t0) ) THEN 1 ELSE 0 END AS "value"
    The query is originally from following C# code: 
    TestQuery(() => db.Customers.Any());
    I try to run the query using query tool of IBM Data Studio 4.1.0.1 Client and get error: SQLCODE=-104, SQLSTATE=42601, DRIVER=4.17.30
    How to convert it to DB2 correctly?
    Any help would be greatly appreciated! Thanks in advance.
    Magnus

    So this is not the right place to ask about DB2. What I can say is that if you had been converting to Oracle, you would have needed to add "FROM dual" to your query.
    That is, on Oracle you cannot leave out the FROM clause, why they have this funky "dual". Whether you can leave out FROM on DB2, I have no idea, but I raise this is a potential problem.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to convert an sql query into a recordset?

    HI, I'm having a hard time building a locations of service form for users to insert, update the cities, counties, zip codes based on the states selected.
    so I found this  query that works great if I use basic  menus and text boxes, but can't use to make comma separated menus because it is nat a record set.
    The problem is that I have a table called zip_codes, with the following fields: state_label, Zip_b, county, city.
    zip codes correspond to the cities, counties and states.
    example:
    Colorado,  Colorado Springs, El Paso,  80918
    Users make a selection of state or states and the recordset is filtered by user selection.
    I manage the part of making a select mutiple drop menu that passes the values to my query page like this.
    <form action="litsTA.php"; method="post">
    <h3>Choose State(s)</h3>
    <p>hold Control key to select multiple states</p>
    <select  name="States_served[]_<?php echo $cnt1; ?>" multiple="multiple" onchange='showselection()'>
      <?php
    do { 
    ?>
      <option value="<?php echo $row_state['state_label']?>"><?php echo $row_state['state_label']?></option>
      <?php
    } while ($row_state = mysql_fetch_assoc($state));
      $rows = mysql_num_rows($state);
      if($rows > 0) {
          mysql_data_seek($state, 0);
           $row_state = mysql_fetch_assoc($state);
    ?>
    </select>
    <p>
      <input type="submit" value="submit" />
    </p>
    </form>
    And the query I need to convert into a recordset looks like this
      mysql_select_db($database_duitop, $duitop);
    $query_TONY = "SELECT * FROM zip_code WHERE state_label IN (";  
    for ($i=0; $i<=count($state_list)-1; $i++) {
    //echo $state_list[$i];
    $query_TONY = $query_TONY . "'" . $state_list[$i] . "'";
    if ($i < count($state_list)-1) {
    $query_TONY = $query_TONY . ", ";
    $query_TONY = $query_TONY . ") GROUP BY county ORDER BY state_label, city ASC";
    Any way that was my attempt to converting the query into a recordset.
    any help, or samples will be appreciated.

    Use Tcode SQ01.
    Give the query name press Enter.
    The query will be listed in the table below.
    Select the Query => From the Main menu select QUERY => More Functions => Display Report Name.
    You will get the program name, now go to Se38 and display the program...

  • How to convert this SQL query to PL/SQL

    I basically need to create an anonymous block that will display each student's first name, last name and the count of students who scored less on test 1 than the student.
    So basically we need to find the count of students who have scored less than that particular student and we do it for all students in the table.
    So for this particular query i designed my code in SQL
    select g1.gr_fname, g1.gr_lname, count(*)
    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;
    But i am unable to get the logic as to how to execute it in PL/SQL,I am missing something a minor detail to execute the same in PL/SQL
    could someone please help me with the logic.
    Thanks

    Hi welcome to the forum try some thing below
    SQL> DECLARE
      2     CURSOR c1
      3     IS
      4        SELECT   ename, sal, d.deptno
      5            FROM scott.emp e, scott.dept d
      6           WHERE e.deptno = d.deptno
      7        GROUP BY ename, sal, d.deptno;
      8  BEGIN
      9     FOR c2 IN c1
    10     LOOP
    11        DBMS_OUTPUT.put_line ('name is  ' || c2.ename);
    12     END LOOP;
    13  END;
    14  /
    name is  CLARK
    name is  KING
    name is  JONES
    name is  MARTIN
    name is  FORD
    name is  SCOTT
    name is  ALLEN
    name is  TURNER
    name is  WARD
    name is  MILLER
    name is  ADAMS
    name is  BLAKE
    name is  JAMES
    name is  SMITH
    PL/SQL procedure successfully completed.This is just to demonstrate the use of PL/SQL block

  • Convert Oracle SQL query to single column output

    Hello All,
    I need to build the query to have multiple columns in a single column with multiple rows.
    select a.customer_trx_id,a.previous_customer_trx_id
    from ra_customer_trx_all a
    where a.customer_trx_id = :customer_trx_id
    here, a.customer_trx_id and a.previous_customer_trx_id are in two columns. I need to bring them into a single column.
    Say: the above output is
    a.customer_trx_id a.previous_customer_trx_id
    123456 87654
    Need to have single column
    As
    123456
    87654
    Please do the needful.
    Thanks,
    Abdul

    Hi,
    Post your question in [SQL and PL/SQL|http://forums.oracle.com/forums/forum.jspa?forumID=75] forum, you would probably get a better/faster response.
    Regards,
    Hussein

  • Convert Oracle SQL Query to SQLite Query

    Hi,
    I am new to SQLite and have requirement to write quries in SQLite format. As table structure is same in both the Oracle and SQLite database i have created queries in Oracle SQL. Now wanted to know is there any tool or package available which will convert my simple Oracle queries into SQLite format???
    Please guide..
    Regards,
    Priyanka

    with tree as (
    select
    level lev
    ,id
    ,parent_id
    ,sys_connect_by_path(id, '-') p
    from test_temp
    connect by
    parent_id = prior id
    start with parent_id is null
    select
    from tree t1
    where exists (
    select 1
    from tree t2
    where substr(t2.p, 1, length(t1.p)) = t1.p
      and regexp_count(t2.p, '-') = regexp_count(t1.p, '-') + 2
      -- if regexp_count is not available in your version or performs not well, below is an alternative
      -- and length(t2.p) - length(replace(t2.p, '-')) = length(t1.p) - length(replace(t1.p, '-')) + 2
    LEV
    ID
    PARENT_ID
    P
    1
    1
    -1
    2
    3
    1
    -1-3
    2
    5
    1
    -1-5
    1
    2
    -2
    2
    6
    2
    -2-6
    3
    14
    6
    -2-6-14

  • How to convert the sql query result into xml ? PLease..Please..

    I have a table Submission Record which contain a field with mix with text string and xml data type.
    Table name: Submission Record
    Field name: RCA
    Jason
    Tomato
    <Record>AA</Record>
    Fish
    Brother
    <Record>BB</Record>
    <Record>CC</Record>
    Tom is a girl
    Its mixing with text and xml data.
    I wish to convert all into xml data as per request from management.
    my select statement is like below...but i think it may contain syntax error. Wish to get help from here.
    sqltestagain = "select '<DATA>' || RCA || '</DATA>' from Submission Record".
    Expect below will display
    <DATA>Jason</DATA>
    <DATA>Tomato</DATA>
    <DATA><Record>AA</Record></DATA>
    or any other solution for it ??
    I've tried FOR XML....DBMS_XML......but none of it worked.....

    also look at xmlelement
    SQL> select xmlelement("DATA", rca).getstringval() from
      2  (
      3  select 'Jason' RCA from dual union all
      4  select 'Tomato' from dual union all
      5  select '<Record>AA</Record>' from dual
      6  )
      7  /
    XMLELEMENT("DATA",RCA).GETSTRI
    <DATA>Jason</DATA>
    <DATA>Tomato</DATA>
    <DATA>&lt;Record&gt;AA&lt;/Record&gt;</DATA>
    SQL>

  • How to convert a sql query to a java language?

    A sql like this:"update myoracletable set name='myname',age=26,sex='female',address=NULL,visittime=SYSDATE,visitnum=visitnum+1where name='name' and address='address'",I want to use java language update such as :rs.updateString(),rs.updateDate() but not a sql update.How can I do in this case?

    Something like this?
    try{
         DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
         Connection con = DriverManager.getConnection("jdbc:oracle:thin:@your_server:1521:sid","scott","tiger");
         Statement st = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
         ResultSet rs = st.executeQuery("SELECT deptno,dname,loc FROM dept where deptno=28");
         while(rs.next() ) {
              rs.updateString(2,"Some Name");
              rs.updateString(3,"Some Location");
              rs.updateRow();
              System.out.println(rs.getString(1)+" : "+rs.getString(2)+" : "+rs.getString(3));
    } catch (Exception e) {
         System.out.println(e);
    }Sudha

  • Need help converting MS SQL query into Oracle, Function 'WHERE' issues

    SELECT PERS_NBR, PAY_ID, PAY_CODE, LOGICAL_DATE, LOGICAL_DATE AS END_DATE, PCNAMES + REPLICATE(',', 39 - (LEN(PCNAMES) - LEN(REPLACE(PCNAMES, ',', ''))))
    AS PC_NAMES_FINAL
    FROM (SELECT DISTINCT A.PAY_ID, A.PAY_CODE, A.PERS_NBR, A.LOGICAL_DATE, PCNAMES = substring
    ((SELECT TOP 10 ',' + PC_NAME + ',' + SUBSTRING(CAST(B.VALUE AS VARCHAR), 0, LEN(CAST(B.VALUE AS VARCHAR)) - 2)
    FROM T_PAY_CAT_RECORD B
    WHERE B.PERS_NBR = A.PERS_NBR AND
    B.LOGICAL_DATE = A.LOGICAL_DATE FOR XML path(''), elements), 2, 500)
    FROM T_PAY_CAT_RECORD A, T_PERSON P
    WHERE A.PERS_NBR = P.NBR) FINAL
    Edited by: 919969 on Mar 9, 2012 3:45 PM

    Hello
    Like any language you need to understand what the messages coming from the syntax check are saying...
    XXXX> SELECT PERS_NBR,
      2          PAY_ID,
      3          PAY_CODE,
      4          LOGICAL_DATE,
      5          LOGICAL_DATE AS END_DATE,
      6          PCNAMES || LPAD(',', 39 - (LENGTH(PCNAMES) - NVL(LENGTH(REPLACE(PCNAMES,',')),0)),',') AS PC_NAMES_FINAL
      7    FROM  (
      8           SELECT  PAY_ID,
      9                   PAY_CODE,
    10                   PERS_NBR,
    11                   LOGICAL_DATE,
    12                   SUBSTR(
    13                          RTRIM(XMLAGG(XMLELEMENT(e,PC_NAME || ',' || SUBSTR(VALUE,1,LEN(VALUE) - 2),',').EXTRACT('//text()')),',') PCNAMES
    14                          2,
    15                          500
    16                         )
    17             FROM  (
    18                    SELECT  A.PAY_ID,
    19                            A.PAY_CODE,
    20                            A.PERS_NBR,
    21                            A.LOGICAL_DATE,
    22                            A.PC_NAME,
    23                            ROW_NUMBER() OVER(PARTITION BY A.PERS_NBR,A.LOGICAL_DATE ORDER BY 1) RN
    24                      FROM  T_PAY_CAT_RECORD A,
    25                            T_PERSON P
    26                      WHERE A.PERS_NBR = P.NBR
    27                   )
    28             WHERE RN <= 10
    29             GROUP BY PAY_ID,
    30                      PAY_CODE,
    31                      PERS_NBR,
    32                      LOGICAL_DATE
    33          ) FINAL
    34  /
                            RTRIM(XMLAGG(XMLELEMENT(e,PC_NAME || ',' || SUBSTR(VALUE,1,LEN(VALUE) - 2),',').EXTRACT('//text()')),',') PCNAMES
    ERROR at line 13:
    ORA-00907: missing right parenthesisIf you use something like SQL*Plus or SQL Developer, they will give you the error stack which will point you to the source of the problem.
    It's saying missing right parenthesis. Start by finding out if we've got all out matching brackets. Counting from the start of that statement i.e. SUBSTR on line 12, we have 7 open brackets and 6 close brackets. So there does appear to be a problem with brackets. However if we take a step back and look at lines 12 to 16, this is actually a single statement. It's a call to the SUBSTR function and within it it has calls to RTRIM, XMLAGG etc. For the statement as a whole there are the same number of left and right parenthesis so the problem is related to something else. Something that is leading the syntax check to think it has reached the end of a statement and hasn't found enough closing parethesis.
    The issue here appears to be that we have the token PCNAMES at the end of line 13 but syntactically that's not correct. We can't have that token there because it's appearing in the middle of a function call. PCTNAMES is actually a column alias but it's just in the wrong place. We need it to be an alias for the whole expression from line 12 to 16. So make the change and see what happens...
    XXXX> select PERS_NBR,
      2          PAY_ID,
      3          PAY_CODE,
      4          LOGICAL_DATE,
      5          LOGICAL_DATE AS END_DATE,
      6          PCNAMES || LPAD(',', 39 - (LENGTH(PCNAMES) - NVL(LENGTH(REPLACE(PCNAMES,',')),0)),',') AS PC_NAMES_FINAL
      7    FROM  (
      8           SELECT  PAY_ID,
      9                   PAY_CODE,
    10                   PERS_NBR,
    11                   LOGICAL_DATE,
    12                   SUBSTR(
    13                          RTRIM(XMLAGG(XMLELEMENT(e,PC_NAME || ',' || SUBSTR(VALUE,1,LEN(VALUE) - 2),',').EXTRACT('//text()')),',')
    14                          2,
    15                          500
    16                         ) PCNAMES
    17             FROM  (
    18                    SELECT  A.PAY_ID,
    19                            A.PAY_CODE,
    20                            A.PERS_NBR,
    21                            A.LOGICAL_DATE,
    22                            A.PC_NAME,
    23                            ROW_NUMBER() OVER(PARTITION BY A.PERS_NBR,A.LOGICAL_DATE ORDER BY 1) RN
    24                      FROM  T_PAY_CAT_RECORD A,
    25                            T_PERSON P
    26                      WHERE A.PERS_NBR = P.NBR
    27                   )
    28             WHERE RN <= 10
    29             GROUP BY PAY_ID,
    30                      PAY_CODE,
    31                      PERS_NBR,
    32                      LOGICAL_DATE
    33          ) FINAL
    34  /
                            2,
    ERROR at line 14:
    ORA-00907: missing right parenthesisNOw we've got a new error. Again it's saying we've got a missing parenthesis but this time on line 14. The issue here is that line 13 is a parameter to the SUBSTR function but there is no comma on the end. What we actually have at the moment is a line that looks like so
    RTRIM(XMLAGG(XMLELEMENT(e,PC_NAME || ',' || SUBSTR(VALUE,1,LEN(VALUE) - 2),',').EXTRACT('//text()')),',') 2,Which is just not formed correctly. We need a comma at the end of line 13 to state that this is the end of that line as a parameter.
    XXXX> select PERS_NBR,
      2          PAY_ID,
      3          PAY_CODE,
      4          LOGICAL_DATE,
      5          LOGICAL_DATE AS END_DATE,
      6          PCNAMES || LPAD(',', 39 - (LENGTH(PCNAMES) - NVL(LENGTH(REPLACE(PCNAMES,',')),0)),',') AS PC_NAMES_FINAL
      7    FROM  (
      8           SELECT  PAY_ID,
      9                   PAY_CODE,
    10                   PERS_NBR,
    11                   LOGICAL_DATE,
    12                   SUBSTR(
    13                          RTRIM(XMLAGG(XMLELEMENT(e,PC_NAME || ',' || SUBSTR(VALUE,1,LEN(VALUE) - 2),',').EXTRACT('//text()')),','),
    14                          2,
    15                          500
    16                         ) PCNAMES
    17             FROM  (
    18                    SELECT  A.PAY_ID,
    19                            A.PAY_CODE,
    20                            A.PERS_NBR,
    21                            A.LOGICAL_DATE,
    22                            A.PC_NAME,
    23                            ROW_NUMBER() OVER(PARTITION BY A.PERS_NBR,A.LOGICAL_DATE ORDER BY 1) RN
    24                      FROM  T_PAY_CAT_RECORD A,
    25                            T_PERSON P
    26                      WHERE A.PERS_NBR = P.NBR
    27                   )
    28             WHERE RN <= 10
    29             GROUP BY PAY_ID,
    30                      PAY_CODE,
    31                      PERS_NBR,
    32                      LOGICAL_DATE
    33          ) FINAL
    34  /
                              T_PERSON P
    ERROR at line 25:
    ORA-00942: table or view does not existNow we have a new error but this time it's because I don't have the t_person table on my database. Syntactically the statement above is now correct so it should work on your system.
    HTH
    David
    Edited by: Bravid on Mar 12, 2012 10:20 AM

  • Converting MS SQL Server Query to Oracle Query

    Hi There,
    I've a strange problem. My project uses both MS SQL Server and Oracle server at run time. I've lot of queries which are written in MS SQL Style. Now, iam planning to write a helper class whic converts MS SQL Query to Oracle Query. Please Help me if any one has that kind of Helper with you.
    Thanks And Regards,
    Sasi Kanth

    That is why persistence applications like Hibernate or
    CMP get used for apps that will use more than one DB,
    but it takes upfront planning.
    If you have a set of automated unit tests that work
    with SQL Server, they will be a big help in getting
    your Oracle code up and running.Indeed - JUnit and Ant would be a big help here.
    It sounds like you have SQL in your JSPs, that will
    work against you as well if so. If you are using a
    DAO pattern, this will be much easier, as you can
    re-implement each DAO for Oracle.If you'd layered this app properly, you might just implement an OracleDAOFactory and be done with it. Interfaces and a DAO layer would go a long way.
    This is why layering is such a good idea. It isolates changes in a smaller subset of classes.
    But your problem sounds pretty big. It'd be daunting even if it were well designed.

  • Convert SQL Query in SSRS

    Can anyoone help me out to convert this SQL query in SSRS.
    create table tickets_every_hour_ict(ddate datetime,dgroup varchar(50))
    Insert into tickets_every_hour_ict
    Select
    --incident.actie,
    incident.dataanmk ,
    incident.ref_operatorgroup
    /*,incident.ref_status as "Status",
    incident.datumaangemeld as "Datum aanmelding" */
    From incident
    WHERE incident.dataanmk >= DATEADD(day,-7, GETDATE())
    AND incident.ref_operatorgroup in ('Automatisering')
    order by incident.dataanmk desc
    Select ddate1,[00:00],[01:00],[02:00],[03:00],[04:00],[05:00],[06:00],[07:00],[08:00],[09:00],[10:00],[11:00],[12:00],
    [13:00],[14:00],[15:00],[16:00],[17:00],[18:00],[19:00],[20:00],[21:00],[22:00],[23:00]
    From
    Select dgroup 'dgroup',cast(Convert(varchar(10),ddate,101)+' '+ convert(varchar(3),ddate,108) +'00' as date) ddate1,convert(varchar(3),ddate,108) +'00' dtime From tickets_every_hour_ict
    )p
    PIVOT
    Count(dgroup) for dtime in([00:00],[01:00],[02:00],[03:00],[04:00],[05:00],[06:00],[07:00],[08:00],[09:00],[10:00],[11:00],[12:00],
    [13:00],[14:00],[15:00],[16:00],[17:00],[18:00],[19:00],[20:00],[21:00],[22:00],[23:00])
    )PVT

    In SSRS you just need to use  matrix container and use query as below
    Select dgroup 'dgroup',cast(Convert(varchar(10),ddate,101)+' '+ convert(varchar(3),ddate,108) +'00' as date) ddate1,convert(varchar(3),ddate,108) +'00' dtime From tickets_every_hour_ict
    Then in report add dtime column inside column group of matrix and add
    =Count(Fields!dgroup.value)
    as expression inside data area.
    add
    ddate1 to row group and you'll get pivoted values
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
    I created it your way but then it will not show the tables with 0. I want it to show all hours even if the count is 0.

  • Getting a Mapping Diagram from SQL Query

    Hi,
    I have 2 schemas: SOURCE and TARGET.
    A previous developer had written an SQL Query to transform and load data from 3 tables from SOURCE schema into 1 table in the TARGET schema. It is working fine by use of the grants and synonyms that I have created.
    My query is: Now I would like to convert this SQL query or transformation into a diagram. The diagram would show the columns of the source tables and the transformations which are then loaded into the target table.
    Kindly advice which tool or software I can use for this? Or, should I go with the manual approach?
    Regards,
    Suddhasatwa

    Hi
    Can you advice which options I should select in TOAD or SQL Developer?
    I have done bit of research from my end, but am not able to find any suitable option.
    Many Thanks,
    Suddhasatwa Bhaumik.

  • Storing the SQL Query results as XML

    Hi All,
    I have a proc to select all the data from emp table and insert into another table. For some reason it inserts only one column and one record.
    I don't have any row limit or skip ...
    CREATE OR REPLACE procedure Convert_Data_Into_XML1
    as
    -- Var Declartion
    qryCtx DBMS_XMLGEN.ctxHandle;
    result CLOB;
    BEGIN
    qryCtx := dbms_xmlgen.newContext('SELECT * from emp');
    -- set the row header to be EMPLOYEE
    DBMS_XMLGEN.setRowTag(qryCtx, 'Employee-ROW');
    DBMS_XMLGEN.setRowsetTag(qryCtx, 'Employee-rowset');
    LOOP
    -- now get the result
    result := DBMS_XMLGEN.getXML(qryCtx);
    DBMS_OUTPUT.PUT_LINE ('In the Loop');
    EXIT WHEN DBMS_XMLGEN.getNumRowsProcessed(qryCtx) = 0;
    INSERT INTO temp_clob_tab VALUES (result);
    END LOOP;
    COMMIT;
    --close context
    DBMS_XMLGEN.closeContext(qryCtx);
    exception
    when others then
    dbms_output.put_line(TO_CHAR(sqlerrm));
    END;
    Basically I got this sample proc from Oracle website. As per the website I should be able to store all the records from emp table.
    How can I debug this.
    Here is the output from SQLPLUS&gt;
    SQL&gt; select result from temp_clob_tab;
    RESULT
    &lt;?xml version="1.0"?&gt;
    &lt;Employee-rowset&gt;
    &lt;Employee-ROW&gt;
    &lt;EMPNO&gt;7369&lt;/EMPNO&gt;
    &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
    Thanks in advance
    Siva

    I am able to convert the SQL query output and I am able to store it in a XMLTYPE column.
    But the code doesn't work when I took the same code and try to Implement inside a Trigger. The reason I am doing this is, when there is an update or delete, I want to store the whole record as a XMLTYPE doc (before and After). But the code compiles fine, but when I tried to update a record it gives error.
    CREATE OR REPLACE TRIGGER INS_UPDDEV_EMP3_F
    BEFORE UPDATE OR DELETE ON EMP
    FOR EACH ROW
    DECLARE
    V_DBUSER VARCHAR2(50);
    V_CHANGETYPE VARCHAR2(20) := 'INSERT' ;
    QRYCTX DBMS_XMLGEN.CTXHANDLE ;
    OLDVALUE XMLTYPE;
    NEWVALUE XMLTYPE;
    BEGIN
    IF :OLD.EMPNO &lt;&gt; :NEW.EMPNO or DELETING then
    ---------- old Value
    QRYCTX := DBMS_XMLGEN.NEWCONTEXT ('SELECT :OLD.EMPNO, :OLD.ENAME, :OLD.JOB, :OLD.MGR, :OLD.HIREDATE, :OLD.SAL, :OLD.COMM, :OLD.DEPTNO FROM EMP WHERE EMPNO=:OLD.EMPNO ');
    DBMS_XMLGEN.SETROWTAG (QRYCTX, 'DEPTROW');
    DBMS_XMLGEN.SETROWSETTAG(QRYCTX, 'DEPTSET');
    OLDVALUE := XMLTYPE(DBMS_XMLGEN.GETXML(QRYCTX));
    ------------------------- new Value
    QRYCTX := DBMS_XMLGEN.NEWCONTEXT ('Select * WHERE EMPNO=:NEW.EMPNO '); -- WHERE :OLD.EMPNO
         DBMS_XMLGEN.SETROWTAG (QRYCTX, 'DEPTROW');
    DBMS_XMLGEN.SETROWSETTAG(QRYCTX, 'DEPTSET');
    NEWVALUE := XMLTYPE(DBMS_XMLGEN.GETXML(QRYCTX));
    V_CHANGETYPE := 'UPDATE' ;
    INSERT INTO ADM_RECAUDITHISTORY VALUES ('table emp', 'fIELD all', OLDVALUE, OLDVALUE,
    V_CHANGETYPE , SYSDATE, 'TIGER TRIG');
    commit;
    END IF;
    END;
    I am getting the following error while updating the record.
    &gt;&gt;&gt;&gt;
    ERROR at line 1:
    ORA-19206: Invalid value for query or REF CURSOR parameter
    ORA-06512: at "SYS.DBMS_XMLGEN", line 83
    ORA-06512: at "SCOTT.INS_UPDDEV_EMP3_F", line 13
    ORA-04088: error during execution of trigger 'SCOTT.INS_UPDDEV_EMP3_F'
    &gt;&gt;&gt;&gt;&gt;
    Is anyone knows why I am getting this error.
    Thanks
    Siva

  • Converting SQL Report Region to PLSQL Function Body Returning SQL Query

    All:
    I want to convert my SQL Report Region to a PLSQL-generated SQL Report Region so that I can eliminate where clauses dynamically and speed up my app, and also so that I can provide additional sorting options.
    <br><br>
    My problem is that I have lots of embedded single quotes that already are coded as 3 single quotes in the SQL Report Region. I am not sure at all how to code them within the PLSQL.
    <br><br>
    As example, here is one column from my query:
    <br><br>
    select decode(nvl(g.date_sub_1,g.date_rec_1), null, decode(g.article, 0, 'E', 1, 'U'), '< a href="javascript:unElevate( ' ' ' || g.grid || ' ' ',' ' ' || g.natca || ' ' ')">' || decode(g.article, 0, 'E', 1, 'U') || '< /a>') "Reverse" from g_table g
    <br><br>
    (Note that I added spaces within the code so it would display properly in the browser.)
    <br><br>
    To clarify, that's a double quote before javascript, and then 3 single quotes before the first concatenation group, then 3 single quotes after the second concatenation group, then 3 single quotes before the third, 3 single quotes after the fourth followed by an end-paren followed by a double quote etc.
    <br><br>
    My question is, what do I do with these triple-single quotes within PLSQL? Probably a no-brainer for the experienced folks, but I am thinking like a mobius strip at this point.
    <br><br>
    Bill
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]
    Message was edited by:
    [email protected]

    Scott,
    I think that feature was made for my situation! I keep getting
    Function returning SQL query: Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the generic columns checkbox below the region source to proceed without parsing.
    (ORA-20001: Unable to bind :43 verify length of item is 30 bytes or less. Use v() syntax to reference items longer than 30 bytes. ORA-01006: bind variable does not exist)
    I did chop the query up into little bits, i.e.
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    p_sql := p_sql || q'! ... !';
    return p_sql;
    But I'm not sure what I'm supposed to do here.
    Thank you.
    Bill

  • SQL query, function or SP for converting varbinary to image(.jpg format).

    Dear Sir/Mam
    I want SQL query, function or SP which converts binary data to image (.jpg format).
    I m able to convert image (.jpg format) to varbinary. But not able to convert vice versa.
    thanks in advance.

    Binary data is binary data - "image" is only an intrepretation of binary data.  Therefore your question makes little sense in the context of sql server since it does not have any facilities to utilize images.  Since you provide no context, I'm
    guessing that you are trying to retrieve an image stored in the database in a varbinary column and have your application use it as an image.  If so, you should post your question to a forum that is specific to your development environment.  

Maybe you are looking for