ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Sqlcode +326

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sqlcode +326

    I am getting this code (326 "Too many host variables have been specified on SELECT INTO or FETCH." ) when I run my SQL:

    a63007fads e ds extname(a63007fa)

    declare facursor cursor for select * from a63007fa

    fetch facursor into :a63007fads


    a63007fa has 16 fields.

    Any ideas would be appreciated. TIA

  • #2
    Re: Sqlcode +326

    Birgitta will correct me if I'm wrong... I'm sure...

    But, I don't think you can do the "Select *" into a DS. I think you have to detail the fields you're bringing back from the Select statement.

    Select F1, F2 F3, F4 from FileName

    Comment


    • #3
      Re: Sqlcode +326

      Originally posted by FaStOnE View Post
      Birgitta will correct me if I'm wrong... I'm sure...

      But, I don't think you can do the "Select *" into a DS. I think you have to detail the fields you're bringing back from the Select statement.

      Select F1, F2 F3, F4 from FileName
      I generally do the select into DS without issue - but perhaps I tried it one too many times :-)

      Comment


      • #4
        Re: Sqlcode +326

        Fetching into an Datastructure is possible.

        How did you define your datastructure?
        As External DS or did you list all columns?
        If it's an external DS, did you really specify the correct file or did you simply copy anything else?
        If you list all columns did you forget one?

        BTW for performance issues SELECT * is never a good solution, always list the columns you really need.

        Birgitta

        Comment


        • #5
          Re: Sqlcode +326

          External DS file name. There are 16 fields and I need all of them -

          Comment


          • #6
            Re: Sqlcode +326

            Very weird. I ran a test to be sure against a file having 17 fields and it worked like a charm.

            Just a strike in the dark. Are there null fields in your file ?
            Philippe

            Comment


            • #7
              Re: Sqlcode +326

              Originally posted by Mercury View Post
              Very weird. I ran a test to be sure against a file having 17 fields and it worked like a charm.

              Just a strike in the dark. Are there null fields in your file ?
              I listed the 16 fields instead of the select *, I changed the DS from external file name to the fields and still get the +326 code. I passed the file (only has 11 records) and there are no null values. This has me stumped.

              Comment


              • #8
                Re: Sqlcode +326

                Your code is good.
                compile again (verify you don't have any OVRDBF), and looks at the compilation list to see your DS and the fields of the file, because this seems to me impossible !
                Patrick

                Comment


                • #9
                  Re: Sqlcode +326

                  You say only 11 records ? Hmm... Can you pls zip the file data together with the file description here. I am curious and would like to run a test using those data on the V5R3 system I am using.

                  BTW what version are you running on your i ?
                  Philippe

                  Comment


                  • #10
                    Re: Sqlcode +326

                    Yet an other idea! Is the library list at compile time the same as at run time?
                    May be your file is in different libraries with a different number of columns.

                    Birgitta

                    Comment


                    • #11
                      Re: Sqlcode +326

                      Originally posted by B.Hauser View Post
                      Yet an other idea! Is the library list at compile time the same as at run time?
                      May be your file is in different libraries with a different number of columns.

                      Birgitta
                      No, but thanks for the try - file is located in one library only and it's at the top of my library list. Not in qtemp either. Running the program interactively after the compile. Using Debug at the dow statement and checking the value of SQLCOD. I have a number of other subroutines in the program using SQL over other files with no issue.

                      Comment


                      • #12
                        Re: Sqlcode +326

                        Look your compilation list please !
                        Patrick

                        Comment


                        • #13
                          Re: Sqlcode +326

                          That's what it was ... Birgitta told me not to do the "Select *" and I took that as Gospel.

                          Whatever she says is good enough for me!

                          Comment


                          • #14
                            Re: Sqlcode +326

                            Originally posted by K2r400 View Post
                            Your code is good.
                            compile again (verify you don't have any OVRDBF), and looks at the compilation list to see your DS and the fields of the file, because this seems to me impossible !
                            this seems to be the missing ingredient here. if you can post the DDS for the PF and the compile listing. there has to be a mismatch somewhere.
                            I'm not anti-social, I just don't like people -Tommy Holden

                            Comment


                            • #15
                              Re: Sqlcode +326

                              Your DS has more subfields than the fields returned by the query.

                              Check your D specs to see if any "other" field is inadvertently defined into your DS.
                              â??No bird soars too high if he soars with his own wingsâ?? â?? William Blake

                              Comment

                              Working...
                              X