Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2009
    Posts
    8

    Question Unanswered: Stored Procedure dynamic query

    Hi,

    When building a dynamic query and concatenating a string with an integer data type parameter it fails when deploying the SP.

    CREATE PROCEDURE CLI_DATA_SQL
    ( IN P_ACCNUM INTEGER)

    DECLARE V_SQL VARCHAR(2000);
    SET V_SQL = ' WHERE CS.DOCSTATUS = 1 AND CS.ACCNUM > ' || P_ACCNUM

    This statement with a string data type works fine.
    SET V_SQL = ' WHERE CS.DOCSTATUS = 1 AND CS.TRADENAME LIKE '''|| P_CMPNAME ||'%''';

    The issue is how to connect my statement with a integer data type parameter?

    Thanks in advance

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Take a look at the CAST operator.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Jul 2009
    Posts
    8
    Hi Nick,

    Works very well....

    Thanks :-)

Posting Permissions

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