ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

where is SQLDATA

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

  • where is SQLDATA

    lets say i have built an sql statement...

    'select * from SRVACHI where ACI010 = '12' and ACI015 = '123
    and ACI085 = '123' order by ACI010, ACI015, ACI085'

    i then want to pull the very first row information out and examine it...

    I'm doing it as such, below... but I am getting a -822 sqlcode on the fetch...


    exec sql include sqlda;

    exec sql
    prepare s1_select from :g_sqlstmt

    exec sql
    exec sql describe s1_select into :sqlda using system names;

    exec sql
    declare c1 cursor for s1_select;

    exec sql
    open c1;

    exec sql
    fetch next from c1 using descriptor :sqlda;

    what am I missing?



    I intend to examine it as...

    for i = 1 to sql_num;

    sqlvar = sql_var(i);
    if sqlname = ' ';
    leave;
    endif;

    endfor;




    Last edited by jayvaughn; October 13, 2017, 01:14 PM.

  • #2
    SQLDATA is included by the pre-compiler - you don't include it. I'm not familiar with the describe step you have in your code nor with how you're trying to use SQLDA - I typically specify the variable name(s) that I'm fetching data into or a data structure with those fields.

    Comment


    • #3
      thanks - this is dynamic sql where that sql select statement was built without know the file or columns... so yes, you approach works when you know the file and columns you are working with at the time of programming.

      Comment


      • #4
        Interesting - at any rate to answer your question SQLDATA and what not are inserted as part of the spool file from the compile you will see them.

        Comment


        • #5
          Did you set SQL_NUM to the maximum values that could be received befofe including the SQLDA?
          Something like this:
          Code:
            Dcl-C SQL_NUM   Const(100);
            Exec SQL Include SQLDA;
          Birgitta

          Comment


          • #6
            Birgitta... to clarify my dilemma and clarify what I have, i just created a new post called dynamic sql - receive fetched row values into host variables - if you can take a look at that one, it will probably make more sense.

            Comment


            • #7
              Originally posted by jayvaughn View Post
              I'm doing it as such, below... but I am getting a -822 sqlcode on the fetch...
              Hard to tell. Is this all default SQLDA stuff? Or did you create it all? Is this the same program in the other posts? If you created it, we need to see all of the definitions.

              The title says "Where is SQLDATA". Does that mean 'where is the field named SQLDATA', or is it 'where is the data pointed to by SQLDATA'?
              Tom

              There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

              Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

              Comment


              • #8
                Tom. Yes. All of these post with similar topics regarding sqlda and descriptors are resolved. As you can tell there has been much confusion on my end in which I have finally got a grasp on.

                Comment

                Working...
                X