<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using SQL cursors in C program in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612856#M104409</link>
    <description>Steve,&lt;BR /&gt;it's not easy without database design help you. Statement seems to be right. May be a stupid question, but does exist some record with CompName and CompVer passed? Did you try direct sql command with console?&lt;BR /&gt; &lt;BR /&gt;Antonio Vigliotti&lt;BR /&gt;</description>
    <pubDate>Fri, 26 Aug 2005 11:42:45 GMT</pubDate>
    <dc:creator>Antoniov.</dc:creator>
    <dc:date>2005-08-26T11:42:45Z</dc:date>
    <item>
      <title>Using SQL cursors in C program</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612855#M104408</link>
      <description>Greetings everyone,&lt;BR /&gt;&lt;BR /&gt;I'm attempting to write some C applications to do basic queries of our ALLBASE/SQL database.  I have two programs that make use of cursors to obtain and display multiple row results.  On program works as expected while the other is unable to obtain a multiple row result set.  The main difference between the two are their SQL cursor declarations.&lt;BR /&gt;&lt;BR /&gt;Here's the "broken" one:&lt;BR /&gt;// SQL Cursor declarations&lt;BR /&gt;EXEC SQL DECLARE comp_ids_crs CURSOR FOR&lt;BR /&gt;    SELECT COMPONENT_ID FROM REL_COMP_DETAIL&lt;BR /&gt;    WHERE COMPONENT_NAME = :CompName&lt;BR /&gt;    AND COMP_VERSION = :CompVer;&lt;BR /&gt;&lt;BR /&gt;and the one that works:&lt;BR /&gt;// SQL Cursor declare&lt;BR /&gt;    EXEC SQL DECLARE dest_ids_crs CURSOR FOR&lt;BR /&gt;        SELECT DESTINATION_ID FROM COMP_DEST&lt;BR /&gt;        WHERE COMPONENT_ID = :ComponentID;&lt;BR /&gt;&lt;BR /&gt;Attached is the broken C source file.  I would attach the working one, but can only attach one file to a post by the looks of things.&lt;BR /&gt;&lt;BR /&gt;Any help would be greatly appreciated.&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Aug 2005 10:15:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612855#M104408</guid>
      <dc:creator>Steve Hosto</dc:creator>
      <dc:date>2005-08-26T10:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL cursors in C program</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612856#M104409</link>
      <description>Steve,&lt;BR /&gt;it's not easy without database design help you. Statement seems to be right. May be a stupid question, but does exist some record with CompName and CompVer passed? Did you try direct sql command with console?&lt;BR /&gt; &lt;BR /&gt;Antonio Vigliotti&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Aug 2005 11:42:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612856#M104409</guid>
      <dc:creator>Antoniov.</dc:creator>
      <dc:date>2005-08-26T11:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL cursors in C program</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612857#M104410</link>
      <description>Here's the table structure as defined in the create table command:&lt;BR /&gt;CREATE TABLE Rel_Comp_Detail (&lt;BR /&gt;       Component_ID         INTEGER NOT NULL,&lt;BR /&gt;       Component_Name       CHAR(20),&lt;BR /&gt;       Comp_Version         CHAR(5),&lt;BR /&gt;&lt;BR /&gt;When the broken SQL select statement is run via isql a multiple row result set is returned.</description>
      <pubDate>Fri, 26 Aug 2005 11:48:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612857#M104410</guid>
      <dc:creator>Steve Hosto</dc:creator>
      <dc:date>2005-08-26T11:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL cursors in C program</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612858#M104411</link>
      <description>I suspect the SQL is just fine, but the string manipulation is incorrect.&lt;BR /&gt;The query for 'ComponentID' is relatively easy because it is a simple integer.&lt;BR /&gt;&lt;BR /&gt;But the Name/Ver query can have trouble with fill characters and null terminators.&lt;BR /&gt;&lt;BR /&gt;I suggest you print those variables and their length just before the query and print them with some delimiter to make it clear where they end, much like how you print the result, but now before the query:&lt;BR /&gt;&lt;BR /&gt;printf("CompName = '%s' %d\n", CompName, strlen(CompName));&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 26 Aug 2005 12:39:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612858#M104411</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-08-26T12:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using SQL cursors in C program</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612859#M104412</link>
      <description>Thanks a bunch.&lt;BR /&gt;&lt;BR /&gt;I thought that might be the problem too, but our C "experts" disagreed with me.&lt;BR /&gt;&lt;BR /&gt;I ended up hard coding in the lenth of the strncat() call to populate CompName.  I had previously been using sizeof() instead of strlen() to determine the length of the strncat() call.&lt;BR /&gt;&lt;BR /&gt;$ ./getCompIDs.r -v GR423A30&lt;BR /&gt;RawInput = 'GR423A30' and is 8 bytes long&lt;BR /&gt;CompName = 'GR423' and is 5 bytes long&lt;BR /&gt;CompVer = 'A30' and is 3 bytes long&lt;BR /&gt;GR423A30 - 26888&lt;BR /&gt;GR423A30 - 26889&lt;BR /&gt;GR423A30 - 26897&lt;BR /&gt;&lt;OUTPUT truncated=""&gt;&lt;BR /&gt;&lt;BR /&gt;Updated C source file attached.&lt;/OUTPUT&gt;</description>
      <pubDate>Fri, 26 Aug 2005 13:04:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-sql-cursors-in-c-program/m-p/3612859#M104412</guid>
      <dc:creator>Steve Hosto</dc:creator>
      <dc:date>2005-08-26T13:04:38Z</dc:date>
    </item>
  </channel>
</rss>

