Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2014
    Posts
    294

    Unanswered: Multiple values on a select statement

    Hi

    I have a basic question. As I am a beginner with this I can't find exactly how to figure this out.

    I am trying to use Prepare & execute in a stored procedure.
    Written some thing like this

    SET STN1 = ('set ? =(SELECT NAME,PLACE,ORIGIN FROM' || P_TABLE ||' WHERE ID = '|| VALUE') );
    PREPARE S1 FROM STN1;
    EXECUTE S1 into V1;

    ON this above query it is returning multiple rows & multiple columns as I am passing all those values into a single variable.

    this is the error which i am getting.
    The number of values assigned is not the same as the number of specified or implied columns or variables.. SQLCODE=-117, SQLSTATE=42802

    can some one let me how to handle in this kind of scenario, as this is the first time for me to do with this.
    kindly excuse me, if I am wrong.

    Thanks

  2. #2
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    I see you know how to concatenate. Have you ever considered concatenating the columns you want into a single column?
    Dave

  3. #3
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    if you mean : the select returns multi-rows : cursor has to be declared ( see infocenter)
    fetch into var1, var2..... reading in these rows
    samples are provided in sample directory
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

Tags for this Thread

Posting Permissions

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