Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2010
    Posts
    13

    Unanswered: Issue with SQL Command not properly ended

    I'm experiencing an issue with this section of the below code.

    Code:
    CREATE OR REPLACE PROCEDURE "PK_TRAINING_LIVE"."GENERATEPROVIDERIDS"
    (alias_name IN varchar,
      auth_name IN varchar )
    
    IS
    alias_code number := 0;
    rndNum varchar(50);
    crte_by_val varchar2(30) := 'SQLSCRIPT';
    updt_by_val varchar2(30) := 'SQLSCRIPT';
    validPersId number;
    
    BEGIN
    select cd_cd into alias_code
        from m_code where cd_abbr = alias_name
        and cd_set_cd = (select cd_set_cd from m_code_set where cd_set_abbr = 'PERS_ALS_TYP_CD'));
    
    ...
    
    END
    PL/SQL: ORA-00933: SQL command not properly ended

    select cd_cd into alias_code
    from m_code where cd_abbr = alias_name
    and cd_set_cd = (select cd_set_cd from m_code_set where cd_set_abbr = 'PERS_ALS_TYP_CD'));

    I'm getting an ORA-00933 error...

    If I change the query to this it works fine:

    select cd_cd into alias_code
    from m_code where cd_abbr = alias_name
    and cd_set_cd = 123;

    Can I not use a subquery inside of a query when assigning to a variable?

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >Can I not use a subquery inside of a query when assigning to a variable?
    It is valid when done correctly (returning only ONE row)


    >and cd_set_cd = (select cd_set_cd from m_code_set where cd_set_abbr = 'PERS_ALS_TYP_CD'));
    why only 1 "(" but 2 "))"?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Aug 2010
    Posts
    13
    select cd_set_cd from m_code_set where cd_set_abbr = 'PERS_ALS_TYP_CD'

    returns 1 row

  4. #4
    Join Date
    Aug 2010
    Posts
    13
    Wow I'm dumb, it was the last ')' in there

  5. #5
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >returns 1 row
    returns 1 row NOW but in future it may return more than 1 & then error gets thrown.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  6. #6
    Join Date
    Aug 2010
    Posts
    13
    It won't because the cd_set_Abbr is unique so it'll always only return 1

Posting Permissions

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