Questions tagged [sqr]

SQR is a high level language like Basic but with built in SQL capabilities - it became very popular with PeopleSoft in the early 90's and is still a mainstay of that product. It can run on many platforms and use many databases

SQR is a programming language designed for generating reports from database management systems. The name is an acronym of Structured Query Reporter, which suggests its relationship to SQL (Structured Query Language). Any SQL statement can be embedded in an SQR program.

Features

SQR is notable for its powerful database and printing functions. It can embed any SQL statement almost anywhere in a program. There is a version of SQR that can use multidimensional databases like Essbase. It can combine database reads with print instructions. It flexibly formats data breaks and page breaks. It prints variable fonts, sizes, and colors. It has a graph generation command that offers dozens of parameters for adjusting content and appearance.

The language is very easy to learn but has some nuances. It is normally compiled at run time, however, it can also be pre-compiled, which does save time on larger programs.

Syntax

SQR has four scalar data types. The first three are:

  • numeric (variables begin with “#”)
  • character string (variables begin with “$”)
  • and date (variables begin with “$”, same as with character string variables.).

Date variables must be declared, to be distinguished from character string variables. There is the option to declare numeric variables to specify them more precisely (integer, floating point, etc.). The last data type is a database column (variables begin with “&”). The values of database columns are set only by a SQL “select” statement; no other command can change their values.

SQR also has arrays, like those of the C programming language or COBOL. An array has one or more fields, where each field is either a numeric, string, or date variable. Each field may have multiple occurrences, giving SQR the equivalent of two-dimensional arrays. SQR has special commands that manipulate multiple items within a single array. There are many commands that cannot use an array element in place of a scalar variable.

The language has four primary control structures. The first three are:

  • if-else-end
  • while-end
  • and evaluate (like case or switch).

The fourth is the embedded SQL “select” statement, which allows SQR statements to be executed for each row of data in a loop.

SQR has commands to open, read, write, append, and close computer files. File input and output is sequential and record-oriented only; random access is not supported.

SQL Select statements are built into the language using Begin-Select and End-Select statements. It can also run native SQL for Inserts, Updates, Deletes, Truncates, etc within Begin-SQL and End-SQL statements.

Within a Begin-Select and End-Select block, each row returned from the query can be trapped and used to either print or call other procedures that may call other SQL statements (or do other logic).

It can be used to produce very pretty reports (a PDF format is an option as well as HTML and CSV formats) and can also read and write files very easily. Multi-dimensional arrays are also supported.

One of the most under-utilized features is the built-in on-break mechanism. Instead of having to manually set break-points when switching groups, this language has an on-break clause that can be attached to fields being returned from the SQL query - using these, Before and After operands allow calling of procedures. For example:

Begin-Select
    Company() on-break print=change/top-page before=Init-Company after=Process-Company Level=1
    Name () on-break print=change/top-page before=Init-Employee after=Process-Employee Level=2
    From PS_Employees
    Order by Company, Name
End-Select

This logic will break on company and employee automatically and call before and after procedures without any flags or grouping required.

SQR is a language still currently being used and it remains a top report and processing program language with PeopleSoft systems.

71 questions
17
votes
3 answers

Fast bignum square computation

To speed up my bignum divisons I need to speed up operation y = x^2 for bigints which are represented as dynamic arrays of unsigned DWORDs. To be clear: DWORD x[n+1] = { LSW, ......, MSW }; where n+1 is number of used DWORDs so value of number x =…
Spektre
  • 49,595
  • 11
  • 110
  • 380
3
votes
1 answer

Trigger only inserting 1 character of variable into table

I have the following sql trigger that is inserting data into a table named PS_AUDIT_PSROLEUSR, based on a Delete action that occurred on a related table. When the table update is triggered by an online user in the application (a role row is removed)…
Nick
  • 268
  • 8
  • 33
2
votes
1 answer

Using SQR to generate a Saved PDF document

I am using an older client/server version of PeopleSoft (7.53 Apps, 7.63 Tools) and trying to get my SQR to automatically generate and save a PDF document. Currently I can use a SQR Flag of -ZIV to open up the SQR Viewer which displays my output to…
Paul
  • 21
  • 1
2
votes
1 answer

SQR Procedure parameters/arguments

I'm trying to understand more about how arguments/parameters are used when calling and executing procedures. I understand that procedures that contain an parameter with a leading colon (:) pass back values to the calling DO command, however I think…
Nick
  • 268
  • 8
  • 33
2
votes
0 answers

SQR and Oracle support

We are a somewhat heavy SQR user and powers above have told us Oracle is stopping support of SQR... I know it is heavily used but have yet to see mention of this online. I just spoke with a friend who works for ADP, a big SQR user, and she has heard…
2
votes
1 answer

Converting date formats in SQR

I'm trying to convert an SQR string from the following format of MM-DD-YYYY into a format of YYMMDD. I've tried to use the following SQR function: STRTODATE('03-09-2018', 'YYMMDD') but I get the following error. (SQR 7501) Using YY edit mask from…
Jimenemex
  • 3,104
  • 3
  • 24
  • 56
2
votes
1 answer

Returning a TABLE like structure in the SELECT

I am working with SQR to put together a report. I can't change the structure of the database, nor can I use PL/SQL to complete this task. Since the report can be run from remote locations, I don't want to make multiple calls to the database from…
Bob
  • 1,045
  • 8
  • 10
1
vote
1 answer

SQR replace by position rather than multiple IF LET ENDIF

In translating codes from one database to the next, I have to use an IF LET ENDIF for each code. IF $CODE = 'A11' LET $CODE = 'AAA' END-IF IF $CODE = 'B11' LET $CODE = 'BBB' END-IF IF $CODE = 'C11' LET $CODE = 'CCC' END-IF. . .ad nauseum Is there a…
dvhouten
  • 55
  • 5
1
vote
1 answer

(SQR 4008) Unknown function or variable in expression

I have an SQR code like this: begin-procedure SPL-REMOVE($Vndr_Name_Shrt_Usr, :$outputshrt) Let $valid_chars_shrt = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -.:/'@0123456789@()=+%*"£$' Let $invalid_chars_shrt =…
1
vote
1 answer

Subtracting 1 day from date variable causing errors

I have an SQR program that uses a field called $EFFDT. It is NOT explicitly declared in the program as a date variable. What it currently does is get initially set to '' (blank) as follows: LET $EFFDT = ' ' $EFFDT then gets set by reading a file…
Nick
  • 268
  • 8
  • 33
1
vote
0 answers

How to submit a JCL through SQR Call System Command on MVS z/os?

I’m trying to submit a JCL through an SQR Program using Call System Command on MVS z/os. The JCL resides in specific Dataset. What I’m trying do is something like this: let $jclcmd= 'SUBMIT PSLIBDSN.O92.CUST7.JCLSRC(UTILI)' call system using…
Bill_Buckner
  • 11
  • 1
  • 4
1
vote
0 answers

Access file on another computer using SQR

I want to import pictures from another computer on our network than where SQR is running. I am wondering how best to specify the path so that the file can be opened. I have had our user name that runs when running and SQR added to the other…
Tree
  • 11
  • 2
1
vote
0 answers

Set Current_Schema for SQRW

When I work with Oracle databases, I often "need" to run a command similar to this before I can begin querying tables in the sysadm schema: ALTER SESSION SET CURRENT_SCHEMA = sysadm; I can do that in Oracle SQL Developer or SQL Plus easily, but I…
Shawn Eary
  • 684
  • 2
  • 7
  • 21
1
vote
1 answer

Explicitly say which conditions to fold Notepad++

I have a custom language for SQR and I'm trying to get the code folding feature to work for Notepad++. In SQR, the case of the keywords do not matter. Begin-Procedure is the same as bEgIn-ProCEdure. The same goes for the traditional if ... end-if…
Jimenemex
  • 3,104
  • 3
  • 24
  • 56
1
vote
2 answers

Align column values in SQR

I'm trying to align the column values, but they are of different lengths. I can't just use Print '123' (+1, 9) and then Print '123456' (+1, 9) because it'll look something like this: 123456790123456790123456790123456790123456790123456790 <- Ignore…
Jimenemex
  • 3,104
  • 3
  • 24
  • 56
1
2 3 4 5