109 lines
4.5 KiB
HTML
109 lines
4.5 KiB
HTML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE html
|
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html lang="en-us" xml:lang="en-us">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<meta name="security" content="public" />
|
|
<meta name="Robots" content="index,follow" />
|
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
|
<meta name="DC.Type" content="reference" />
|
|
<meta name="DC.Title" content="Example: LOBFILE.SQB in COBOL" />
|
|
<meta name="DC.subject" content="examples, LOBFILE.SQB COBOL program listing, LOBs (Large Objects), LOBEVAL.SQB COBOL program listing" />
|
|
<meta name="keywords" content="examples, LOBFILE.SQB COBOL program listing, LOBs (Large Objects), LOBEVAL.SQB COBOL program listing" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafyexampextract.htm" />
|
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
|
|
<meta name="DC.Format" content="XHTML" />
|
|
<meta name="DC.Identifier" content="rbafylfilb" />
|
|
<meta name="DC.Language" content="en-us" />
|
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
|
<!-- US Government Users Restricted Rights -->
|
|
<!-- Use, duplication or disclosure restricted by -->
|
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
|
<title>Example: LOBFILE.SQB in COBOL</title>
|
|
</head>
|
|
<body id="rbafylfilb"><a name="rbafylfilb"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Example: LOBFILE.SQB in COBOL</h1>
|
|
<div><div class="section"><div class="note"><span class="notetitle">Note:</span> By using the code examples, you agree to the terms of the <a href="codedisclaimer.htm">Code license and disclaimer information</a>.</div>
|
|
</div>
|
|
<div class="example"> <pre>
|
|
Identification Division.
|
|
Program-ID. "lobfile".
|
|
|
|
Data Division.
|
|
Working-Storage Section.
|
|
copy "sqlenv.cbl".
|
|
copy "sql.cbl".
|
|
copy "sqlca.cbl".
|
|
|
|
EXEC SQL BEGIN DECLARE SECTION END-EXEC. <span>1</span>
|
|
01 userid pic x(8).
|
|
01 passwd.
|
|
49 passwd-length pic s9(4) comp-5 value 0.
|
|
49 passwd-name pic x(18).
|
|
01 resume USAGE IS SQL TYPE IS CLOB-FILE.
|
|
01 lobind pic s9(4) comp-5.
|
|
EXEC SQL END DECLARE SECTION END-EXEC.
|
|
|
|
77 errloc pic x(80).
|
|
|
|
Procedure Division.
|
|
Main Section.
|
|
display "Sample COBOL program: LOBFILE".
|
|
|
|
* Get database connection information.
|
|
display "Enter your user id (default none): "
|
|
with no advancing.
|
|
accept userid.
|
|
|
|
if userid = spaces
|
|
EXEC SQL CONNECT TO sample END-EXEC
|
|
else
|
|
display "Enter your password : " with no advancing
|
|
accept passwd-name.
|
|
|
|
* Passwords in a CONNECT statement must be entered in a VARCHAR
|
|
* format with the length of the input string.
|
|
inspect passwd-name tallying passwd-length for characters
|
|
before initial " ".
|
|
|
|
EXEC SQL CONNECT TO sample USER :userid USING :passwd
|
|
END-EXEC.
|
|
move "CONNECT TO" to errloc.
|
|
call "checkerr" using SQLCA errloc.
|
|
|
|
move "RESUME.TXT" to resume-NAME. <span>2</span>
|
|
move 10 to resume-NAME-LENGTH.
|
|
move SQL-FILE-OVERWRITE to resume-FILE-OPTIONS.
|
|
|
|
EXEC SQL SELECT resume INTO :resume :lobind <span>3</span>
|
|
FROM emp_resume
|
|
WHERE resume_format = 'ascii'
|
|
AND empno = '000130' END-EXEC.
|
|
if lobind less than 0 go to NULL-LOB-indicated.
|
|
|
|
display "Resume for EMPNO 000130 is in file : RESUME.TXT".
|
|
go to End-Main.
|
|
|
|
NULL-LOB-indicated.
|
|
display "NULL LOB indicated".
|
|
|
|
End-Main.
|
|
EXEC SQL CONNECT RESET END-EXEC.
|
|
move "CONNECT RESET" to errloc.
|
|
call "checkerr" using SQLCA errloc.
|
|
End-Prog.
|
|
stop run.</pre>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafyexampextract.htm" title="This program example shows how character large object (CLOB) elements can be retrieved from a table into an external file.">Example: Extract a document to a file</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |