⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 blobs.html

📁 通用的数据库中间库
💻 HTML
📖 第 1 页 / 共 2 页
字号:
      <P>Next step is used to actually bind the content of 
      a file into input variable:<BR><STRONG>SAString sContent =                             
      SomeFunctionThatReadFileContent(&quot;blob.bin&quot;);<BR></STRONG>The above line 
      reads the whole content of a file.<BR><STRONG>cmd.Param(&quot;fblob&quot;).asBLob() = 
      sContent;<BR></STRONG>The above line binds parameter 
            <EM>:fblob</EM>      with value of file 
      content previously 
      read.</P>
      <P>All that we need now is to execute a 
      query:<BR><STRONG>cmd.Execute();</STRONG> 
      </P>
      <P>For using piecewise capabilities of SQLAPI++ for binding Long or Lob 
      types see <A href="../Examples/step5.cpp">example</A>.</P>
      
      <A name="Reading Long or Lob data"></A>
      <H4>Reading Long or Lob data</H4>
      <P>Suppose, we want to retrieve BLob field named 
            FBLOB from table named TEST where some other field named FKEY 
            (primary key) is equal to 'KEY' (Select FBLOB from TEST where FKEY =       
                  
            
      'KEY').  Field should be read into a file named 
      'blob.bin'.</P>
      <P>As usual, the first thing to do is to create the 
      objects:<BR><STRONG><FONT face="" size=2><FONT face=System><FONT size=+0>SACommand cmd(&amp;Connection, &quot;Select FBLOB from 
      TEST where FKEY = 
      'KEY' &quot;);</FONT></FONT></FONT></STRONG><FONT 
      size=+0><FONT face=System></FONT></FONT> 
      <BR>F<A name="Reading Long or Lob data">or more information see 
      </A><A 
      href="connect.html">Connecting to databases</A><A 
      name="Reading Long or Lob data">.</A>  
      </P>
      <P>Next thing to do is to execute a 
      query:<BR><STRONG>cmd.Execute();</STRONG>  
      </P>
      <P>Next step is used to actually fetch the row and 
      access BLob data:<BR><STRONG>if(cmd.FetchNext())&nbsp; // or 
      while(cmd.FetchNext())<BR>{<BR>&nbsp;&nbsp;&nbsp; SAString sBLob = 
      cmd.Field(&quot;FBLOB&quot;).asBLob();<BR>&nbsp;&nbsp;&nbsp; 
      SomeFunctionToSaveBLobToFile(&quot;blob.bin&quot;, sBLob);<BR>}</STRONG>  
      </P>
      <P>For using piecewise capabilities of SQLAPI++ for&nbsp;reading Long or 
      Lob types see <A href="../Examples/step6.cpp">example</A>.</P>
      <H3><A name="Server specific notes"></A>Server specific notes</H3>
            <P><STRONG>1.</STRONG> 
            Binding Lob(CLob, BLob) data when working with 
            <STRONG><A href="../ServerSpecific/Oracle.html" title="Oracle server specific information">Oracle</A></STRONG>        
                 server has some differences from others. It's necessary for 
            a name of bind variable to be the same 
            as the column name it associated with. </P>
            <P><FONT 
            face=System>Ex.:&nbsp;&nbsp;&nbsp;&nbsp; Update TEST set <FONT 
            color=maroon face="">FBLOB = :fblob</FONT> 
            where FKEY = 
            'KEY'</FONT>        
                          
                     
                   </P>
            <P>        
                          
               Therefore, it's impossible to bind Lob(CLob, 
            BLob) data to Oracle database by position. </P>
            <P><STRONG>2.</STRONG> 
            Working with PostgreSQL Large Objects 
            data (Oid field type) in <A 
            href="../ServerSpecific/PostgreSQL.html"><STRONG>PostgreSQL</STRONG></A> server has some 
            particular features. Generally when you fetch Oid field data (which 
            can point to any object, not necessary PostgreSQL Large Object) 
            SQLAPI++ returns its value as a number (SQLAPI++ returns an object 
            identifier). If you want to retrieve Oid field as PostgreSQL Large 
            Object you should set command-related option 
            <STRONG>OidTypeInterpretation</STRONG> to 
            <EM>&quot;LargeObject&quot;</EM> value before the command execution. 
            See <A 
            href="../OnLineDoc/Command_setOption.html">SACommand::setOption</A> 
            for more        
                          
                     
                  detailes. </P>
            <P><STRONG>3.</STRONG> The table below shows how SQLAPI++ data types 
            correspond with servers original data types.</P>
      <P>
      <TABLE border=1 cellPadding=5 width="100%">
        
        <TR>
          <TD>
            <P><STRONG><A 
                        href="../ServerSpecific/Oracle.html" title="Oracle server specific information">Oracle</A></STRONG></P></TD>
          <TD>
            <P>When using OCI8:<BR><EM>SA_dtLongBinary</EM> 
                        &lt;= &gt;  LONG 
            RAW<BR><EM>SA_dtLongChar</EM> &lt;= &gt;         
            LONG<BR><EM>SA_dtBLob</EM> &lt;=  &gt; BLOB, FILE<BR><EM>SA_dtCLob 
            </EM>&lt;= &gt;  CLOB</P>
            <P>When using OCI7:<BR><EM>SA_dtLongBinary</EM> 
                        &lt;= &gt;  LONG 
            RAW<BR><EM>SA_dtLongChar</EM> &lt;= &gt;         
            LONG<BR><EM>SA_dtBLob</EM> =  &gt; LONG RAW<BR><EM>SA_dtCLob 
            </EM>= &gt; 
 
   LONG</P></TD></TR>
        <TR>
          <TD>
            <P><STRONG><A 
                        href="../ServerSpecific/SQLServer.html" title="SQL Server server specific information">SQL 
                        Server</A> 
                        </STRONG> </P></TD>
          <TD>
            <P><EM>SA_dtLongBinary</EM> &lt;= &gt;   
            IMAGE<BR><EM>SA_dtLongChar</EM> &lt;= &gt;  
            TEXT<BR><EM>SA_dtBLob</EM> = &gt;    IMAGE<BR><EM>SA_dtCLob 
            </EM>=&gt; TEXT</EM></P></TD></TR>
                <TR>
                    <TD><STRONG><A 
                        href="../ServerSpecific/Sybase.html" title="Sybase server specific information">Sybase</A></STRONG>
                    <TD>
            <P><EM>SA_dtLongBinary</EM> &lt;= &gt;   
            IMAGE<BR><EM>SA_dtLongChar</EM> &lt;= &gt;  
            TEXT<BR><EM>SA_dtBLob</EM> = &gt;    IMAGE<BR><EM>SA_dtCLob 
            </EM>=&gt; TEXT</EM></P>
        <TR>
          <TD>
            <P><STRONG><A 
                        href="../ServerSpecific/DB2.html" title="DB2 server specific information">DB2</A></STRONG> </P></TD>
          <TD>
            <P><EM>SA_dtLongBinary</EM> &lt;= &gt; LONG   
            VARGRAPHIC<BR><EM>SA_dtLongChar</EM> &lt;= &gt; LONG  
            VARCHAR<BR><EM>SA_dtBLob</EM> &lt;= &gt;    BLOB<BR><EM>SA_dtCLob 
            </EM>&lt;=&gt; 
                        CLOB, DBCLOB</EM></P></TD></TR>
        <TR>
          <TD>
            <P><STRONG><A 
                        href="../ServerSpecific/Informix.html" title="Informix server specific information">Informix</A></STRONG> 
                        </P></TD>
          <TD>
            <P><EM>SA_dtLongBinary</EM> &lt;=  &gt;   
            BYTE<BR><EM>SA_dtLongChar</EM> &lt;=  &gt;  
            TEXT<BR><EM>SA_dtBLob</EM> = &gt;    BYTE<BR><EM>SA_dtCLob 
            </EM>=&gt; TEXT</P></TD></TR>
        <TR>
          <TD>
            <P><STRONG><A 
                        href="../ServerSpecific/InterBase.html" title="InterBase server specific information">InterBase</A></STRONG></P></TD>
          <TD>
            <P><EM>SA_dtLongBinary</EM> = &gt; BLOB, subtype 
            0<BR><EM>SA_dtLongChar</EM> = &gt;BLOB, subtype 
            1<BR><EM>SA_dtBLob</EM> 
            &lt;=&gt; BLOB, subtype 0<BR><EM>SA_dtCLob 
            </EM>&lt;=&gt; BLOB, subtype 1</EM></P></TD></TR>
        <TR>
          <TD>
            <P><STRONG><A 
                        href="../ServerSpecific/SQLBase.html" title="SQLBase server specific information">SQLBase</A></STRONG></P></TD>
          <TD>
            <P><EM>SA_dtLongBinary</EM> &lt;= &gt;  LONG 
            VARCHAR<BR><EM>SA_dtLongChar</EM> &lt;= &gt; LONG 
            VARCHAR<BR><EM>SA_dtBLob</EM> =&gt; LONG 
            VARCHAR<BR><EM>SA_dtCLob </EM>=&gt; LONG VARCHAR</P></TD></TR>
        <TR>
          <TD>
            <P><STRONG><A 
                        href="../ServerSpecific/MySQL.html" title="MySQL server specific information">MySQL</A></STRONG></P></TD>
          <TD>
            <P><EM>SA_dtLongBinary</EM> &lt;=   &gt; 
            BLOB<BR><EM>SA_dtLongChar</EM> &lt;=  &gt; 
            TEXT<BR><EM>SA_dtBLob</EM> = &gt; 
            BLOB<BR><EM>SA_dtCLob </EM>= &gt; TEXT</P></TD></TR>
        <TR>
          <TD>
            <P><STRONG><A 
                        href="../ServerSpecific/PostgreSQL.html" title="PostgreSQL server specific information">PostgreSQL</A></STRONG></P></TD>
          <TD>
            <P><EM>SA_dtLongBinary</EM> &lt;=    
            &gt; BYTEA<BR><EM>SA_dtLongChar</EM> &lt;=   
            &gt; TEXT<BR><EM>SA_dtBLob</EM> &lt;= 
  &gt; 
            Large Object<BR><EM>SA_dtCLob &lt; </EM>= &gt; 
            Large Object</P></TD></TR>
        <TR>
          <TD>
            <P><STRONG><A 
                        href="../ServerSpecific/ODBC.html" title="ODBC server specific information">ODBC</A></STRONG></P></TD>
          <TD>
            <P>SQLAPI++ maps data types to ODBC constants. 
            Actual mapping from constant to SQL type is ODBC driver 
specific.</P>
            <P><EM>SA_dtLongBinary</EM> &lt;=&gt; 
            SQL_LONGVARBINARY<BR><EM>SA_dtLongChar</EM> &lt;= &gt;        
            SQL_LONGVARCHAR<BR><EM>SA_dtBLob</EM> =  &gt; SQL_LONGVARBINARY<BR><EM>SA_dtCLob 
            </EM>=&gt; SQL_LONGVARCHAR</EM></P></TD></TR></TABLE></P>
            <P>&nbsp;</P>
            <h3>Problems and Questions</h3>
            <p>If you don't find the answer to you 
            questions or have some problems on using the Library, please, send 
            e-mail to <A href="mailto:howto@sqlapi.com" >howto@sqlapi.com</A>. </p>
            <p>&nbsp;</p>
            <P>&nbsp;</P>
		</td>
	<tr></tr>
</table></FONT>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -