Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Including variable in query using owa_util.listprint function

NewApexCoderOct 23 2017 — edited Oct 24 2017

I am working in an ORACLE package. I have a procedure that displays options for a user to select. The option is a simple drop down (select) list. I am using the OWA_UTIL.LISTPRINT function. I am trying to include a variable in the "WHERE" clause of the query, but I keep getting the "variable not recognized" error or the "Encountered the symbol '$%^' " symbol. I know its soemthing simple. Just a matter of syntax but I haven't figured it out. Code is below:

htp.bodyOpen ;
  htp
.centeropen;
  htp
.formopen (curl => twbkwbis.f_cgibin || 'sykcrrp.p_display_report',
  cmethod
=> 'POST');
  htp
.tableopen;
  htp
.br;
  htp
.tableRowOpen;
  htp
.tableData ( 'Select Class Year: ',
  cattributes
=> 'style="text-align:right;"' );
  twbkfrmt
.P_TableDataOpen ( cattributes => 'style="text-align:left;"' );  
  OWA_UTIL
.LISTPRINT ( p_theQuery => 'SELECT distinct class_description, class_code||'' - ''||class_description, null'
  
||' FROM ROSTER_TABLE'
  
||' WHERE EXISTS (SELECT ''x'''
  
||' FROM ROLE_TABLE'
  
||' WHERE Role_pidm = ||'v_id'||'''

  
||' AND Role_role = ''ROSTER_''||program)'
  
||' order by 1',
  p_cname
=> 'p_class_year',
  p_nsize
=> 7,
  p_multiple
=> TRUE );  
  twbkfrmt
.P_TableDataClose;
  htp
.tableRowClose;  
  htp
.tableClose;

  htp
.bodyClose;
  htp
.br;
htp
.htmlclose;

EXCEPTION
WHEN OTHERS THEN
htp
.print(SQLERRM);
END;

In my code, my variable is v_id. I am passing this in. I know there is a value in there as I am able to output it to the screen as a number. Again, it looks like a syntax issue that I just haven't figured out yet. Having trouble concatenating it or using the apostrophes, or idk.

Any help on this would be great. Thanks in advance.

 

This post has been answered by padders on Oct 24 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 21 2017
Added on Oct 23 2017
6 comments
566 views