Simple Select Statement Error

Hello,
I want to print user from my database, this is the code:
                      System.out.println("user:\n"); user = sc.next(); System.out.println("password:\n"); psw = sc.next();                                                     Statement s = conn.createStatement (); s.executeQuery("SELECT usr, pass FROM log WHERE usr=''"+user+" AND pass=''"+psw);                       ResultSet rs = s.getResultSet ();                       if (s.getMoreResults()){                           System.out.println("works");                       }                       else if (!s.getMoreResults()){                           System.out.println("doesn't");                           System.exit(1);                       }                         while (rs.next ())   {             String nameVal = rs.getString ("user");       String catVal = rs.getString ("pass");       System.out.println (                       "name = " + nameVal               + " pass = " + catVal);       ++count;   }
the connection is established, but it doesn't print anything when I enter data in it [ admin "1234" which exists in the db ], any idea what could be wrong? I have to mentioned that I'm a little bit fresh in Java databases.

hey I sorted out! = )
ResultSet rs = s.getResultSet ();
   if (rs.next()) {
     do {
      String nameVal = rs.getString ("lnum");
       String catVal = rs.getString ("passwd");
       System.out.println (
                "name = " + nameVal
               + " password = " + catVal);
     //  System.out.println("Full access granted ");
JOptionPane.showMessageDialog(frame,
    "Welcome in LYITstorage",
    "Welcome",
    JOptionPane.INFORMATION_MESSAGE);
Desktop.getDesktop().browse(new java.net.URI("www.google.com"));
        } while (rs.next());
   else{
       JOptionPane.showMessageDialog(frame,
    "Username or password are incorrect\n " +
     "If You don't have an account please\n press the regestration link",
    "Regestration problem",
    JOptionPane.ERROR_MESSAGE);
  }= ), thanks for help right now, but its not a end of my problems = ). I wanted to use it with INSERT, but it doesn' work as good as I want, as a matter of fact it's not working at all :), this is the code, any help would be nice :).
