SQl Select Statement. Please help

Hi all,
Is this statement correct?Can anyone please give me the correct way of writing one.
String query = "SELECT EmployeeID, LastName, FirstName, EmailAddress, PhoneNumber from Employees where EmployeeID="<%=request.getParameter("ID")%>;
I also tried
String id = request.getParameter("ID");
String query = "SELECT EmployeeID, LastName, FirstName, EmailAddress, PhoneNumber from Employees where EmployeeID="<%=request.getParameter("ID")%>;
This also didn't work.
Thanx

Thanks for reply. Tried your reply. Got this exception.
javax.servlet.ServletException: [Microsoft][ODBC Driver Manager] Invalid cursor state
Not trying anything special just to execute this query and post the results. Here is the full code.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:empapp";
Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement();
String id = request.getParameter("ID");
if(id != null)
String query = "SELECT EmployeeID, LastName, FirstName, EmailAddress, PhoneNumber from Employees where EmployeeID='"+request.getParameter("ID")+"'";
//PreparedStatement statement = conn.prepareStatement(query);
//statement.setString(1, id);
ResultSet rs = stmt.executeQuery(query);
%>
Employee ID: <%= rs.getString("EmployeeID") %>
Lasyt Name: <%=rs.getString("LastName")%>
First Name: <%=rs.getString("FirstName")%>
Email Address: <%=rs.getString("EmailAddress") %>
PhoneNumber: <%=rs.getString("PhoneNumber") %>
<%
%>
String query = "SELECT EmployeeID, LastName, FirstName, EmailAddress, PhoneNumber from Employees where EmployeeID='"+request.getParameter("ID")+"'";
Thanks

