Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
sunbelt-plb-samples/legacy_demo/odbc.pls at main · KcsDev1982/sunbelt-plb-samples · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
KcsDev1982
/
sunbelt-plb-samples
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
5
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
main
Breadcrumbs
sunbelt-plb-samples
/
legacy_demo
/
odbc.pls
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
184 lines (184 loc) · 6.79 KB
main
Breadcrumbs
sunbelt-plb-samples
/
legacy_demo
/
odbc.pls
Copy path
Top
File metadata and controls
Code
Blame
184 lines (184 loc) · 6.79 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
*..........................................................................
. Example Program: ODBC.PLS
.
. This program is a simple example of the PL/B SQL statements. It
. allows the user to connect to a remote database via ODBC. ODBC must
. be installed before this program is executed.
.
. The following function are performed:
. 1. Connects to ODBC remote database.
. 2. Sets up a database query.
. 3. Executes the database query.
. 4. Checks the status of the database query.
. 5. Fetches all of the data selected by the query and displays it.
. 6. Disconnects from the ODBC remote database.
.
. Copyright @ 1997-1999 Sunbelt Computer Systems, Inc.
. All Rights Reserved.
*............................................................................
.
D DBFILE
Reply DIM 1
R FORM 4
ID DIM 5
NAME DIM 40
*
. Column Data Retrieved from the Selected Table
. (These should be modified to match your database specifications.)
.
ORDID FORM 2
ORDCUS DIM 5
ORDPID INTEGER 4
ORDDT DIM 10
ORDQT DIM 4
*..........................................................................
. Connect to the Database
.
. The DBCONNECT statement allows a program to connect to a remote
. database and associate that connection with a DBFILE declaration.
.
. There are four required parameters and two optional parameters for
. this statement.
.
. FORMAT:
. DBCONNECT <dbfile>,<host>,<user>,<pass>[,<conn>,<ext>]
.
. where:
.
. <dbfile> - defines the DBFILE associated with the connection.
. <host> - defines the name of the data source.
. <user> - defines the name of the user.
. <pass> - defines the user's password.
. <conn> - optional parameter to define additional login info.
. <ext> - optional parameter to define the database extension.
.
DBCONNECT D,"","","" // Since the name of the <host>
// parameter is null, this statement
// envokes a standard dialog to identify
// the database to be connected to.
// The <host> parameter could also
// be specified like in the variables
// 'L1' and 'L2' above.
*..........................................................................
. Issue the SQL Statement
.
. The DBSEND statement is used to send a query or a portion of a query
. to the ODBC system driver. Note that the query is simply buffered by
. the DBSEND statements. The actual execution of the query does not
. take place until DBEXECUTE is performed.
.
. FORMAT:
. DBSEND <dbfile>;<list>
.
. where:
.
. <dbfile> - defines the DBFILE associated with the connection.
. <list> - defines a comma delimited list of controls, variables,
. and literals. The list is similiar to a DISPLAY.
.
.
.
.The Table name should be changed as appropriate
.
DBSEND D;"SELECT * from orders"
*..........................................................................
. Execute the Query
.
. The DBEXECUTE statment is used to execute the query specified by the
. DBSEND statement(s). Note that if the DBEXECUTE initiates the query
. ok, then it can return before the query is completed. The program
. should use the DBSTATE statement to determine the status of the query
. before executing a DBFETCH statement.
.
. FORMAT:
. DBEXECUTE <dbfile>
.
. where:
.
. <dbfile> - defines the DBFILE associated with the connection.
.
.
DBEXECUTE D
.
*............................................................................
. Wait for the Query to Complete
.
. The following logic is waiting for the status of the last query to
. indicate when it is completed. This logic is using the DBSTATE statement
. to determine when the query is complete.
.
. The DBSTATE statment is used to determine the current state of a remote
. database. The actual state is provided via the flags LESS and EQUAL.
. When the LESS is set, then a query is currently executing at the remote
. database. Otherwise, it is cleared. The EQUAL flag is set when the
. remote database has data that can be obtained using the DBFETCH
. statement.
.
. FORMAT:
. DBSTATE <dbfile>
.
. where:
.
. <dbfile> - defines the DBFILE associated with the connection.
.
.
DISPLAY *HD,*R,"Waiting.";
LOOP
DISPLAY ".";
DBSTATE D
REPEAT WHILE LESS
DISPLAY *N;
*............................................................................
. Fetch Data
.
. The following logic is looping through the current query selection
. data using the DBFETCH statement. The DBFETCH statement sets the
. OVER when there are no more rows of information to be retreived.
. This should give the user a feel like a READ statement. There is also
. a timeout value which can be given for the DBFETCH operation. The LESS
. flag is set if the timeout value expires before an item is received from
. the remote database. If the timeout value is -1, this disables the
. the timeout feature.
.
. FORMAT:
. DBFETCH <dbfile>,<timeout>;<list>[<;>]
.
. where:
.
. <dbfile> - defines the DBFILE associated with the connection.
. <timeout> - defines the timeout value to be used for data being
. retrieved. A value is specified in seconds. If
. the value is a "-1", then the timeout feature is
. not used.
. <list> - defines a comma delimited list of controls and variables
. into which the data is returned. This is very
. similiar to a READ statement.
. <;> - a semi-colon is optional at the end of a DBFETCH
. statement. This can be used to retrieve a partial
. number of columns from a row. Note that a
. DBFETCH will not proceed to the next row until a
. DBFETCH is executed without a semi-colon.
.
LOOP
DBFETCH D,"1";ORDID,ORDCUS,ORDPID,ORDDT,ORDQT
UNTIL OVER
DISPLAY ORDID,":",ORDCUS," : ",ORDPID," : ",ORDDT," : ",ORDQT
REPEAT
*.............................................................................
. Disconnect the Database
.
. The DBDISC or DBDISCONNECT statement is used to disconnect from the
. remote database.
.
. FORMAT:
. DBDISCONNECT <dbfile>
.
. where:
.
. <dbfile> - defines the DBFILE associated with the connection.
.
DBDISCONNECT D
*............................................................................
. Terminate Execution
.
KEYIN *HD,*R,"Database Closed. ",Reply
You can’t perform that action at this time.