Using select query to insert into a field

Hi,
I am working with a jdbc-to-jdbc scenario, in which on source side iam geting data from 2 tables t1 & t2 and inserting this data into two tables tb1 & tb2 on target side.A field in tb2 has to be inserted with a value which is equal to the number of records inserted into the table tb1 i.e with the number equal to 'how many records from the table t1 has been retrieved inorder to insert into table tb1'.
Can anybody please suggest me.....
Thanks & Regards,
Radhika.

consider ur strucutre
<Data>
<id> 1 </id> 0..1
<id> 2 </id>
<id> 3 </id>
<id> 4 </id>
</Data>
here i meant context to <id>. Mapping id > count > target will give the nunmber of records in Data i.e. 4
note: here u have change the context of <id> to <data>
Message was edited by:
        Prabhu  S

Similar Messages

  • "Create Table from select Query" Vs "Insert into"

    Hi
    Schenaio:
    My Select Query returns more than 10 million records, these records needs to be inserted into another table.
    Approach 1:
    I created table called TABLE1, and inserted the records using INSERT statement as a batch (batch size is 5000).
    Approach 2:
    I create table like,
    CREATE TABLE TABLE1 AS <SELECT QUERY>
    Here Apporach-1 took almost 40 minutes to complete the insert but Approach-2 took only 6 minutes.
    If anybody knows why it is? And is there any way to improve the performance of Approach-1?.
    Thanks
    Nidhi

    Most "batch" methods execute the same query multiple times. Row filtering is done after the rows are fetched from the source. The process of fetching all the rows could be a FullTableScan.
    Therefore, a FullTableScan is executed for each batch of 5000 rows.
    However, your query and batch definitions may well be different. We haven't seen the query and the execution plan.
    Another point : How are you "filtering" the rows (i.e the second execution inserts rows 5001 to 10000 and does not attempt to reinsert rows 1 to 5000) ?
    What is the overhead imposed by the filter ? (does the third execution have to exclude rows 1 to 10000 and inserts rows 10001 to 15000 and so on)
    Hemant K Chitale

  • Data type mismatch when inserting into text field

    Hello all,
    Using VB script and ASP.
    I have a page that inserts into a field (casenum) in a table (clientsw) in a database. The field (casenum) in the table is data type TEXT :
    I create a recordset and then an insert statement which the following is part of:
    Code to insert the casenum into the field
    rsClients("Casenum")=Right(Date(),2) & "E-100" & rsCasenumber("countervalue")
    It inserts a number like 09E-1004500
    I then have code that takes that string and passes it to the next page as a variable
    Session("UserID")=rsClients("CASENUM")
    response.redirect "done3.asp"
    When it gets to the next page it is assigned as UserID
    Dim svuserid
    svuserid = "0"
    if (Session("UserID") <> "") then svuserid = Session("UserID")
    %>
    My information inserts into the database exactly as I want it, but when it gets to the next page I get an error that is displayed that says the following:
    Microsoft JET Database Engine error '80040e07'
    Data type mismatch in criteria expression.
    /done3.asp, line 16
    My code on the second page is as follows:
    <%@LANGUAGE="VBSCRIPT"%>
    <!--#include file="Connections/connNewdatabase1.asp" -->
    <%
    Dim svuserid
    svuserid = "0"
    if (Session("UserID") <> "") then svuserid = Session("UserID")
    %>
    <%
    set rsClients = Server.CreateObject("ADODB.Recordset")
    rsClients.ActiveConnection = MM_connNewdatabase_STRING
    rsClients.Source = "SELECT *  FROM CLIENTSW WHERE CASENUM=" + Replace(svuserid, "'", "''") + "  ORDER BY CASENUM"
    rsClients.CursorType = 0
    rsClients.CursorLocation = 2
    rsClients.LockType = 3
    rsClients.Open()
    rsClients_numRows = 0
    %>
    Line 16 is the one that says rsClients.Open()
    If I take the concatenation out of rsClients("Casenum")=Right(Date(),2) & "E-100" & rsCasenumber("countervalue") and have only rsClients("Casenum")=rsCasenumber("countervalue") and change the table field to number, I don't get the "datatype mismatch error"
    What do I change to enable me to leave the above statement concatenated and insert into the table correctly and complete the stuff on the next page?

    >This is an access database, varchar is not an option for a datatype.
    Sorry. In another thread I thought you mentioned using SQL Server
    >I changed the + signed to ampersands instead and it doesn't make a difference.
    I didn't think that was the problem. I was just pointing out that it's a bad practice. If you use the '+' on two strings that can evaluate as numeric, it will actually add rather than concat them.

  • Insert into a field which is long

    i use stream method to insert into a
    long type field , but unsuccess.
    my code is:
    PreparedStatement pstmt = conn.prepareStatement("insert into forlong(thelob) values(?)");
    InputStream is = new FileInputStream ("c:\\notes.txt");
    File file = new File ("c:\\notes.txt");
    pstmt.setAsciiStream (1, is, (int)file.length ());
    is.close();

    I do not have TOAD, but I tried your posted example from PL/SQL Developer and it seems to work as expected. Can you post some more detail as to how you are doing it from TOAD and what the issue is, with errors, if any:
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
    Connected as kkishore
    SQL>
    Table created
    View created
    Trigger created
    1 row inserted
            F1
             1
             1
    OWNER                          TABLE_NAME                     COLUMN_NAME                    UPDATABLE INSERTABLE DELETABLE
    KKISHORE                       DUMMY_V                        F1                             NO        NO         NO
    SQL>

  • To display 01 to 10 using select query

    Hi all,
    using select query...
    In where clause...,
    If u give 1 to 9 it should display 01 to 09 and
    If u give 10 it should display as 10.
    I want it in a single query .
    Thanks & Regards,
    Hariharan ST.

    Just need to build a where condition to the query posted by ascheffer -
    Something Like this -
      1  Select rn
      2  From   ( Select To_Char(ROWNUM, '09')  rn
      3           From   Dual
      4           Connect By rownum < 11
      5         )
      6  Where  (     (       Trim(rn) < 10
      7                 And '&Param' = '1 to 9'
      8               )
      9           Or (       Trim(rn) = LPAD('&Param', 2, 0)
    10              )
    11*        )
    SQL> /
    Enter value for param: 10
    old   7:                And '&Param' = '1 to 9'
    new   7:                And '10' = '1 to 9'
    Enter value for param: 10
    old   9:          Or (       Trim(rn) = LPAD('&Param', 2, 0)
    new   9:          Or (       Trim(rn) = LPAD('10', 2, 0)
    RN
    10
    SQL> /
    Enter value for param: 7
    old   7:                And '&Param' = '1 to 9'
    new   7:                And '7' = '1 to 9'
    Enter value for param: 7
    old   9:          Or (       Trim(rn) = LPAD('&Param', 2, 0)
    new   9:          Or (       Trim(rn) = LPAD('7', 2, 0)
    RN
    07
    SQL> /
    Enter value for param: 4
    old   7:                And '&Param' = '1 to 9'
    new   7:                And '4' = '1 to 9'
    Enter value for param: 4
    old   9:          Or (       Trim(rn) = LPAD('&Param', 2, 0)
    new   9:          Or (       Trim(rn) = LPAD('4', 2, 0)
    RN
    04
    SQL> /
    Enter value for param: 1 to 9
    old   7:                And '&Param' = '1 to 9'
    new   7:                And '1 to 9' = '1 to 9'
    Enter value for param: 1 to 9
    old   9:          Or (       Trim(rn) = LPAD('&Param', 2, 0)
    new   9:          Or (       Trim(rn) = LPAD('1 to 9', 2, 0)
    RN
    01
    02
    03
    04
    05
    06
    07
    08
    09
    9 rows selected.Shailender Mehta

  • Message:execute non-query failure(insert into EDCSESSIONSTOREENTITY

    Hi , my error is
    Adobe Reader Extensions ES2
    ERROR.....
    [com.adobe.idp.common.errors.exception.IDPLoggedException] UserM:GENERIC_WARNING: [Thread Hashcode: 975924454] com.adobe.idp.common.errors.exception.IDPLoggedException| [com.adobe.idp.storeprovider.jdbc.DBStatement] errorCode:12290 errorCodeHEX:0x3002 message:execute non-query failure(insert into EDCSESSIONSTOREENTITY ( id , sequencenumber , renewalcount , sessiondata , sessionendtime) values(?, ?, ?, ?, ?)) chainedException:java.sql.SQLException: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'chainedExceptionMessage:Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT' chainedException trace:java.sql.SQLException: Binary logging not possible. Message: Transaction level 'READ-COMMITTED' in InnoDB is not safe for binlog mode 'STATEMENT'.
    why????

    Hello,
    Theproblem seems to be with isolation level, the below post may help here.
    https://confluence.atlassian.com/pages/viewpage.action?pageId=251724630
    -Vijay

  • Update multiple fields using select query efficiently – 9i

    I need to populate a table called prop_charact used for synching data to a legacy system.
    Prop_charact has fields that are found in a few other tables (no one field is found in more than one table outside of prop_charact). I want to pull the data from the corresponding fields in the source tables and put it into prop_charact. I only want to populate prop_charact with records that have been updated, but want to pull all fields for those records (whether or not that field has been updated). I am getting the list of updated records from a transaction history table.
    After getting that list, I was not sure what to do with it.
    I put what I want to do in terms of strictly SQL. I am thinking there are more efficient (less system resources) ways of doing this, but I am not sure what to pursue. I can use PL/SQL, but please keep in mind I am limited to using version 9i. Anyone have any hints about what I should look into using instead of just thes particular SQL statements?
    insert into eval.prop_charact (parcelno, propertyid)
    select distinct p.parcelno, p.propertyid
    from eval.transaction_history tr,
    admin.properties p
    where tr.propertyid = p.propertyid
    and trim(tr.tablename) in ('PROPERTIES', 'PROPERTYCHARACTERISTICS','EQID','NEWCHARACTERISTICS','DIMENSIONS', 'NON_RESIDENTIALS')
    and trim(tr.fieldname) in ('BLDGCODE', 'CATCODE', 'UNFINISHED', 'TOPOGRAPHY', 'GARAGETYPE', 'GARAGESPACES', 'OPENSPACES',
    'VIEW', 'GENERALCONSTRUCTION', 'YEARBUILT', 'ESTIMATEDYEAR', 'TOTALROOMS', 'TOTALBEDROOMS',
    'BASEMENTTYPE', 'NUMBEROFFIREPLACES', 'HEAT', 'CENTRALAIR','CONDITION','SITE_TYPE','TOTALDWELLINGAREA',
    'PLOTFRONT','PLOTDEPTH','PLOTSQFT','SHAPE','STORIES','FULLBATHROOMS','PARTBATHROOMS','MULTIPLE_BLDGS')
    and tr.trans_date >= to_date('01-01-2010', 'MM/DD/YYYY')
    and tr.trans_date < sysdate
    order by p.parcelno;
    update
    select p.BLDGCODE pBLDGCODE, epc.BLDGCODE epcBLDGCODE, p.CATCODE pCATCODE,epc.CATCODE epcCATCODE,
    p.UNFINISHED pUNFINISHED, epc.UNFINISHED epcUNFINISHED,
    pc.TOPOGRAPHY pcTOPOGRAPHY, epc.TOPOGRAPHY epcTOPOGRAPHY,
    pc.GARAGETYPE pcGARAGETYPE, epc.GARAGETYPE epcGARAGETYPE,
    pc.GARAGESPACES pcGARAGESPACES, epc.GARAGESPACES epcGARAGESPACES,
    pc.OPENSPACES pcOPENSPACES, epc.OPENSPACES epcOPENSPACES, pc.VIEW_ pcVIEW_, epc.VIEW_ epcVIEW_,
    pc.GENERALCONSTRUCTION pcGENERALCONSTRUCTION,
    epc.GENERALCONSTRUCTION epcGENERALCONSTRUCTION,
    pc.YEARBUILT pcYEARBUILT, epc.YEARBUILT epcYEARBUILT,
    pc.ESTIMATEDYEAR pcESTIMATEDYEAR, epc.ESTIMATEDYEAR epcESTIMATEDYEAR,
    pc.TOTALROOMS pcTOTALROOMS, epc.TOTALROOMS epcTOTALROOMS,
    pc.TOTALBEDROOMS pcTOTALBEDROOMS, epc.TOTALBEDROOMS epcTOTALBEDROOMS,
    pc.BASEMENTTYPE pcBASEMENTTYPE, epc.BASEMENTTYPE epcBASEMENTTYPE,
    pc.NUMBEROFFIREPLACES pcNUMBEROFFIREPLACES, epc.NUMBEROFFIREPLACES epcNUMBEROFFIREPLACES,
    pc.HEAT pcHEAT, epc.HEAT epcHEAT, pc.CENTRALAIR pcCENTRALAIR, epc.CENTRALAIR epcCENTRALAIR,
    e.CONDITION eCONDITION, epc.CONDITION epcCONDITION,
    n.SITE_TYPE nSITE_TYPE, epc.SITE_TYPE epcSITE_TYPE,
    d.TOTALDWELLINGAREA dTOTALDWELLINGAREA, epc.TOTALDWELLINGAREA epcTOTALDWELLINGAREA,
    d.PLOTFRONT dPLOTFRONT, epc.PLOTFRONT epcPLOTFRONT,
    d.PLOTDEPTH dPLOTDEPTH, epc.PLOTDEPTH epcPLOTDEPTH,
    d.PLOTSQFT dPLOTSQFT, epc.PLOTSQFT epcPLOTSQFT,d.SHAPE dSHAPE, epc.SHAPE epcSHAPE,
    pc.STORIES pcSTORIES, epc.STORIES epcSTORIES,
    n.FULLBATHROOMS nFULLBATHROOMS,epc.FULLBATHROOMS epcFULLBATHROOMS,
    n.PARTBATHROOMS nPARTBATHROOMS, epc.PARTBATHROOMS epcPARTBATHROOMS,
    nr.MULTIPLE_BLDGS nrMULTIPLE_BLDGS, epc.MULTIPLE_BLDGS epcMULTIPLE_BLDGS
    from eval.prop_charact epc, admin.properties p, admin.propertycharacteristics pc, admin.eqid e,
    admin.dimensions d, eval.newcharacteristics n, EVAL.non_residentials nr
    where epc.propertyid = p.propertyid and epc.propertyid = pc.propertyid and epc.propertyid = e.propertyid(+)
    and epc.propertyid = d.propertyid(+) and epc.propertyid = n.propertyid(+) and epc.propertyid = nr.propertyid(+)
    set epcBLDGCODE= pBLDGCODE, epcCATCODE= pCATCODE, epcUNFINISHED = pUNFINISHED,
    epcTOPOGRAPHY = pcTOPOGRAPHY, epcGARAGETYPE = pcGARAGETYPE, epcGARAGESPACES = pcGARAGESPACES,
    epcOPENSPACES = pcOPENSPACES, epcVIEW_ = pcVIEW_, epcGENERALCONSTRUCTION = pcGENERALCONSTRUCTION,
    epcYEARBUILT = pcYEARBUILT, epcESTIMATEDYEAR = pcESTIMATEDYEAR, epcTOTALROOMS = pcTOTALROOMS,
    epcTOTALBEDROOMS = pcTOTALBEDROOMS, epcBASEMENTTYPE = pcBASEMENTTYPE,
    epcNUMBEROFFIREPLACES = pcNUMBEROFFIREPLACES, epcHEAT = pcHEAT, epcCENTRALAIR = pcCENTRALAIR,
    epcCONDITION = eCONDITION, epcSITE_TYPE = nSITE_TYPE, epcTOTALDWELLINGAREA = dTOTALDWELLINGAREA,
    epcPLOTFRONT = dPLOTFRONT, epcPLOTDEPTH = dPLOTDEPTH, epcPLOTSQFT = dPLOTSQFT,
    epcSHAPE = dSHAPE, epcSTORIES = pcSTORIES, epcFULLBATHROOMS = nFULLBATHROOMS,
    epcPARTBATHROOMS = nPARTBATHROOMS, epcMULTIPLE_BLDGS = nrMULTIPLE_BLDGS;

    The following example may be of help.
    SQL> create table mytable(col1 number(1),
      2  col2 date);
    Table created.
    SQL> insert into mytable values(1,sysdate);
    1 row created.
    SQL> select * from mytable;
          COL1 COL2
             1 20-AUG-04
    SQL> update mytable
      2  set (col1,col2) = (select 2, sysdate-1 from dual);
    1 row updated.
    SQL> select * from mytable;
          COL1 COL2
             2 19-AUG-04

  • Can select, but cannot insert into oracle tables using php.

    I am having trouble inserting data into a tables in oracle using PHP. I can insert into the tables using baninst1, but nothing else. I can't even insert using the tables' owner. Every time I try I get the ORA-00492 error of table or view does not exist. However, I can run a select statement just fine. So far, baninst1 is the only user that can actually do inserts. I've triple checked all the table grants and everything is fine. Also, I can copy/paste the exact insert statement into SQL*Plus and it works with the correct user. It doesn't have to be baninst1. I've tried everything I can think of. I've tried putting the table name in quotes, adding the schema name to the table, checking public synonyms, but everything appears to be ok. I would greatly appreciate any suggestions others may have.
    I'm using PHP 5.2.3 with an oracle 9i DB.

    Here is the code that doesn't work. It works only with baninst1, no other username will work and all I do is change the my_username/my_password to something different. This is one example function where I try to do an insert, but it doesn't work on any of the tables I try.
    Thanks for looking.
    class Oracle {
         private $oracleUser = "my_username";
         private $oraclePassword = "my_password";
         private $oracleDB = "MY_DB";
         private $c = null;
         function Connect() {
              if ( !($this->c = ocilogon( $this->oracleUser, $this->oraclePassword, $this->oracleDB ) ) )
                   return false;
              return true;
         function AddNewTest($testName, $course, $section, $term, $maxAttempts, $length, $startDate, $startTime, $endDate, $endTime)
              $result = "";
              if( $this->c == null )
                   $this->Connect();     
              $splitIndex = strpos($course, " ");
              $subjectCode = substr($course, 0, $splitIndex);
              $courseNumber = substr($course, $splitIndex + 1);
              $insertStatment = "insert into szbtestinfo(szbtestinfo_test_name,
                                                                szbtestinfo_course_numb,
                                                           szbtestinfo_section,
                                                                szbtestinfo_max_attempts,
                                                                szbtestinfo_length_minutes,
                                                                szbtestinfo_start,
                                                                szbtestinfo_end,
                                                                szbtestinfo_id,
                                                                szbtestinfo_subj_code,
                                                                szbtestinfo_eff_term)
                                                                values( '" . $testName .
                   "', '" . $courseNumber .
                   "', '" . $section .
                   "', " . $maxAttempts .
                   ", " . $length .
                   ", to_date('" . $startDate . " " . $startTime . "', 'MM/DD/YYYY HH24:MI')" .
                   ", to_date('" . $endDate . " " . $endTime . "', 'MM/DD/YYYY HH24:MI')" .
                   ", szsnexttest.nextval" .
                   ", '" . $subjectCode .
                   "', '" . $term . "')";
              //return $insertStatment;
              $s = OCIParse($this->c, $insertStatment);
              try
                   $result = OCIExecute($s);
              catch(exception $e)
              return $result;
         }

  • Select statement to insert into a table using a loop

    hi
    create table uploadtab(
    itema varchar2(3),
    xtype varchar2(1),
    salesa number,
    margina number,
    salesb number,
    marginb number,
    salesc number,
    marginc number);
    insert into uploadtab
      (itema, xtype, salesa, margina, salesb, marginb, salesc, marginc)
    values
      ('abc', 'a', 100, .40, 300, .10, 450, .25);
    create table testinsert(itema varchar2(3),
    xtype varchar2(1),
    sales number,
    margin number);what i want to do is create 3 records based on that one in a loop
    so my desired output for testinsert is as follows
    abc  a 100  .40
    abc  a 300  .10
    abc  a 450  .25i don't want to use 3 insert tables if at all possible
    any help would be greatly appreciated
    thanks in advance
    Edited by: DM on Jul 7, 2010 2:22 PM

    Just a question on this
    INSERT INTO testinsert
    ( itema
    , xtype
    , sales
    , margin
    SELECT  itema
    ,       xtype
    ,       DECODE
            ( RN
            , 1,salesa
            , 2,salesb
            , 3,salesc
    ,       DECODE
            ( RN
            , 1,margina
            , 2,marginb
            , 3,marginc
    FROM            uploadtab
    CROSS JOIN      (
                            SELECT ROWNUM RN
                            FROM   dual
                            CONNECT BY LEVEL <= 3
    ;when you put a WHERE before the CROSS JOIN, the error
    ORA-00933:SQL command not properly ended. is displayed.

  • Using default values in INSERT INTO..SELECT..

    Hi,
    I like to do following insert in Oracle 10g
    INSERT
    INTO tab1
    x1,
    x2
    SELECT
    NVL(y1,DEFAULT),
    y2
    FROM tab2
    but oracle throws missing expression error. I don't want to substitute default values as it involves code change for any default value change. I suppose Oracle changes context to tab2 while SELECT, but is there any way to accomplishing the above INSERT?
    Edited by: ponn_raj on Jan 14, 2009 4:52 AM

    Hi,
    Welcome to the forum!
    DECLARE
      var number;
    BEGIN
        INSERT INTO test
            (col1,
             col2)
        VALUES
            (1,
             NVL(var, 0));
        COMMIT;
    END;
    /Also you can create the table and assign default values to the columns that you want. See [CREATE TABLE|http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2095331].
    From the link above:
    DEFAULT
    The DEFAULT clause lets you specify a value to be assigned to the column if a subsequent INSERT statement omits a value for the column. The datatype of the expression must match the datatype of the column. The column must also be long enough to hold this expression.
    The DEFAULT expression can include any SQL function as long as the function does not return a literal argument, a column reference, or a nested function invocation.
    Regards,
    Edited by: Walter Fernández on Jan 14, 2009 10:44 AM

  • Records are getting overwritten in the internal table using Select query.

    Hi All,
    I have following query :
    Loop at i_salesplant.
           select maramatnr mvkeVKORG mvkeVTWEG maraZZCOEAFE maraZZCOEAFEUOM mvkeZZALLPOL
           into corresponding fields of table i_zallocpol from mara inner join mvke on
           mvkematnr = maramatnr
           where MARA~zzobjtype = I_ZZOBJTYPE
             and MVKE~VKORG = i_salesplant-vkorg
             and MVKE~VTWEG = T_VTWEG.
         ENDLOOP.
    My Que : For example lets say first it selects all the records for Sales Org 1000. Next when you select the records for the Sales Org 2000 the earlier records are getting overwritten.
    Please let me know your valuable inputs.
    Thanks,
    Chandravadan

    Hi,
    Thanks alot for the reply.
    I changed query using appending as follows :
          Loop at i_salesplant.
            select maramatnr mvkeVKORG mvkeVTWEG maraZZCOEAFE maraZZCOEAFEUOM mvkeZZALLPOL
             into appending corresponding fields of table i_zallocpol from mara inner join mvke on
            mvkematnr = maramatnr
            where MARA~zzobjtype = I_ZZOBJTYPE
              and MVKE~VKORG = i_salesplant-vkorg
              and MVKE~VTWEG = T_VTWEG.
          ENDLOOp.
    But it is giving error saying " Field "APPENDING" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement. "     
    Please suggest.
    Thanks,
    Chandravadan

  • Query for inserting into dynamic partitioned table

    i want to insert into a table which is partitioned (partition name will be obtained dynamically) based on some select statement using execute immediate statement can some one help with query

    First u create table with partition.when u will insert record it will automatically enter in right partition in dynamically.
    and when u will select that record give SELECT query with partition
    Ex:
    SELECT * FROM table_name PARTITION(partition name);

  • My first PL/SQL block not working with using Select query within begin

    I am new to PL/SQL , just started with basics of BLOCKS .
    I am having a query here in executing a block .
    When i am doing a insert oprtation in Blocks Begin method everything is working fine , but when ever i tried to do select operation , some error is being thrown .
    First of all This is my Table :
    select from try :*
    KEY      VALUE
    Key     Value
    Key1     Value1
    Key2     Value2
    Key3     Value3
    ======================
    This is the code which is not working : Please see the code and tell me what is the problem .
    DECLARE
    v_KEY    VARCHAR2(20);
    v_VALUE   VARCHAR2(20);
    BEGIN
    select key into v_KEY FROM try where v_value='Value' ;
    dbms_output.put_line(v_KEY);
    END;
    When i run this code , it is saying Data Not Found on this line " select key into v_KEY FROM try where v_value='Value' ;"
    wheer when i run tis individually it worked fine :
    select KEY FROM try where VALUE='Value' ;"
    please share your ideas .as why it isn't running ??
    Edited by: user10503747 on Sep 20, 2010 3:16 AM

    Hi,
    user10503747 wrote:
    I am new to PL/SQL , just started with basics of BLOCKS .
    I am having a query here in executing a block .
    When i am doing a insert oprtation in Blocks Begin method everything is working fine , but when ever i tried to do select operation , some error is being thrown .
    First of all This is my Table :
    select from try :*
    KEY      VALUE
    Key     Value
    Key1     Value1
    Key2     Value2
    Key3     Value3
    ======================
    This is the code which is not working : Please see the code and tell me what is the problem .
    DECLARE
    v_KEY    VARCHAR2(20);
    v_VALUE   VARCHAR2(20);
    BEGIN
    select key into v_KEY FROM try where v_value='Value' ;
    dbms_output.put_line(v_KEY);
    END;
    When i run this code , it is saying Data Not Found on this line " select key into v_KEY FROM try where v_value='Value' ;"
    wheer when i run tis individually it worked fine :
    select KEY FROM try where VALUE='Value' ;"
    please share your ideas .as why it isn't running ??
    Edited by: user10503747 on Sep 20, 2010 3:16 AMInstead of:
    {code}
    select key into v_KEY FROM try where v_value='Value' ;
    {code}
    perhaps you meant something like:
    {code}
    v_value := 'Value1';
    select key into v_KEY FROM try where v_value=Value ; -- No quotes
    {code}
    Until you assign a vlue to a variable, like v_value, it is NULL, so your original statement was equivalent to
    {code}
    select KEY FROM try where NULL='Value' ;
    {code}
    In PL/SQL, a SELECT ... INTO statement must return exactly one row, or else you will get an error (either NO_DATA_FOUND or TOO_MANY_ROWS). This is different from SQL, where a query cn return any number of rows, including 0, without raising an error.

  • Order mismatch in selected data using Select query

    Hello Experts,
    We are upgrading from 4.6C to ECC6. I came across a select query on a custom table, which gives different order of data from 4.6C to ECC6. Data (no. of records) is same in both the servers but order is different. Table doesn't have indexes in either 4.6C or ECC6. What would be the cause for order change?
    Further, in 4,6C, ECC6 and data bases order of the data is totally different. Select query have some conditions in where clause with select options, but in both the cases (4.6C and ECC6) I am not passing any data from the selection screen so am getting entire data from the data base.
    Thanks in advance
    Phalani

    From the SAP service market place I found that
    1. Unless we use SORT or ORDER BY clause the order of the data is not in our control.
    2. In 4.6C, two same select queries never give the result in the same order, if the primary key contains character fields.
    Thanks for your help.
    Phalani

  • Selection breaks after inserting into dataProvider

    I have been battling this issue for a couple of days now. I
    have a HorizontalList that is using an itemRenderer component that
    I created. When I insert an item into the dataProvider using
    addItemAt....
    1) the item is inserted
    2) i see the item rendered correctly in the HorizontalList
    However, the selection breaks. What I mean by this is the
    newly added items does NOT highlight when I roll over it and if I
    click on it, it does not select. This only happens for the newly
    added item, all the others that were already in the list work fine
    (highlight and can be selected).
    I've tried calling validateNow() on the HorizontalList after
    inserting into the dataprovider but it doesn't help at all.
    Please help.

    I can't believe this, but after 2 days of trying to figure
    this out I figured it out just moments after posting to the forum!
    Here is what fixed it and I am not sure exactly why. At this
    point I don't care...
    The dataProvider I was using contained a list of custom
    objects. I had a property on the class called uid. When I commented
    out this property, everything worked. I don't know what made me
    think to try this. I guess my uid property on the class was
    conflicting with the uid property on the itemRenderer component or
    something.
    Finally.

Maybe you are looking for