Documente Academic
Documente Profesional
Documente Cultură
Conceptos
Herramienta de reportes y procesos
Se programa en archivos de texto con nombre de 8 caracteres mximo y
extensin SQR
Mdulos a incluir con extensin SQC
SQR
Heading
Body
Footing
SQR
Primera pasada
Se procesan los #INCLUDE SQCs y se insertan en el cdigo principal
Se evalan todos los dems comandos #. En particular se sustituyen los
#DEFINE por su valor
Se procesa la seccin SETUP y se reserva memoria para arrays
Se verifica la sintxis
SQR
Segunda pasada
La ejecucin comienza desde el Begin-Report y termina en End-Report
El cuerpo del reporte es calculado restando el Page-Size definido en la seccin
Setup menos el Cabezal y el Pie de pgina.
1. Processes data for the Body section
If page overflow occurs or a NEW-PAGE command is encountered in the code:
a. Processes HEADING section
b. Processes FOOTING section
c. Writes page buffer to the output buffer
d. Returns back to 1., above
2. Processes HEADING section
3. Processes FOOTING section
4. Writes entire page buffer to file
SQR
Secciones
Report or Program (principal)
nica seccin obligatoria
Generalmente se compone de comandos do
begin-program
do MyProcedure
end-program
Setup (Declaraciones)
begin-setup
! Declare the default layout for this report
declare-layout default
paper-size=(8.5,11)
left-margin=1 right-margin=1
top-margin=1 bottom-margin=1
end-declare
end-setup
SQR
Secciones (2)
Heading/Footing
begin-heading 1
print 'Tutorial Report' (1) center
end-heading
begin-footing 1
! print "Page n of m" in the footing
page-number (1,1) 'Page '
last-page () ' of '
end-footing
Procedures
begin-procedure myprocedure
[paragraphs and commands]
end-procedure
Se llaman con el comando do
SQR
Paragraphs
Select
Sentencia SELECT al estilo SQR!!
SQL
Permite ejecutar sentencias SQL Update,Delete,etc.
Document
Permite mezclar texto y datos recuperados de la DB
SQR
Paragraph select
begin-SELECT [DISTINCT][Loops=#][ON-ERROR=procedure]
COLUMN_NAME
! normally 1 per line
[SQR commands]
! must be indented
FROM TABLE/VIEW
[WHERE]
[Order by ]
end-SELECT
begin-select
name (,1)
city (,32)
state (,49)
phone (,55)
position (+1) ! Advance to the next line
from customers
end-select
9
SQR
Paragraph SQL
10
SQR
11
SQR
(+1,1,30)
(,+5,15)
Print Implcito/Sustitucin {}
begin-procedure implicit-print
begin-SELECT
NAME
(+1,1,30)
PHONE
(,+5,15)
FROM PS_STUDENT_DATA
end-SELECT
end-procedure implicit-print
#define c1 1
#define c2 35
begin-procedure implicit-print
begin-SELECT
NAME
(+1,{c1})
PHONE
(,{c2})
FROM PS_STUDENT_DATA
end-SELECT
end-procedure implicit-print
12
SQR
Print Formatos
Center
Edit
Fill
Wrap
On-Break
PRINT '=+= (+1,5,9) FILL
!Results: =+==+==+=
13
SQR
14
SQR
Variables/command Let
Pueden tener cualquier largo
No son case-sensitive
Son globales (salvo parmetros de procedures)
Data Type
Variable Name
Maximum Size
Initialized
to
Character, string,
text, date
$Text
RDBMS longvar
null
Numeric (float,
decimal, integer)
#Num
RDBMS double
floating point
SQR
Variables reservadas
#CURRENT-LINE Current physical line on a page.
#CURRENT-COLUMN Current column on a page.
#PAGE-COUNT
Current page number (can be reset).
#END-FILE
Set to 1 if end of file occurs.
#RETURN-STATUS Value returned to operating system when SQR exits.
#SQL-COUNT
The # of rows affected by an SQL DML statement.
#SQL-STATUS
Status value from database after each query is compiled/executed.
$SQR-DATABASE The database type for which SQR was compiled.
$SQL-ERROR
Text message of error returned from DBS.
$SQR-LOCALE
The name of the current locale being used.
#SQR-PID
The process ID of the current SQR process.
$SQR-PLATFORM The hardware/operating system type for which SQR was compiled.
Valid values are: WINDOWS, VM, MVS, VMS, and UNIX.
$SQR-PROGRAM The name of the SQR program file.
$SQR-VER
The text string shown with -ID flag.
16
SQR
Arrays
Array
CREATE-ARRAY
NAME= of array
SIZE= number of rows, starting at zero (0)
FIELD= fieldname : type : occurs
begin-procedure array_students
CREATE-ARRAY NAME=students SIZE=25
FIELD=
student_id:char
FIELD=
name:char
FIELD=
course:char:3
end-procedure array_students
Put
PUT '2001'
INTO students(0)
student_id
Get
17
SQR
Sentencias de control
DO
Perform a procedure
BREAK
IF
Conditional execution
EVALUATE
18
SQR
WHILE
Loop structure
GO TO
Jump to a label
STOP QUIET
STOP
EXIT-SELECT
IF {field} = {value}
{execute SQR command(s)}
ELSE
{execute SQR command(s)}
END-IF
If &Course_Type = 'T'
and $Project_Role = 'DBA'
Do Process-DBA
Else
Do Process-Functional
End-if
EVALUATE
EVALUATE variable
WHEN = {value or variable}
{execute SQR command(s)}
BREAK
WHEN = {value or variable}
{execute SQR command(s)}
BREAK
WHEN-OTHER
{default SQR command(s)}
END-EVALUATE
19
SQR
WHILE
WHILE #num < {#num_var or literal}
{execute SQR command(s)}
add 1 to #num
END-WHILE
20
SQR
Manejo de archivos
OPEN
READ
WRITE
CLOSE
Close a file
SQR
22
SQR
SQR Runner
Editor y ejecutor de SQR integrado
No es distribuido por PeopleSoft
Cuenta con templates para SQR nuevos
23
SQR
SQR Runner
Opciones
En registry o al momento de ejecutar
SQR
Usuario de DB, no PS
25
SQR
Debug
No tiene debugger integrado, es mediante comandos show
Se utiliza la directiva #debug para indicar que ejecute el comando
Se ejecuta con el parmetro DEBUG para indicar que ejecute las directivas
En ambientes de produccin no se usa
26
SQR
Tarea V