Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9254453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:28:22+00:00 2026-06-18T11:28:22+00:00

Hey I am trying to write a procedure in which the user can insert

  • 0

Hey I am trying to write a procedure in which the user can insert which columns he would like to get as parameter input. As of right now when I run a test script I get this error:

error -1 message error in ct_cu_act_medrecon_pg.spm_search_patientmedrecs =>ORA-00933: SQL command not properly ended

The error is refering to the order by part in the select statement, and when I remove that I get an error saying:

error -1 message error in ct_cu_act_medrecon_pg.spm_search_patientmedrecs =>ORA-00904: "D"."P_INSERTDT_IN": invalid identifier

Here is the spec:

procedure spm_search_patientmedrecs (
  p_columnsort_in  in varchar2, --which is sort column
  p_medmed_in      in varchar2, --first column
  p_planid_in      in varchar2, --second column
  p_detmed_in      in varchar2, --third column
  p_insertdt_in    in varchar2, --fourth column
  p_ascdesc_in     in varchar2, --asc or desc in order by
  p_return_cur_out out sys_refcursor,
  p_err_code_out   out number,
  p_err_mesg_out   out varchar2
);

Here is the procedure body:

procedure spm_search_patientmedrecs (
  p_columnsort_in  in varchar2,
  p_medmed_in      in varchar2,
  p_planid_in      in varchar2,
  p_detmed_in      in varchar2,
  p_insertdt_in    in varchar2,
  p_ascdesc_in     in varchar2,
  p_return_cur_out out sys_refcursor,
  p_err_code_out   out number,
  p_err_mesg_out   out varchar2)
is
  lv_sql           varchar2(32767);
begin
  lv_sql := '';
  lv_sql := 'select h.p_medmed_in,
                    h.p_planid_in,
                    d.p_detmed_in,
                    d.p_insertdt_in
             from membermedicalreconcilationhdr h,
                  membermedicalreconcilationdet d
             where h.membermedreconciliationhdrskey = 
                   d.membermedreconciliationhdrskey
             order by h.p_columnsort_in p_ascdesc_in';
    p_err_code_out := 0;
    OPEN p_return_cur_out FOR lv_sql;
exception
  when others then
    p_err_code_out := -1;
    p_err_mesg_out := 'error in ct_cu_act_medrecon_pg.spm_search_patientmedrecs =>'||sqlerrm;
end spm_search_patientmedrecs;

Here is my test script:

set serveroutput on
declare 
  type tempcursor is ref cursor;
  v_cur_result tempcursor;
  errcode number;
  errmesg varchar2(1000);
begin
  ct_cu_act_medrecon_pg.spm_search_patientmedrecs
    ('primarymemberplanid',
     'membermedreconciliationhdrskey',
     'primarymemberplanid',
     'membermedreconciliationdetskey',
     'inserteddt',
     'ASC',
     v_cur_result,
     errcode,
     errmesg
     );

--  dbms_output.put_line(v_cur_result);
  dbms_output.put_line('error '||errcode||' message '||errmesg);
end;

First off, I know how I’m handeling the error isnt the best way to do it but thats how the person asking me to do this wanted it.

Now I dont know if this is a possible thing to do in Oracle PL/SQL, but if it is I would greatly appreciate some help in pointing me in the right direction. If you guys need any more information feel free to ask and I will assist as best I can (Ive only been working with SQL and PL/SQL for 2 months). Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:28:24+00:00Added an answer on June 18, 2026 at 11:28 am

    Dynamic SQL means assembling strings which are executed as SQL statements. Your string hardcodes the parameter names, whereas what you actually need is the contents of the parameters.

    Something like this:

    lv_sql := 'select h.'||p_medmed_in||',
                        h.'||p_planid_in||',
                        d.'||p_detmed_in||',
                        d.'||p_insertdt_in||'
                 from membermedicalreconcilationhdr h,
                      membermedicalreconcilationdet d
                 where h.membermedreconciliationhdrskey = 
                       d.membermedreconciliationhdrskey
                 order by h.'||p_columnsort_in||' '|| p_ascdesc_in;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys I'm trying to write a simple socket program that basically send like
Hey all. I would like to get some insight on a question that I
Hey, I'm trying to write a loop which updates within a method at 1/60
Hey i'm just trying to write some code in DrScheme: ((function (x) (* x
Hey there. I'm trying to write a small program that will read the four
Hey I'm new to java servlets and I am trying to write one that
Hey all, I'm trying to write a sort function but am having trouble figuring
edited. Hey, I am trying to write an NSMutableArray to a plist. The compiler
Hey everyone i am trying to write this code and I am having problems
trying to initialize a string from a vector. I am supposed to get hey

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.