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 137865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:10:25+00:00 2026-05-11T07:10:25+00:00

The stored procedures being written here currently concats the parameters to the queries: SELECT

  • 0

The stored procedures being written here currently concats the parameters to the queries:

   SELECT *       FROM Names      WHERE Name = ' || prmName || '   ORDER BY ' || prmSortField 

Is it possible to parameterize this query inside the stored procedure? Possibly like:

query = 'select * From Names Where Name = @name Order By ' || prmSortField call(query, prmName) 

Note:
In case you wonder why we do so, there are two common parameters for our sp’s: sortFieldIndex and sortDirection. Since we cannot directly parameterize these, the query is dynamically generated. But other parameters make the queries open for injection. So I am looking a way to parameterize some of the parameters.

  • 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. 2026-05-11T07:10:25+00:00Added an answer on May 11, 2026 at 7:10 am

    Absolutely. Use cursors.

    DECLARE   CURSOR c1 (job VARCHAR2, max_wage NUMBER) IS     SELECT * FROM employees WHERE job_id = job AND salary > max_wage; BEGIN   FOR person IN c1('CLERK', 3000)   LOOP      -- process data record     DBMS_OUTPUT.PUT_LINE('Name = ' || person.last_name || ', salary = ' ||                          person.salary || ', Job Id = ' || person.job_id );   END LOOP; END; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the query that is being executed on SQL Server 2008: SELECT "dbo"."tblMainData"."recID" FROM
I have a somewhat-long-running stored procedure being called from a PB application. I want
I have group of stored procedures with names like 'somename_%'. Are there any way
I currently have a main stored procedure calling many stored procedures: Main --| --|
I am trying to capture error messages in my Java code from stored procedures
I have 2 stored procedures ( sp1 and sp2 ) in SQL Server 2005
I have two stored procedures I wish to use in my stored procedure, but
We have lots of stored procedures which all contain a lot of comments. Is
I am building CLR Stored Procedures and UDFs as discussed in this article: http://www.codeproject.com/KB/cs/CLR_Stored_Procedure.aspx
i am writing stored procedures in MySQL that return values; CREATE PROCEDURE getCustomerById (id

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.