Results 1 to 4 of 4

Thread: SQL error

  1. #1
    Join Date
    Dec 2003
    Posts
    3

    Question Unanswered: SQL error

    Hello All I am new to Oracle and SQl I have been trying to create the following view for a script and keep getting amissing expression error.
    Here is my script and the error any suggestions?
    Thanks to all in advance


    CREATE VIEW BRANCH_REPORT(BRANCH_NUM,TITLE,PUBL_NAME,PRICE,UOH ) AS
    SELECT N.BRANCH_NUM, P.PUBLisher_CODE||'-'||RTRIM(P.PUBLisher_NAME),||' '||RTRIM(B.Book_PRICE),
    ||RTRIM(I.Units_on_Hand),
    FROM BRANCH N, PUBLISHER P, INVENT I, BOOK B
    WHERE N.BRANCH_NUM = I.BRANCH_NUM
    and P.publisher_code = B.publisher_code
    and I.Book_code = b.book_code;
    T N.BRANCH_NUM, P.PUBLisher_CODE||'-'||RTRIM(P.PUBLisher_NAME),||' '||RTRIM(B.Book_PRICE),||' '
    *
    at line 2:
    0936: missing expression

  2. #2
    Join Date
    Dec 2003
    Posts
    18

    Re: SQL error

    Hi,

    In your query have 4mistake:-
    1. don't use || in start of any column name like '||RTRIM(I.Units_on_Hand)' and ||' '||RTRIM(B.Book_PRICE)

    2. After last column remove the sign of ,
    3 Number of column in after view name and number of column in select statment are not match means 4 vs 3.

    The correct query is :-
    CREATE VIEW BRANCH_REPORT(BRANCH_NUM,TITLE,PUBL_NAME,PRICE
    ) AS
    SELECT N.BRANCH_NUM,
    P.PUBLisher_CODE||'-'||RTRIM(P.PUBLisher_NAME),
    RTRIM(B.Book_PRICE),
    RTRIM(I.Units_on_Hand)
    FROM BRANCH N, PUBLISHER P, INVENT I, BOOK B
    WHERE N.BRANCH_NUM = I.BRANCH_NUM
    and P.publisher_code = B.publisher_code
    and I.Book_code = b.book_code;






    Originally posted by bllaker80
    Hello All I am new to Oracle and SQl I have been trying to create the following view for a script and keep getting amissing expression error.
    Here is my script and the error any suggestions?
    Thanks to all in advance


    CREATE VIEW BRANCH_REPORT(BRANCH_NUM,TITLE,PUBL_NAME,PRICE,UOH ) AS
    SELECT N.BRANCH_NUM, P.PUBLisher_CODE||'-'||RTRIM(P.PUBLisher_NAME),||' '||RTRIM(B.Book_PRICE),
    ||RTRIM(I.Units_on_Hand),
    FROM BRANCH N, PUBLISHER P, INVENT I, BOOK B
    WHERE N.BRANCH_NUM = I.BRANCH_NUM
    and P.publisher_code = B.publisher_code
    and I.Book_code = b.book_code;
    T N.BRANCH_NUM, P.PUBLisher_CODE||'-'||RTRIM(P.PUBLisher_NAME),||' '||RTRIM(B.Book_PRICE),||' '
    *
    at line 2:
    0936: missing expression

  3. #3
    Join Date
    Apr 2003
    Location
    Minneapolis, MN
    Posts
    273

    Re: SQL error

    Originally posted by bllaker80

    AS
    SELECT N.BRANCH_NUM, P.PUBLisher_CODE||'-'||RTRIM(P.PUBLisher_NAME),||' '||RTRIM(B.Book_PRICE),
    ||RTRIM(I.Units_on_Hand),
    FROM
    (1) the First apparent problem with the number of columns. you have defines 5 columns in the view and as you are selecting 4 columns.
    then ther are some concatinating errors as you can resove it

    (2) remove , (coma) before FORM Clause.
    Bhavin

    MS Computer Science
    OCP DBA 9i/8i

  4. #4
    Join Date
    Dec 2003
    Posts
    3

    Re: SQL error

    Thanks much, I have been trying for days to get this correct, the book I've been following has the contactenion all over the place. I should have realized especially when i only wanted it in one place.
    Thanks again


    Originally posted by rishikant_tiwar
    Hi,

    In your query have 4mistake:-
    1. don't use || in start of any column name like '||RTRIM(I.Units_on_Hand)' and ||' '||RTRIM(B.Book_PRICE)

    2. After last column remove the sign of ,
    3 Number of column in after view name and number of column in select statment are not match means 4 vs 3.

    The correct query is :-
    CREATE VIEW BRANCH_REPORT(BRANCH_NUM,TITLE,PUBL_NAME,PRICE
    ) AS
    SELECT N.BRANCH_NUM,
    P.PUBLisher_CODE||'-'||RTRIM(P.PUBLisher_NAME),
    RTRIM(B.Book_PRICE),
    RTRIM(I.Units_on_Hand)
    FROM BRANCH N, PUBLISHER P, INVENT I, BOOK B
    WHERE N.BRANCH_NUM = I.BRANCH_NUM
    and P.publisher_code = B.publisher_code
    and I.Book_code = b.book_code;

Posting Permissions

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