Similar Messages

  • Unsure of syntax for SQL SELECT statement, please help

    I am trying to execute the following SQL statement:
    ResultSet rs = stB.executeQuery("SELECT quantity FROM stocklevels WHERE code=salesCode[x]");where SalesCode is an integer array and x is a counter used to loop this part of the code. I keep getting the "syntax error - missing operator" message when I run the code and get to this line, can anybody please tell me the correct syntax/form to use? Many thanks.

    Is salesCode an array in Java or in your DB? I don't know anything about SQL arrays, so I'll assume it's in your Java code.
    You want to put the value of salesCode[x] into the query--say 123456. But what you've got is like doing System.out.println("The code = salesCode[x]"); and then wondering why you're seeing "salesCode[x]" instead of "123456. You'd need to do System.out.println("The code = " + salesCode[x]); Similarly, you could take the "salesCode[x]" out of the string literal that's forming the query, in order to have it evaluated as an int and stuffed into the string as "123456". It would be better to use a PreparedStatement though: ps = con.prepareStatement("select .... where code = ?");
    ps.setInt(1, salsedCode[x]);
    rs = ps.executeQuery();

  • SQL Select Statement. Help Needed

    Hi all,
    Can anyone point out why i am getting this error. Any help is appreciated.
    javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver]COUNT field incorrect
    EmployeeID field is text field.(MS Access DB). It is not a primary key.
    Here is what I have(code)
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url = "jdbc:odbc:empapp";
    Connection conn = DriverManager.getConnection(url);
    Statement stmt = conn.createStatement();
    String id = request.getParameter("ID"); // ID is passed from another jsp page.
    if(id != null)
    String query = "SELECT EmployeeID, LastName, FirstName, EmailAddress, PhoneNumber from Employees where EmployeeID=?";
    PreparedStatement statement = conn.prepareStatement(query);
    statement.setString(1, id);
    ResultSet rs = stmt.executeQuery(query);
    %>
    Employee ID: <%= rs.getString("EmployeeID") %>
    Lasyt Name: <%=rs.getString("LastName")%>
    First Name: <%=rs.getString("FirstName")%>
    Email Address: <%=rs.getString("EmailAddress") %>
    PhoneNumber: <%=rs.getString("PhoneNumber") %>
    <%
    %>
    I m only trying to print it out.
    Thanks

    Thanks for the reply. I know this is not the way to do
    it. I have a question for you.
    What's the difference in storing the DB connection
    info, query etc..
    a. In a pure java object.
    b. In a servlet.
    c. In a java bean.
    Which one to use and why?
    Thank you
    What's the difference between (a) and (c) in your mind? Are not Java Beans pure Java objects?
    Depends on the app.
    For my Web apps I let Tomcat create a connection pool for me. I don't store connections anywhere in my code. I check them out of the pool, use them, and put them back.
    I think this is a good way to go for any app.

  • Jdev9i, JSP, Execute a Sql Select statement directly?

    Hi,
    I need the syntax to execute a Sql SELECT statement directly against Oracle database and access rows(returned by SELECT statemnet) in a JSP page or Servlet? Any sample code available for this.
    Thanks.

    Hi Ali,
    I didn't work a lot with jsp ,but on this url some help .
    http://otn.oracle.com/docs/products/oracle8i/doc_library/817_doc/java.817/a83726/basics7.htm#1014578

  • Convert sql select statement to oracle

    Hi All,
    Can anyone help me converting this Sql select statement to oracle ....
    -----------------------------------------Query--------------------------------------------------------------
    select emp_master.emp_code ,
    emp_master.dept_cd ,
    attendance_master.daily_attn_code ,
    attendance_master.linked_column ,
    case when location.payroll_status <> 'N' and eDocsNetEmployeesLeave.StartDate < dateadd(mm, 1 , convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01'))     
    then
    dateadd(mm, 1 , convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01'))
    when eDocsNetEmployeesLeave.StartDate < convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01')     
    then convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01') else eDocsNetEmployeesLeaveDetails.StartDate           
    end ,
    eDocsNetEmployeesLeaveDetails.NoOfDays,          
    case when eDocsNetEmployeesLeave.StartDate > location.next_pay_date     
    then convert(datetime , convert(varchar, dateadd(ss,-1, dateadd(mm, 1, convert(datetime , datename(yy,eDocsNetEmployeesLeave.StartDate)+ '/' + datename(mm,eDocsNetEmployeesLeave.StartDate)+ '/01') )),106) )     
    else      
    case when location.payroll_status <> 'N'
    then dateadd(mm,1,location.next_pay_date)      
    else location.next_pay_date
    end      
    end as PaymentDate               ,
    isnull(grade_master.leave_type,'C') ,
    eDocsNetEmployeesLeave.StartDate ,          
    eDocsNetEmployeesLeaveDetails.LeaveType
    from eDocsNetEmployeesLeave ,
    eDocsNetEmployeesLeaveDetails ,
    eDocsNetLeaveTypes ,
    emp_master ,
    grade_master ,
    attendance_master ,
    location
    where eDocsNetEmployeesLeaveDetails.RequestID     = eDocsNetEmployeesLeave.RequestID and
    eDocsNetEmployeesLeave.EmployeeID = emp_master.emp_code and
    eDocsNetEmployeesLeaveDetails.LeaveType = eDocsNetLeaveTypes.LeaveTypeID and
    eDocsNetLeaveTypes.loc_cd = emp_master.loc_cd and
    location.loc_cd = emp_master.loc_cd and
    attendance_master.loc_cd = emp_master.loc_cd and
    attendance_master.linked_column = eDocsNetLeaveTypes.LinkedAttendance and
    grade_master.loc_cd = emp_master.loc_cd and
    grade_master.grade_cd = emp_master.grade_cd and
    eDocsNetEmployeesLeaveDetails.RequestID      = @RequestID
    order by eDocsNetEmployeesLeaveDetails.StartDate
    Thanks in Advance
    Smiley

    Seems like you want to convert a SQL statement from the ??? dialect to the Oracle dialect. *(It would be useful to indicate the non-ANSI standard SQL you are starting with.)
    Part of the problem is that you use several date related functions. Some are unnecessary in Oracle and some need to translated into Oracle functions as found in the Functions section (chapter 5) of the SQL Reference manual at http://www.oracle.com/pls/db102/homepage
    Note that columns and expressions of type 'date' in ORacle always contain all of "yyyy mm dd hh mi ss" and you need to format and trauncate as necessary.
    Also note that '09-JAN-31' is NOT an Oracle date, but rather a character representation of a date which must be converted to/from a date expression. You will often need to use the to_date() and to_char() functions with a format mask as the second parameter. This is also descreibed in the first 2 chapters of the SQL Reference manual.

  • Parsing an OPEN SQL select statement

    Hi all,
      I want to parse an open SQL select statement to get the list of tables and the corresponding fields in the select statement.
      Is there some ABAP-internal syntax from the SAP Database Interface that does this? or is the only option to do this is to manually break the statement?
    Thanks.
    Girish

    Hi,
    I doubt if there is something like that available to use. It think you will have to write a parser for yourself.
    Regards

  • Using column number inplace of column name in SQL Select statement

    Is there a way to run sql select statements with column numbers in
    place of column names?
    Current SQL
    select AddressId,Name,City from AddressIs this possible
    select 1,2,5 from AddressThanks in Advance

    user10962462 wrote:
    well, ok, it's not possible with SQL, but how about PL/SQL?As mentioned, using DBMS_SQL you can only really use positional notation... and you can also use those positions to get the other information such as what the column is called, what it's datatype is etc.
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2) IS
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_rowcount  NUMBER := 0;
    BEGIN
      -- create a cursor
      c := DBMS_SQL.OPEN_CURSOR;
      -- parse the SQL statement into the cursor
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      -- execute the cursor
      d := DBMS_SQL.EXECUTE(c);
      -- Describe the columns returned by the SQL statement
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      -- Bind local return variables to the various columns based on their types
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000); -- Varchar2
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);      -- Number
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);     -- Date
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);  -- Any other type return as varchar2
        END CASE;
      END LOOP;
      -- Display what columns are being returned...
      DBMS_OUTPUT.PUT_LINE('-- Columns --');
      FOR j in 1..col_cnt
      LOOP
        DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' - '||case rec_tab(j).col_type when 1 then 'VARCHAR2'
                                                                                  when 2 then 'NUMBER'
                                                                                  when 12 then 'DATE'
                                                         else 'Other' end);
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('-------------');
      -- This part outputs the DATA
      LOOP
        -- Fetch a row of data through the cursor
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        -- Exit when no more rows
        EXIT WHEN v_ret = 0;
        v_rowcount := v_rowcount + 1;
        DBMS_OUTPUT.PUT_LINE('Row: '||v_rowcount);
        DBMS_OUTPUT.PUT_LINE('--------------');
        -- Fetch the value of each column from the row
        FOR j in 1..col_cnt
        LOOP
          -- Fetch each column into the correct data type based on the description of the column
          CASE rec_tab(j).col_type
            WHEN 1  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
            WHEN 2  THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_n_val);
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                         DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'));
          ELSE
            DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
            DBMS_OUTPUT.PUT_LINE(rec_tab(j).col_name||' : '||v_v_val);
          END CASE;
        END LOOP;
        DBMS_OUTPUT.PUT_LINE('--------------');
      END LOOP;
      -- Close the cursor now we have finished with it
      DBMS_SQL.CLOSE_CURSOR(c);
    END;
    SQL> exec run_query('select empno, ename, deptno, sal from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    DEPTNO - NUMBER
    SAL - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    DEPTNO : 10
    SAL : 2450
    Row: 2
    EMPNO : 7839
    ENAME : KING
    DEPTNO : 10
    SAL : 5000
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    DEPTNO : 10
    SAL : 1300
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from emp where deptno = 10');
    -- Columns --
    EMPNO - NUMBER
    ENAME - VARCHAR2
    JOB - VARCHAR2
    MGR - NUMBER
    HIREDATE - DATE
    SAL - NUMBER
    COMM - NUMBER
    DEPTNO - NUMBER
    Row: 1
    EMPNO : 7782
    ENAME : CLARK
    JOB : MANAGER
    MGR : 7839
    HIREDATE : 09/06/1981 00:00:00
    SAL : 2450
    COMM :
    DEPTNO : 10
    Row: 2
    EMPNO : 7839
    ENAME : KING
    JOB : PRESIDENT
    MGR :
    HIREDATE : 17/11/1981 00:00:00
    SAL : 5000
    COMM :
    DEPTNO : 10
    Row: 3
    EMPNO : 7934
    ENAME : MILLER
    JOB : CLERK
    MGR : 7782
    HIREDATE : 23/01/1982 00:00:00
    SAL : 1300
    COMM :
    DEPTNO : 10
    PL/SQL procedure successfully completed.
    SQL> exec run_query('select * from dept where deptno = 10');
    -- Columns --
    DEPTNO - NUMBER
    DNAME - VARCHAR2
    LOC - VARCHAR2
    Row: 1
    DEPTNO : 10
    DNAME : ACCOUNTING
    LOC : NEW YORK
    PL/SQL procedure successfully completed.
    SQL>

  • Exporting SQL Select statement to spreadsheet

    Hi all, basic question that I couldn't find the answer to while googling and searching the Oracle documentation.
    What is the code for exporting the result of a SQL Select statement to a spreadsheet such as Excel or Calc? In Oracle SQL Developer I tried saving the output as an XML file but it did not come out properly and I tried using EXPORT at the end of the statement but it gave an error message and I am not sure if this is the right command or what the syntax is. Thanks.

    Here's an example of one way to create CSV files that most spreadsheet type applications are able to read...
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.
    There are other methods for specifically creating Excel workbooks with multiple sheets etc. and details can be found in the SQL and PL/SQL FAQ at the top of the forum:
    {message:id=9360007}

  • Javascript and sql select statement

    I am working in html db in the 10 g environment. I'm trying to create an "auto suggestion function" that predicts values as the user enters characters into a text field. I've gotten it to work by hard coding the values in the function, ie: states. btw: there are several external javascript files at work here.
    What I want is to create a dynamic link to the database to gather, say, all names of providers at the time the page is built to use in the auto suggest format. I want to put this into a javascript routine and I'm having problems finding out how to mix the sql select statement into the javascript function.
    For the states example, I'm using:
    function StateSuggestions() {
    this.states = [
    "Alabama", "Alaska", "Arizona", "Arkansas",
    "California", "Colorado", "Connecticut",..."Wyoming" ];
    Can I substitute the hard coded data (states) with a sql select statement such
    as:
    select name from <dbtable> ???
    How does this need to be "wrapped" or containerized?
    Thank you. You have a great product in html db and your site is very useful. I appreciate everything you have done to assist us. Again, thank you.

    Hi,
    You can use TRUNC with 2 arguments to get the first DATE in a month, year, quarter, week, hour, minute, ISO year, ...
    SELECT  TRUNC ( ADD_MONTHS ( SYSDATE
                               , 12
                  , 'MONTH'
                  )     AS first_of_month
    FROM    dual
    ;The DATE returned will be in the same month, year, quearter, ... as the first argument.
    \We convered the last day of the month in [your previous question|http://forums.oracle.com/forums/message.jspa?messageID=3942939#3942939].
    At that time, I warded about using LAST_DAY as a cutoff point; TRUNC is a much better way.
    For example, to find all appointment_dates in the current month next year:
    SELECT  *
    FROM    appointments
    WHERE   appointment_date >= TRUNC (ADD_MONTHS (SYSDATE, 12), 'MONTH')
    AND     appointment_date <  TRUNC (ADD_MONTHS (SYSDATE, 13), 'MONTH')Note that
    the first part of the WHERE clause calls for dates on or equal to the beginning of the 12th month in the future, but
    the second part of the WHERE clause calls for dates before, not equal to , the beginning of the 13th month in the future.

  • I replaced the original hdd in my early 2008 iMac.  I can't move my files that were backed up with Time Machine to my new hdd using Migration Assistant.  When prompted to select the "from drive", the ext. hhd does not appears as a selection. Please help!!

    I replaced the original hdd in my early 2008 iMac.  I can't move my files that were backed up with Time Machine to my new hdd using Migration Assistant.  When prompted to select the "from drive", the ext. hhd does not appears as a selection. Please help!!

    I'd recommend staring over, Pondini has created an excellent guide on how to use Setup Assistant. I'd recommend begin reading Pondini Setup Assistant tips where he talks about "Second Chance." Assuming your Time Machine backup is sound the restore  should be very smooth.
    Roger

  • I don't have credit card for creAting my apple ID. There is no NONE option also to select . Please help

    I don't have credit card for creAting my apple ID. There is no NONE option also to select . Please help...

    Did you or your friend follow, exactly, the instructions on the page that FoxFifth linked to when creating a new account ? I've just tried it on my computer's iTunes and the instructions still work, I get the 'none' option on a new account

  • SQL SELECT statement Parent_child table and its related table..... HELP plz

    I have 2 tables
    Table Parent_child_table:
    ID | Parent_id | Name
    1 | NULL | Kitchen
    2 | 1 | Freezer
    3 | NULL | Garden
    4 | 3 | Grass
    Table Products:
    ID | parent_child_table_ID | Price | Comment
    1 | 2 | 111 | aaaa
    2 | 4 | 12 | vv
    I want to select Name from parent table where selected child ID are in PRODUCT table.....
    The result would like:
    |NAME|
    |Kitchen
    |Garden
    Can someone help with this SQL SELECT ?

    Raivis wrote:
    I have 2 tables
    Table Parent_child_table:
    ID | Parent_id | Name
    1 | NULL | Kitchen
    2 | 1 | Freezer
    3 | NULL | Garden
    4 | 3 | Grass
    Table Products:
    ID | parent_child_table_ID | Price | Comment
    1 | 2 | 111 | aaaa
    2 | 4 | 12 | vv
    I want to select Name from parent table where selected child ID are in PRODUCT table.....
    The result would like:
    |NAME|
    |Kitchen
    |Garden
    Can someone help with this SQL SELECT ?A guess
    select
       p.name
    from Parent_child_table p
    where p.parent_id is null
    and exists
    select
       null
    from Parent_child_table p1, products p2
    where p1.id = p2. parent_child_table_id
    and p1.parent_id = p.id
    )The reason it's a guess is because you've really done nothing to outline WHY you should get the results you say you would like. The more time you spend creating a clear question, the less time you'll have to spend weeding through useless answers.
    Cheers,

  • SQL select statements

    Hey everyone,
    First of all, yes, I have been looking through the 8.5 database schema guide.  As I have been reviewing the schema, I have been developing some ideas as to how to collect the desired data.  However, if anyone has already developed or found the SQL statements (which I'm sure someone already has) it would help me by minimizing buggs in my data collection program.
    All of these statistics need to be grouped by CSQ and selected for a certain time range (<start time> and <stop time>).  I.e. 1 hour increments.  I have no problem getting a list of results and then performing calulations to get the desired end result.  Also, if I need to perform multiple select statements to essentialy join two tables, please include both statements.  Finally, I saw the RtCSQsSummary table, but I have to collect data for the past, not at that given time.
    1. Total calls presented per CSQ
    2. Total calls answered per CSQ
    3. Total calls abandoned per CSQ
    4. Percentage of calls abandoned per CSQ  (if this is not stored in the database, I'm thinking: <calls abandonded>/<calls presented>)
    5. Average abandon time in seconds (if this is not stored in the db, I'm thinking: sum(<abandon time>)/<calls abandonded>)
    6. Service Level - % calls answered in 90 seonds by a skill-set (I saw metServiceLevel in table ContactQueueDetail; however, I would have to find how to configure this threshold for the application)
    7. Average speed of answer per CSQ
    8. Average call talk time per CSQ
    9. Aggregate logged in time of CSQ resources/agents
    10. Aggregate ready time of CSQ resources/agents
    I realize that some of these should be easy to find (as I am still digging through the db schema guide), but I was reading how a new record is created for every call leg so I could easily see how I could get inaccurate information without properly developed select statements.
    Any help will be greatly appreciated.
    Brendan

    Hi,
    kindly use the below link
    http://www.cisco.com/en/US/docs/voice_ip_comm/cust_contact/contact_center/crs/express_8_5/user/guide/uccx85dbschema.pdf
    it is the data base schema for UCCX 8.5.
    if you want to connect to DB. go to page 123. it shows you how to connect to DB. it is for UCCX 9 not 8.5 but it worths to try
    http://www.cisco.com/en/US/docs/voice_ip_comm/cust_contact/contact_center/crs/express_9_02/programming/guide/UCCX_BK_CFD16E30_00_cisco-unified-contact-center-express.pdf
    HTH
    Anas
    please rate all helpful posts

  • How can I stop Crystal reports from locking tables in our SQL db?  PLEASE HELP!!!

    Post Author: kevans
    CA Forum: Data Connectivity and SQL
    I really need help with this and so far I've had no luck finding a solution on Crystal's knowledge base, forums our even outside of this site.
    I recently upgraded from crw8 to crw10 and of course after converting reports and placing them into production I now discovered that crw10 will place locks (blocking) on the SQL tables it is using.
    Is there a setting in crystal so I can turn this off?  Someone said I can use a statement like ... "with (nolock)"  but I can't seem to figure out the correct syntax to use, I'm not even sure if this works since I can't find info on it.  I desperately need help!!!
    Example - if this is my select statement how would I add the "nolock" to it?
    (DateTimeToDate (PDMTimeToDateTime ({call_req.open_date})) >= {?Starting Date}) AND   (DateTimeToDate (PDMTimeToDateTime ({call_req.open_date})) <= {?End Date}) AND    (if {?Select_Group} <> "ALL" then {ca_contact.last_name} = {?Select_Group}         else if {?Select_Group} = "ALL" then true) AND            {call_req.type} = {?Type}

    Post Author: sharonmtowler
    CA Forum: Data Connectivity and SQL
    no lock is used in the sql stored procedure. i believe you can look at your sql statement in the report and place the nolock(prior to the table name)
    the only problem with this is you may get dirty data. most sql developers dont recommend it especially with real time data.

  • SQL INSERT trouble- please help

    I'm having an trouble,to INSERT a record to my db.(MySQL)
    This is the condition.
    There is a form to validate the NicNo,which is input by the user.If it it exist, then the system displays an error msg. If it is not,display a new form to enter the candidate details.Then the user can save them to the db.These are working well.But,when I go to the mySQL console and check,the record is nicely saved except 2 fields.(civilStatus and eduQua).
    Did you know why? I check my prepared statement,I think it's OK.
    Here are the codes:
    The form which is used by the user to input NicNo.
    <%@ page session="false" %>
    <%@ page import="java.sql.*,java.util.*,javax.servlet.http.*" %>
    <form method="POST" action="EntInterProcess.jsp">
        <center>
            <div align="center">
        <center>
       <TABLE borderColor=burlywood cellSpacing=0 cellPadding=1
                width="256" borderColorLight=moccasin border=1>
          <tr>
            <td noWrap style="background-color: #DEB887" width="80"><B>NIC No</b></td>
            <td width="106">
            <input type="text" name="nicno" size="14" style="border:1px solid #0000FF;
    color: #FF0000; font-weight: bold"></td>
            <td width="56"><input type="submit" value="Select" name="B1"></td>
          </tr>
         </table>
           </center>
      </div>
    </form>The file called "EntInterProcess.jsp"
    <%@ page import="core.CandidateMgr" %>
    <jsp:useBean id="CandidateMgr" class="core.CandidateMgr" scope="session"/>
    <jsp:setProperty name="CandidateMgr" property="*"/>
    <%
    String nextPage ="MainForm.jsp";
    if(CandidateMgr.verifyNicNo()){
         nextPage="InterviewForm.jsp";
         }else{
         nextPage="ExitError.jsp";
    %><jsp:forward page="<%=nextPage%>"/>I didn't copy here the page called "InterviewForm.jsp",because it has many fields.If you want please tell me.So I copy here the CandidateMgr.java file, which is the javaBean.
    package core;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class CandidateMgr
       private String nicno;
       private String name
       private String address;
       private String civilStatus;
       private String tele;
       private String eduQua;
         // Constructor
         public CandidateMgr()
       * Returns the nicno.
       public String getNicno()
          return nicno;
       * Sets the nicno.
       public void setNicno(String nicno)
          this.nicno = nicno;
       * Returns the name.
       public String getName()
          return name;
       * Sets the name.
       public void setName(String name)
          this.name = name;
       * Returns the address.
       public String getAddress()
          return address;
       * Sets the address.
       public void setAddress(String address)
          this.address = address;
       * Returns the civilStatus.
       public String getCivil()
          return civilStatus;
       * Sets the civilStatus.
       public void setCivil(String civilStatus)
          this.civilStatus= civilStatus;
       * Returns the tele.
       public String getTele()
          return tele;
       * Sets the tele.
       public void setTele(String tele)
          this.tele= tele;
       * Returns the eduQua.
       public String getEdu()
          return eduQua;
       * Sets the eduQua.
       public void setEdu(String eduQua)
          this.eduQua= eduQua;
         public boolean verifyNicNo(){
              boolean nic_no_select_ok = false;
              String nic="xxxx";
              try{
                   String DRIVER = "com.mysql.jdbc.Driver";
                   java.sql.Connection conn;
                   String URL = "jdbc:mysql://localhost:3306/superfine";
                    //Open the database
                   Class.forName(DRIVER).newInstance();
                   Connection con=null;
                   PreparedStatement pstmt1 = null;
                   con = DriverManager.getConnection(URL);
                   String sql="SELECT * FROM Candidate where nicNo= ?";          
                   pstmt1 = con.prepareStatement(sql);
                   pstmt1.setString(1,nicno);
                   ResultSet rs1 = pstmt1.executeQuery();
                                while(rs1.next()){
                        nic=rs1.getString("nicNo");
                   if(nic=="xxxx")
                        nic_no_select_ok = true;
                   } else{
                        nic_no_select_ok = false;     
                   rs1.close();
                           pstmt1.close();
                   con.close();
                catch(ClassNotFoundException e1){
                   System.err.println(e1.getMessage());
                catch(SQLException e2){
                           System.err.println(e2.getMessage());
               catch (java.lang.InstantiationException e3) {
                    System.err.println(e3.getMessage());
              catch (java.lang.IllegalAccessException e4) {
                    System.err.println(e4.getMessage());
              catch (java.lang.NullPointerException e5){
                   System.err.println(e5.getMessage());
              return nic_no_select_ok;
         public boolean addInter(){
              boolean add_inter_ok = false;
              try{
                   String DRIVER = "com.mysql.jdbc.Driver";
                   java.sql.Connection conn;
                   String URL = "jdbc:mysql://localhost:3306/superfine";
                    //Open the database
                   Class.forName(DRIVER).newInstance();
                   Connection con=null;
                   PreparedStatement pstmt3=null;
                   con = DriverManager.getConnection(URL);
                   String sqle ="INSERT INTO Candidate VALUES(?,?,?,?,?,?)";
                   pstmt3 = con.prepareStatement(sqle);
                   //assign value for ???
                   pstmt3.setString(1, nicno);
                   pstmt3.setString(2, name);
                   pstmt3.setString(3, address);
                   pstmt3.setString(4, civilStatus);
                   pstmt3.setString(5, tele);
                   pstmt3.setString(6, eduQua);
                   if(pstmt3.executeUpdate()==1) add_inter_ok=true;
                   pstmt3.close();
                           con.close();
                catch(ClassNotFoundException e1){
                   System.err.println(e1.getMessage());
                catch(SQLException e2){
                           System.err.println(e2.getMessage());
               catch (java.lang.InstantiationException e3) {
                    System.err.println(e3.getMessage());
              catch (java.lang.IllegalAccessException e4) {
                    System.err.println(e4.getMessage());
              return add_inter_ok;
    }These are the codes which I use to do this task.I don't know what happend to that 2 fields(they save in the db as NULL).Is there a nice method to do this database declaration? I try to declare that part as
    a seperate class,but I don't know how to code that by using java and call it to other sections for reuse.
    Anyone can answer these questions,please tell me how to do this,because it's urgent.
    Thanks.

    Hi Casabianca,
    Your code looks okay. I have just a couple of questions:
    (1) Are you 100% certain that those columns are of type VARCHAR/String in your MySQL database?
    (2) You only have a default ctor for your core.CandidateMgr class, and it has no implementation at all. That means that the six private member Strings are all set to null.
    Your addInter() method inserts the current values of the private data members into MySQL. If it so happened that those two fields, civilStatus and eduQua, were never initialized using calls to their respective setters, then their values would still be null because you never set them to sensible values inside the constructor.
    I'd do two things:
    (1) Add code to your default constructor to set all the strings to the empty string.
    (2) Write a second constructor that allows a user to initialize all six strings when the object is created. That way you can have a fully-initialized instance of CandidateMgr without having to call the setters. Have your default ctor simply call this second ctor:
    public CandidateMgr()
        this("", "", "", "", "", "");
    public CandidateMgr(final String nicno, final String name, final String address, final String civilStatus, final String tele, final String eduQua)
      this.nicno = nicno;  
      this.name  = name;
      this.address = address;  
      this.civilStatus = civilStatus;  
      this.tele = tele;  
      this.eduQua = eduQua;
    }Always write a constructor so the object is ready for use right away.
    See if that fixes your problem. The JDBC code looks okay.

  • How to make a procedure from a select statement please.....

    Dear All,
    i am new to oracle db, but i do have nice knowledge on sql in sql server, could you please help me.,,,,, in the below issue
    i do have below query in oracle db just joining two views,
    select docview.firstname as "First Name", docview.lastname as "Last Name", docview.mrn as "MRN", docview.physician as "Physician", docview.surgicalcong "Surgical Consent Missing", docview.admissionnotemissing "Admin Assessment Missing",
    (case (docview.doctype) when 135 then 'Doctor Chart Checklist' else 'DS Chart Checklist' end) as doctypename,
    docview.hpmissing "History & Physical Missing", docview.nursingassessment "Nursing Admission/Assessment", docview.anesthesiologymissing "Anesthe Consultation Missing", docview.medicalevalmissing "Medical Evaluation Missing", docview.Doctorlabresultmissing "Doctor Lab Results Missing", docview.outsidelabresultmissing "Outside Lab Results Missing", docview.chestxraymissing "Chest X-Ray Missing",
    docview.ekgmissing "Ekg Missing", docview.cardioechomissing "Cardio Echo Missing",docview.stresstestmissing "Stress Test Missing", docview.pulmonaryfunctionmissing "Pulmonary Function Missing"
    from DoctorMainView docview inner join DoctoSurgicalView surgicalView on docview.accountid= surgicalView.accountid and docview.mrn= surgicalView.mrn and docview.physician = surgicalView.physician
    and docview.lastname=surgicalView.lastname
    where docview.doctype in (23,61)
    Order by docview.firstname
    how can i make a procedure with below two steps,
    1) load the result of above query to some temp table / or even a fixed table (which ever easier)
    2) list all data from the temp table / fixed table created in first step
    so in the final expecting result is
    execute myprocnamehere -- will result same as running above query
    please help me
    thanks a ton in advance
    i greatful to you all
    Best Regards
    Buzzi

    Why would you want to extract all of the results from the database and write them to a table just so you could read them back out again? Wouldn't it be simpler just to return the results in one shot?
    In general the procedure and call would look something like this:
    SQL> create or replace procedure myprocnamehere
      2     ( p_results out sys_refcursor )
      3  as
      4  begin
      5     open p_results for
      6        select 'Results here' as results from dual;
      7  end;
      8  /
    Procedure created.
    SQL> var myresultset refcursor
    SQL>
    SQL> call myprocnamehere(:myresultset);
    Call completed.
    SQL> print :myresultset
    RESULTS
    Results here
    1 row selected.Edited by: William Robertson on Feb 8, 2011 7:13 PM

Maybe you are looking for

  • DVI to VGA adapter... Which one?

    Hey all, Currently I'm using an "oldish" VGA monitor with my Power Mac G5, which does me fine. Just recently, my neighbour gave me his old VGA monitor that he doesn't use anymore, so I thought I could take advantage and try out a dual display setup..

  • HP LJ1006 wont print on RDP 2012

    Dear All,      We have a a NEW Terminal server in MS Azure Running Server 2012 R2 and the client is Windows 8.1 (Fully updated). The client has a HP LJ1006 attached to it through USB cable and we would like to redirect athe printing on the applicatio

  • Breakpoints not breaking

    I have a JavaFX project running in the mobile emulator through NetBeans 6.5. Several of the classes used are Java classes being called from the Main.fx. When I set a breakpoint in Main.fx it always triggers, but if I set it anywhere in any of my Java

  • Opening a link in a new tab brings opens to a page of Chinese writing

    I have had several web sites today that have re-routed me to a page filled with Chinese. The location bar shows the correct destination, but it brings up chinese on an otherwise blank page. The page I selected to view was at this URL: http://www.expo

  • WLS 7.0 Premium or Advantage

    We're doubting whether we need the WLS Premium edition or the Advantage           edition:           We don't need failover, so am I right to suppose that there are hw/sw load           balancers that can load balance between several instances of the