try
                      System.out.println("try");
                         Statement s = conn.createStatement ();
                         System.out.println("statement");
                         int count =0;
                         boolean temp;
                         String query =   "INSERT INTO log (passwd, name,surname,lnum) VALUES ('"+pa+"', '"+n+"', '"+sn+"','"+nu+"')" ;
                         System.out.println("test");
                      count=  s.executeUpdate(query);
                        System.out.println(query);
                       System.out.println(count);
                         ResultSet rs = s.getResultSet ();
                         if(rs.next()){
                             JOptionPane.showMessageDialog(frame,
                            "Welcome ",
                            "Welcome",
                             JOptionPane.INFORMATION_MESSAGE);
                        else   {
       JOptionPane.showMessageDialog(frame,
    "User already exists","error",
    JOptionPane.ERROR_MESSAGE);
   }

Similar Messages

  • Simple Select statement in MS Access

    I am not able to get this simple select statement working in MS Access.
    "SELECT PhotoLocation from RfidData WHERE TeamID = '"+teamID ;
    It is using a variable called teamID which is a string.
    The error is java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression
    Please Suggest
    Thank You...

    Let's look at your code, shall we?
    public String readPhotoLoc(String teamID)
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection(dbURL,"","");
        PreparedStatement ps = con.prepareStatement("Select PhotoLocation from RfidData ");  // There's no bind parameter here, so setString will do nothing
    ps.setString(1,teamID);
    ResultSet rs = ps.executeQuery();  // what do you do with the ResultSet?  Nothing.  //You don't return anything,  either.  I doubt that this mess even compiles.
    }Here's one suggestion for how to write it properly:
    public String readPhotoLoc(Connection connection, String teamID)
        String photoLoc = null;
         PreparedStatement ps = null;
         ResultSet rs = null;
        try
            String query = "SELECT PhotoLocation FROM RfidData WHERE TeamID = ?";
            ps = connection.prepareStatement(query);
            ps.setString(1,teamID);
            rs = ps.executeQuery();
            while (rs.next())
                photoLoc = rs.getString("PhotoLocation");
            return photoLoc;
        catch (SQLException e)
              e.printStackTrace();
               return null;
        finally
              try { if (rs != null) rs.close(); } catch (SQLException ignoreOrLogThis) {}
              try { if (ps != null) ps.close(); } catch (SQLException ignoreOrLogThis) {}
    }Make sure that the types of the columns match the Java types.
    %

  • Select statement error.

    Hi all,
    I have a select statement which will join 4 tables as shown below. Something is not working right in the select statement and caused the shortdump.
    I really cannot figure out where is not right.
    Please help.
    TYPES:  
      BEGIN OF t_lips,
        matnr TYPE matnr,
        lfimg TYPE lfimg,
        meins TYPE meins,
        vbeln TYPE vbeln_vl,
        lfart TYPE lfart,
        vstel TYPE vstel,
        maktx TYPE maktx,
        werks TYPE werks_d,
        exnum TYPE exnum,
        posnr TYPE posnr_vl,
        uecha TYPE uecha,
        netwr TYPE netwr,
        waerk TYPE waerk,
        vgbel TYPE vgbel,
      END OF t_lips.
    DATA: lt_lips      TYPE TABLE OF t_lips.
    SELECT lips~matnr lfimg lips~vrkme lips~vbeln lfart
        vbap~vstel lips~arktx lips~werks exnum
        vbap~netwr vbap~waerk lips~vgbel
        lips~posnr lips~uecha
      INTO TABLE lt_lips
      FROM lips INNER JOIN vttp
        ON    vttp~vbeln = lips~vbeln
        INNER JOIN likp
        ON    lips~vbeln = likp~vbeln
        INNER JOIN VBAP
        ON lips~vgbel = vbap~vbeln
      WHERE vttp~tknum = ps_vttk-tknum
        AND   lfimg      <> 0.
    Error analysis                                                                               
    An exception occurred that is explained in detail below.                                     
        The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught                
         in                                                                               
    procedure "GET_DATA" "(FORM)", nor was it propagated by a RAISING clause.                    
        Since the caller of the procedure could not have anticipated that the                        
        exception would occur, the current program is terminated.                                    
        The reason for the exception is:                                                             
        In a SELECT access, the read file could not be placed in the target                          
        field provided.                                                                               
    Either the conversion is not supported for the type of the target field,                     
        the target field is too small to include the value, or the data does not                     
        have the format required for the target field.                                               

    Hi,
    In the below code, where are you picking up value for LFIMG and LFART. Give the alias/table name for them also.
    for ex. lips~lfimg....
    SELECT lips~matnr lfimg lips~vrkme lips~vbeln lfart
        vbap~vstel lips~arktx lips~werks exnum
        vbap~netwr vbap~waerk lips~vgbel
        lips~posnr lips~uecha
      INTO TABLE lt_lips
      FROM lips INNER JOIN vttp
        ON    vttp~vbeln = lips~vbeln
        INNER JOIN likp
        ON    lips~vbeln = likp~vbeln
        INNER JOIN VBAP
        ON lips~vgbel = vbap~vbeln
      WHERE vttp~tknum = ps_vttk-tknum
        AND   lfimg       0.
    Hope this is useful.
    Also selection of records should be same as declared in table lt_lips otherwise use 'INTO CORRESPONDING TABLE LT_LIPS'
    Regards,
    Saba
    Edited by: Saba Sayed on Oct 24, 2008 9:30 AM

  • Slow query results for simple select statement on Exadata

    I have a table with 30+ million rows in it which I'm trying to develop a cube around. When the cube processes (sql analysis), it queries back 10k rows every 6 seconds or so. I ran the same query SQL Analysis runs to grab the data in toad and exported results, and the timing is the same, 10k every 6 seconds or so. r
    I ran an execution plan it returns just this:
    Plan
    SELECT STATEMENT  ALL_ROWSCost: 136,019  Bytes: 4,954,594,096  Cardinality: 33,935,576       
         1 TABLE ACCESS STORAGE FULL TABLE DMSN.DS3R_FH_1XRTT_FA_LVL_KPI Cost: 136,019  Bytes: 4,954,594,096  Cardinality: 33,935,576  I'm not sure if there is a setting in oracle (new to the oracle environment) which can limit performance by connection or user, but if there is, what should I look for and how can I check it.
    The Oracle version I'm using is 11.2.0.3.0 and the server is quite large as well (exadata platform). I'm curious because I've seen SQL Server return 100k rows ever 10 seconds before, I would assume an exadata system should return rows a lot quicker. How can I check where the bottle neck is?
    Edited by: k1ng87 on Apr 24, 2013 7:58 AM

    k1ng87 wrote:
    I've notice the same querying speed using Toad (export to CSV)That's not really a good way to test performance. Doing that through Toad, you are getting the database to read the data from it's disks (you don't have a choice in that) shifting bulk amounts of data over your network (that could be a considerable bottleneck) and then letting Toad format the data into CSV format (process the data adding a little bottleneck) and then write the data to another hard disk (more disk I/O = more bottleneck).
    I don't know exedata but I imagine it doesn't quite incorporate all those bottlenecks.
    and during cube processing via SQL Analysis. How can I check to see if its my network speed thats effecting it?Speak to your technical/networking team, who should be able to trace network activity/packets and see what's happening in that respect.
    Is that even possible as our system resides off site, so the traffic is going through multiple networks.Ouch... yes, that could certainly be responsible.
    I don't think its the network though because when I run both at the same time, they both are still querying at about 10k rows every 6 seconds.I don't think your performance measuring is accurate. What happens if you actually do the cube in exedata rather than using Toad or SQL Analysis (which I assume is on your client machine?)

  • Global profile select statement error

    Hello,
    I try to set up profiles to personalize reports for users.
    When I use global profile with profile value of first kind  (on a profile value screen i choose "value", type, my formula "="my variable", and click add) and attatch it to the publication, it doesn't work properly. No matter what i use inside formula field, BO environment doesn't personalize report in accordance to it.
    I've noticed that there is something wrong with select statement created by BO. After sending a publication, report instance received by user has "description" field like "(and (equal null "my variable")). No matter what i put inside formula box in profile "equal null" statement is always added.
    When i use second type profile value (filter expression) everythig seems to be fine.
    Is this some kind of bug inside global profile mechanism
    I have BO XI R 3.1 without any fixpacks.
    Thanks in advance for any help
    best regards
    Wojtek

    Hi,
    In the Values option one can only use fixed values no formulas. Hence the formulas will not work.
    In my case the expression option does not work. Have you tried using a formual =CurrentUser in the expression field.

  • Help with a simple select statement

    $x = oci_parse($c, "select quantity from balance where item_num=101");
    oci_execute($x);
    echo "the quant is: ".$x;
    I try to run this select statement without success
    then I tried...
    $x = oci_parse($c, "select quantity from balance where item_num=101");
    $y= oci_execute($x);
    echo "the quant is: ".$y;
    and it didn't work either...
    What should I change?
    thanks!

    The Oracle library operates a bit differently from some other PHP libraries, notably MySQL/MySQLi. With Oracle (OCI8), you have to execute the statement, and then afterward use an oci_fetch...() function to pull things from your $statement variable. Here's a small example that hopefully will illustrate the basic usage:
    <?php
         $conn = oci_connect('hr','hr','xe');
         if(!$conn) {
              echo 'Could not connect!';
              exit;
         $sql = 'select * from jobs';
         $stmt = oci_parse($conn, $sql);
         if(!$stmt) {
              echo 'Could not parse query.';
              exit;
         $result = oci_execute($stmt, OCI_DEFAULT);
         if(!$result) {
              echo 'Could not execute query.';
              exit;
         echo "Query ran successfully.\n";
         // Fetch rows as associative arrays, so
         // we can ask for values by column name.
         // Other options include oci_fetch_row(),
         // oci_fetch_array(), and oci_fetch_object().
         // Note that oci_fetch_assoc() will create
         // an associative array using upper-case
         // column names for the keys.
         while(($row = oci_fetch_assoc($stmt)) != null)
              echo $row['JOB_ID'] . ': ' . $row['JOB_TITLE'] . "\n";
         echo "All data returned.\n";
         oci_close($conn);
    ?>When I run this, I get the following:
    C:\workspace\php>php select.php
    Query ran successfully.
    AD_PRES: President
    AD_VP: Administration Vice President
    AD_ASST: Administration Assistant
    FI_MGR: Finance Manager
    FI_ACCOUNT: Accountant
    AC_MGR: Accounting Manager
    AC_ACCOUNT: Public Accountant
    SA_MAN: Sales Manager
    SA_REP: Sales Representative
    PU_MAN: Purchasing Manager
    PU_CLERK: Purchasing Clerk
    ST_MAN: Stock Manager
    ST_CLERK: Stock Clerk
    SH_CLERK: Shipping Clerk
    IT_PROG: Programmer
    MK_MAN: Marketing Manager
    MK_REP: Marketing Representative
    HR_REP: Human Resources Representative
    PR_REP: Public Relations Representative
    All data returned.
    C:\workspace\php>For more information, take a look at the OCI8 library documentation in the PHP manual online:
    OCI8
    http://us.php.net/manual/en/book.oci8.php
    Some other examples
    http://us.php.net/manual/en/oci8.examples.php
    Kind regards,
    Christopher L. Simons

  • Script logic select statement error (*SELECT(%YEAR%,"[YEAR]","T_TIME","[ID]

    Hi
    i am trying to use the below statement . its giving error . pls have a look
    *SELECT(%YEAR%,"[YEAR]","T_TIME",u201D[ID]=%T_TIME_SET%u201D)
    *SELECT(%PYEAR%,"[YEAR]-1","T_TIME",u201D[ID]=%T_TIME_SET%u201D)
    *RUNALLOCATION
    *FACTOR=1
    *DIM T_MOVEMENTS WHAT = CB; WHERE=OB;
    *DIM T_TIME WHAT=MAR.%PYEAR%; WHERE=BAS(TOTAL.%YEAR%)
    *ENDALLOCATION
    *COMMIT
    The resule
    Validation status of executable file: Failed
    - Incorrect syntax near 'u201D'. in:select [YEAR] from mbrT_TIME where u201D[ID]=%T_TIME_SET%u201D
    Validation status of syntax: Failed
    - Invalid syntax found; see statements in red
    Bud if specify the year its running properly. pls  advice me whare i was wrong
    Thanks

    Hi Narsi,
    You can use the below instruction:
    *SELECT(%YEAR%,"[YEAR]","T_TIME",u201DID='%T_TIME_SET%'u201D)
    *SELECT(%PYEAR%,"[YEAR]-1","T_TIME",u201DID='%T_TIME_SET%'u201D)
    I have just added single quote before and after %T_TIME_SET% and %T_TIME_SET%
    Please try this!!
    Thanks,
    Rohit

  • Urgent , abap select statement error ...

    Hi all ,
    here i attached my code , has anyone can tell me where is the error ???
    when i active this code , it showed :
    "comma without preceding colon(after select?)"
    thanks a lot !
    SELECT LIPSERDAT LIPSVBELN LIPSPOSNR LIPSVGPOS LIPS~LFIMG
    LIPSVRKME LIKPWADAT_IST LIKPKUNAG LIKPKUNNR LIKP~VBELN
    VBAPVBELN VBAPMATNR VBAPNETWR VBAPWAERK VBAPMWSBP VBAPNETPR
    VBAPPOSNR VBUPKOSTA VBUPWBSTA VBUPFKSTA VBUPPOSNR VBUPVBELN
    VBPAPARVW VBPAVBELN VBUKCMGST VBUKVBELN VBAKAUART VBAKVBELN
    INTO (
    WASTATUS-ERDAT , WASTATUS-VBELN , WASTATUS-POSNR ,
    WASTATUS-VGPOS , WASTATUS-LFIMG , WASTATUS-VRKME ,
    WASTATUS-WADAT_IST , WASTATUS-KUNAG ,WASTATUS-KUNNR ,
    WASTATUS-LIKPVBELN , WASTATUS-VBAPVBELN , WASTATUS-MATNR ,
    WASTATUS-NETWR , WASTATUS-WAERK , WASTATUS-MWSBP ,
    WASTATUS-NETPR , WASTATUS-POSNR , WASTATUS-KOSTA , WASTATUS-WBSTA ,
    WASTATUS-FKSTA , WASTATUS-VBUPPOSNR , WASTATUS-VBUPVBELN ,
    WASTATUS-PARVW , WASTATUS-VBPAVBELN , WASTATUS-CMGST ,
    WASTATUS-VBUKVBELN , WASTATUS-AUART , WASTATUS-VBAKVBELN )
        FROM ( LIPS inner join LIKP
               on  LIKPVBELN = LIPSVBELN
               inner join VBAP
               on  VBAPVBELN = LIPSVGBEL
               and VBAPPOSNR = LIPSVGPOS
               inner join VBUP
               on  VBUPPOSNR = LIPSPOSNR
               and VBUPVBELN = LIPSVBELN
               inner join VBPA
               on  VBPAVBELN = LIPSVBELN
               inner join VBUK
               on  VBUKVBELN = LIPSVBELN
               inner join VBAK
               on  VBAKVBELN = VBAPVBELN )
            WHERE
               LIPS~VBELN in P_SVBELN
               and LIPS~ERDAT in P_ERDAT
               and LIKP~KUNAG in P_KUNAG
               and LIKP~KUNNR in P_KUNNR
               and VBAP~VBELN in P_PVBELN
               and VBUP~KOSTA in P_KOSTA
               and VBUP~WBSTA in P_WBSTA
               and VBUP~FKSTA in P_FKSTA
               and VBPA~PARVW in P_PARVW
               and VBUK~CMGST in P_CMGST .

    sorry all ,
       i already removed the space on my code like that :
       but it still displayed the error .
    SELECT LIPS~ERDAT
    <b>*LIPSVBELN LIPSPOSNR LIPSVGPOS LIPSLFIMG
    *LIPSVRKME LIKPWADAT_IST LIKPKUNAG LIKPKUNNR LIKP~VBELN
    *VBAPVBELN VBAPMATNR VBAPNETWR VBAPWAERK VBAPMWSBP VBAPNETPR
    *VBAPPOSNR VBUPKOSTA VBUPWBSTA VBUPFKSTA VBUPPOSNR VBUPVBELN
    *VBPAPARVW VBPAVBELN VBUKCMGST VBUKVBELN VBAKAUART VBAKVBELN</b>    FROM ( LIPS inner join LIKP
               on  LIKPVBELN = LIPSVBELN
               inner join VBAP
               on  VBAPVBELN = LIPSVGBEL
               and VBAPPOSNR = LIPSVGPOS
               inner join VBUP
               on  VBUPPOSNR = LIPSPOSNR
               and VBUPVBELN = LIPSVBELN
               inner join VBPA
               on  VBPAVBELN = LIPSVBELN
               inner join VBUK
               on  VBUKVBELN = LIPSVBELN
               inner join VBAK
               on  VBAKVBELN = VBAPVBELN )
    INTO (WASTATUS-ERDAT)
    <b>*WASTATUS-VBELN, WASTATUS-POSNR, WASTATUS-VGPOS,WASTATUS-LFIMG)
    *WASTATUS-VRKME,
    *WASTATUS-WADAT_IST, WASTATUS-KUNAG,WASTATUS-KUNNR,
    *WASTATUS-LIKPVBELN, WASTATUS-VBAPVBELN, WASTATUS-MATNR,
    *WASTATUS-NETWR, WASTATUS-WAERK, WASTATUS-MWSBP,
    *WASTATUS-NETPR, WASTATUS-POSNR, WASTATUS-KOSTA, WASTATUS-WBSTA,
    *WASTATUS-FKSTA, WASTATUS-VBUPPOSNR, WASTATUS-VBUPVBELN,
    *WASTATUS-PARVW, WASTATUS-VBPAVBELN, WASTATUS-CMGST,
    *WASTATUS-VBUKVBELN, WASTATUS-AUART, WASTATUS-VBAKVBELN )</b>        WHERE
               LIPS~VBELN in P_SVBELN
               and LIPS~ERDAT in P_ERDAT
               and LIKP~KUNAG in P_KUNAG
               and LIKP~KUNNR in P_KUNNR
               and VBAP~VBELN in P_PVBELN
               and VBUP~KOSTA in P_KOSTA
               and VBUP~WBSTA in P_WBSTA
               and VBUP~FKSTA in P_FKSTA
               and VBPA~PARVW in P_PARVW
               and VBUK~CMGST in P_CMGST .

  • Urgent , abap select statement error VBPA ...

    hi gurus,
    please tell me what is the wrong in the following select statment:
    it returns 4 dispite that the data is there in the table VBPA
    like this :
    VBPA
    Cl.                          :     200
    Document                :    0010002449
    Item                         :
    Funct                      :    PE
    Pers.No.  :                    100820
    SELECT SINGLE
      pernr
    INTO  w_pernr
    FROM  vbpa
    WHERE VBELN   EQ '0010002449'
    and   kunnr   EQ 'PE'.

    hi
    good
    wrong one ->
    SELECT SINGLE
    pernr
    INTO w_pernr
    FROM vbpa
    WHERE VBELN EQ '0010002449'
    and kunnr EQ 'PE'.
    SELECT SINGLE
    pernr
    INTO w_pernr
    FROM vbpa
    WHERE VBELN EQ 0010002449
    and kunnr EQ PE.
    change like this and check the difference.
    thanks
    mrutyun^

  • Normal select statement error!??

    Hello All,
    I have a table with primary key (antrag_nr, beladeflag, stempel)
    Desc test88
    Name Null? Type
    ANTRAG_NR NOT NULL NUMBER
    A_PROZESS NUMBER
    STEMPEL NOT NULL DATE
    BELADEFLAG NOT NULL VARCHAR2(1)
    desc test99
    Name Null? Type
    ANTRAG_NR NOT NULL NUMBER
    A_PROZESS NUMBER
    STEMPEL NOT NULL DATE
    BELADEFLAG NOT NULL VARCHAR2(1)
    select * from test99;
    ANTRAG_NR A_PROZESS STEMPEL B
    1 3 04-JAN-05 m
    2 4 04-JAN-05 m
    1     4 05-JAN-05 m
    select * from test88;
    ANTRAG_NR A_PROZESS STEMPEL B
    1 1 01-JAN-05 m
    1 2 02-JAN-05 m
    1 2 03-JAN-05 m
    1 3 04-JAN-05 m
    2 1 01-JAN-05 m
    2 2 02-JAN-05 m
    2     3 04-JAN-05 m
    I am writing this query now and getting the below answer.
    select a.antrag_nr, a.a_prozess, a.stempel, a.beladeflag from test88 a, test99 b where a.antrag_nr = b.antrag_nr and a.a_prozess <> b.a_prozess and a.stempel = (select max(stempel) from test88);
    ANTRAG_NR A_PROZESS STEMPEL B
    2 3 04-JAN-05 m
    1     3 04-JAN-05 m
    according to my query I have ’a a.a_prozess <> b.a_prozess’ but why do I get 1 3 04-jan-05 m
    Please let me know where have I gone wrong!!
    RGds
    Karhtik krishna

    The way your initial query was designed, checks all a_prozess available for each antrag_nr. If I change your query around I can demonstrate.
    select  a.antrag_nr
    ,       b.a_prozess
    ,       a.stempel
    ,       a.beladeflag
    from    test88 a
    ,       test99 b
    where   a.antrag_nr = b.antrag_nr
    and     a.a_prozess <> b.a_prozess
    and     a.stempel = (   select max(stempel)
                            from test88
    ANTRAG_NR     A_PROZESS     STEMPEL          BELADEFLAG
    1          4          4-JAN-2005     m
    2          4          4-JAN-2005     m

  • SELECT statement in stored procedure

    I want to be able to execute a simple SELECT statement from within a stored procedure and return a stream of data which consists of all the rows from the SELECT statement.
    Ultimately, I want to ouput this stream of data to a Crystal Report.
    Apparently, Oracle will not allow you to execute a simple SELECT statement from within a stored procedure. It will only allow execution of a SELECT INTO statment, which requires that you define a cursor, etc. etc.
    Any way around this?
    Thanks
    Bill

    Look into REF CURSORs. Still not sure about whether APEX uses them though.... Good luck.

  • Dynamic table name in an inner join - select statement

    Hi,
    Please can you let me know if is possible to use a Dynamic table name in an inner join?
    Something like the statement below? (It works in a simple select statement but not in an inner join)
    SELECT  *
         INTO CORRESPONDING FIELDS OF <t_itab>
          FROM <Dynamic table name> INNER JOIN pa0050 ON
          ( <Dynamic table name>pernr =  pa0050pernr )
           WHERE <Dynamic table name>~pernr = it_pernr-l_pernr
           AND pa0050~bdegr = f_bdegr.
    Any help would be apprecited very much.
    Thanks & Regards.

    Hi,
    Check this link.
    [http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb39c4358411d1829f0000e829fbfe/frameset.htm]
    [Re: accessing dynamic internal table's fields??;
    hope it'll help u.
    Regards,
    Sneha.
    Edited by: sneha kumari on Jun 18, 2009 1:57 PM

  • Doubt about Select statement.

    Hi folks!!
                 I have a few doubts about the select statements, it may be a silly things but its useful for me.
    what is   difference between below statment.
    1)SELECT * FROM TABLE.
    2)SELECT SINGLE * FROM TABLE
    3)SELECT SINGLE FROM TABLE.
    Hope i will get answer,thanks in advance.
    Regards
    Richie..

    Hi,
    try this and if possible use sap help.i mean place the cursor on select and press F1.
                 Types of select statements:
    1.     select * from ztxlfa1 into table it.
                 This is simple select statement to fetch all the data of db table into internal table it.
       2.   select * from ztxlfa1 into table it where lifnr between 'V2' and 'V5'.
            Thisis using where condition between v2 and v5.
      4. select * from ztxlfa1 where land1 = 'DE'. "row goes into default table work Area
      5. select lifnr land1 from ztxlfa1
            into corresponding fields of it   "notice 'table' is omitted
             where land1 = 'DE'.
              append it.
               endselect.
         Now data will go into work area. and then u will add it to internal table by     
            append statement.
      6.   Table 13.2 contains a list of the various forms of select as it is used with internal tables and their relative efficiency. They are in descending order of most-to-least efficient.
    Table 13.2  Various Forms of SELECT when Filling an Internal Table
    Statement(s)                                   Writes To
    select into table it                                    Body
    select into corresponding fields of table it   Body
    select into it                                    Header line
    select into corresponding fields of it           Header line
    7. SELECT VBRK~VBELN
           VBRK~VKORG
           VBRK~FKDAT
           VBRK~NETWR
           VBRK~WAERK
           TVKOT~VTEXT
           T001~BUKRS
           T001~BUTXT
        INTO CORRESPONDING FIELDS OF TABLE IT_FINAL
        FROM VBRK
        INNER JOIN TVKOT ON VBRKVKORG = TVKOTVKORG
        INNER JOIN T001 ON VBRKBUKRS = T001BUKRS
        WHERE VBELN IN DOCNUM AND VBRK~FKSTO = ''
       AND VBRK~FKDAT in date.
    Select statement using inner joins for vbrk and t001 and tvkot table for this case based on the conditions
    8. SELECT T001W~NAME1 INTO  TABLE IT1_T001W
    FROM T001W INNER JOIN EKPO ON T001WWERKS = EKPOWERKS
    WHERE EKPO~EBELN = PURORD.
    here selecting a single field into table it1_t001winner join on ekpo.
    9. SELECT BUKRS LIFNR EBELN FROM EKKO INTO CORRESPONDING FIELDS OF IT_EKKO WHERE     EBELN IN P_O_NO.
    ENDSELECT.
    SELECT BUTXT   FROM T001 INTO  IT_T001 FOR ALL ENTRIES IN IT_EKKO WHERE BUKRS = IT_EKKO-BUKRS.
    ENDSELECT.
    APPEND IT_T001.
    here I am using for all entries statement with select statement. Both joins and for all entries used to fetch the data on condition but for all entries is the best one.
    10. SELECT AVBELN BVTEXT AFKDAT CBUTXT ANETWR AWAERK INTO TABLE ITAB
                 FROM  VBRK AS A
                 INNER JOIN TVKOT AS B ON
                 AVKORG EQ BVKORG
                 INNER JOIN T001 AS C ON
                 ABUKRS EQ CBUKRS
                 WHERE  AVBELN IN BDOCU AND AFKSTO EQ ' ' AND B~SPRAS EQ
                 SY-LANGU
                 AND AFKDAT IN BDATE AND AVBELN EQ ANY ( SELECT VBELN FROM
                VBRP WHERE VBRP~MATNR EQ ITEMS ).
        Here we are using sub query in inner join specified in brackets.
    Thanks,
    chandu.

  • Stored Procedures for Simple SQL statements

    Hi Guys,
    We are using Oracle 10g database and Web logic for frontend.
    The Product is previously developed in DotNet and SQL Server and now its going to develop into Java (Web Logic) and Oracle 10g database.
    Since the project is developed in SQL Server, there are lot many procedures written for simple sql queries. Now I would like to gather your suggestions / pointers on using procedures for simple select statements or Inserts from Java.
    I have gathered some list for using PL/SQL procedure for simple select queries like
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)
    Simple select statements are much faster than executing them from Procedure
    Pros
    Code changes for modifying select query in PL/SQL much easier than in Java
    Your help in this regard is more valuable. Please post your points / thoughts here.
    Thanks & Regards
    Srinivas
    Edited by: Srinivas_Reddy on Dec 1, 2009 4:52 PM

    Srinivas_Reddy wrote:
    Cons
    If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)No entirely correct. All SQLs that hit the SQL engine are stored as cursors.
    On the client side, you have an interface that deals with this SQL cursor. It can be a Java class, a Delphi dataset, or a PL/SQL refcursor.
    Yes, cursors are created/opened at a huge rate by the SQL engine. But is is capable of doing that. What you need to do to facilitate that is send it SQLs that uses bind variables. This enables the SQL engine to simply re-use the existing cursor for that SQL.
    Simple select statements are much faster than executing them from ProcedureAlso not really correct. SQL performance is SQL performance. It has nothing to do with how you create the SQL on the client side and what client interface you use. The SQL engine does not care whether you use a PL/SQL ref cursor or a Java class as your client interface. That does not change the SQL engine's performance.
    Yes, this can change the performance on the client side. But that is entirely in the hands of the developer and how the developer selected to use the available client interfaces to interface with the SQL cursor in the SQL engine.
    Pros
    Code changes for modifying select query in PL/SQL much easier than in JavaThis is not a pro merely for ref cursors, but using PL/SQL as the abstraction layer for the data model implemented, and having it provide a "business function" interface to clients, instead of having the clients dealing with the complexities of the data model and SQL.
    I would seriously consider ref cursors in your environment. With PL/SQL servicing as the interface, there is a single place to tune SQL, and a single place to update SQL. It allows one to make data model changes without changing or even recompiling the client. It allows one to add new business logical and processing rules, again without having to touch the client.

  • Use of cursors insted of select statements

    could any one please explain what is the advantage of using cursors instead of simple select statements
    thanks
    siby

    A benefit to using an explicit cursor rather than a select statement, is for the NO_DATA_FOUND exception. Its kind of like a free IF statment. IF no data is found, then stop.
    if you write a select statement, and no data is returned, you SHOULD code for the NO_DATA_FOUND exception. Often people say, "i'll ALWAYS get a row returned". but you should always cover your code "just in case". so you must code an exception...
    declare
    v_var varchar2(1);
    procedure do_something(p_parm varchar2) is
    begin
    null;
    end do_something;
    procedure log_error is
    begin
    null;
    end log_error;
    begin <<main>>
    do_something('x');
    begin <<selectblock>>
    select dummy
    into v_var
    from dual
    where dummy = 'a';
    do_something(v_var);
    exception
    when no_data_found then
    log_error;
    end selectblock;
    do_something (v_var||'abc');
    end main;
    if you use an explicit cursor instead, you don't need to code for the NO_DATA_FOUND. If an explicit cursor opens and finds no rows, there are simply no rows. of course, you don't need a loop if you expect only 1 row returned under normal circumstances.
    BTW, don' forget that SQL%ROWCOUNT and your_cursor%ROWCOUNT are not initialized. There is a null, until a row is successfully fetched. therefore if no rows are returned at all, %ROWCOUNT is NULL.
    declare
    v_var varchar2(1);
    cursor my_cur is
    select dummy
    from dual
    where dummy = 'a';
    procedure do_something(p_parm varchar2) is
    begin
    null;
    end do_something;
    procedure log_error is
    begin
    null;
    end log_error;
    begin << main>>
    for cur_rec in my_cur loop
    dbms_output.put_line('inside');
    begin <<loop_block>>
    if nvl(my_cur%rowcount,0) > 1 then
    do_something(cur_rec.dummy);
    else
    log_error;
    end if;
    end loop_block;
    end loop;
    end main;
    /

Maybe you are looking for

  • Reports to Generate Statistics of Vendors

    Hello. Iu2019m looking some reports to find this;;; 1- Vendors that has emitted the greater quantity of purchase orders  (Top 10). 2- Vendors with PO or Blanket Orders  to which the greater amount of money has been paid to them  (Top 10). 3- Vendors

  • Jlist with database?

    I have to get a few members out of a database and put them in a list. Then the admin can select the member he wants and alter his information. Now i was thinking of putting those members into a Jlist but I have a few problems with that. I want it in

  • What is the definition of a Java Basic Block?

    The ClassFile specification reads "The intent is that a stack frame map must appear at the beginning of each basic block in a method." but it never goes about defining what a "basic block" is. http://en.wikipedia.org/wiki/Basic_block indicates that b

  • I wanted to know how does technical support work via icloud and is there any new technology out that helps providing technical support

    i wanted to know how does technical support work via icloud and is there any new technology out that helps providing technical support?

  • A guide for unlocking cores

    This may be an old topic but I am new to doing anything with core unlocks. I will provide my specific 800 series board ident shortly. My question is:  is there a guide for doing this at the Forum or elsewhere? Are there other materials such as BIOS m