Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2003
    Posts
    10

    Arrow Unanswered: How can a sql statement be parsed in Java?

    I have a sql statement which Can execute in Sql*plus and Java
    but, although I can execute the statement in Java
    when I call the method:
    resultSet.next()
    it throw sqlException and said: no statement parse...

    I want to ask how a statement can be parsed?
    is that it should NOT end with ';' in Java
    (In sql*plus, we end a statement with ';')

    and here is my sql which I execute in Java:
    -------------------------------------------------
    CREATE OR REPLACE FUNCTION d(a NUMBER, b NUMBER)
    RETURN NUMBER AS
    x NUMBER;
    BEGIN
    IF b<>0 THEN
    x := a / b;
    RETURN x;
    ELSE
    x := NULL;
    RETURN x;
    END IF;
    END;
    /
    VARIABLE visitor1 NUMBER;
    VARIABLE buyer1 NUMBER;
    VARIABLE visitor2 NUMBER;
    VARIABLE buyer2 NUMBER;
    DECLARE
    V1 NUMBER;
    B1 NUMBER;
    V2 NUMBER;
    B2 NUMBER;
    BEGIN
    SELECT COUNT(*) INTO V1
    FROM (SELECT
    userUin USER_1
    FROM RPSUserProperty
    WHERE (value='Male')) User_t1,
    (SELECT
    DISTINCT userUin USER_UIN, itemUin ITEM_UIN1
    FROM ActionHistory10
    WHERE (actionTime > to_date('1999-01-01 00:00:00', 'YYYY/MM/DD HH24:MIS') AND
    actionTime < to_date('2004-01-01 00:00:00', 'YYYY/MM/DD HH24:MIS'))) User_t, (
    SELECT itemUIN ITEM_UIN FROM Item WHERE catUIN = '1') Item_t
    WHERE (User_t.ITEM_UIN1 = Item_t.ITEM_UIN) AND (User_t1.USER_1 = User_t.USER_UIN
    );
    :visitor1 :=V1;
    SELECT COUNT(*) INTO B1
    FROM (SELECT
    userUin USER_1
    FROM RPSUserProperty
    WHERE (value='Male')) User_t1,
    (SELECT
    DISTINCT userUin USER_UIN, itemUin ITEM_UIN1
    FROM ActionHistory16
    WHERE (actionTime > to_date('1999-01-01 00:00:00', 'YYYY/MM/DD HH24:MIS') AND
    actionTime < to_date('2004-01-01 00:00:00', 'YYYY/MM/DD HH24:MIS'))) User_t, (
    SELECT itemUIN ITEM_UIN FROM Item WHERE catUIN = '1') Item_t
    WHERE (User_t.ITEM_UIN1 = Item_t.ITEM_UIN) AND (User_t1.USER_1 = User_t.USER_UIN
    );
    :buyer1 :=B1;
    SELECT COUNT(*) INTO V2
    FROM (SELECT
    userUin USER_1
    FROM RPSUserProperty
    WHERE (value='Female')) User_t1,
    (SELECT
    DISTINCT userUin USER_UIN, itemUin ITEM_UIN1
    FROM ActionHistory10
    WHERE (actionTime > to_date('1999-01-01 00:00:00', 'YYYY/MM/DD HH24:MIS') AND
    actionTime < to_date('2004-01-01 00:00:00', 'YYYY/MM/DD HH24:MIS'))) User_t, (
    SELECT itemUIN ITEM_UIN FROM Item WHERE catUIN = '1') Item_t
    WHERE (User_t.ITEM_UIN1 = Item_t.ITEM_UIN) AND (User_t1.USER_1 = User_t.USER_UIN
    );
    :visitor2 :=V2;
    SELECT COUNT(*) INTO B2
    FROM (SELECT
    userUin USER_1
    FROM RPSUserProperty
    WHERE (value='Female')) User_t1,
    (SELECT
    DISTINCT userUin USER_UIN, itemUin ITEM_UIN1
    FROM ActionHistory16
    WHERE (actionTime > to_date('1999-01-01 00:00:00', 'YYYY/MM/DD HH24:MIS') AND
    actionTime < to_date('2004-01-01 00:00:00', 'YYYY/MM/DD HH24:MIS'))) User_t, (
    SELECT itemUIN ITEM_UIN FROM Item WHERE catUIN = '1') Item_t
    WHERE (User_t.ITEM_UIN1 = Item_t.ITEM_UIN) AND (User_t1.USER_1 = User_t.USER_UIN
    );
    :buyer2 :=B2;
    END;
    /
    SELECT d(:visitor1,:buyer1) Male, d(:visitor2,:buyer2) Female FROM DUAL
    ----------------------------------------------------

    Thank you.

  2. #2
    Join Date
    Apr 2003
    Posts
    10

    Question Re: How can a sql statement be parsed in Java?

    or Is it because I use the keyword "VARIABLE" which cannot read by Java ?

  3. #3
    Join Date
    Apr 2003
    Posts
    10

    Question Re: How can a sql statement be parsed in Java?

    [QUOTE][SIZE=1]Originally posted by idd0060
    I have a sql statement which Can execute in Sql*plus and Java
    or I cannot do the things(CREATE function and SELECT)
    in one statement in Java?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •