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
1
vote
1 answer

SQR CASE STATEMENT GIVING ERROR WHEN LOCAL VARIABLE IS USED

I need to use a date variable in a case statement for the select section of a sql statement in sqr and keep getting an error. It works fine when i use the getdate() function to compare but doesn't work with my variable. help please. code is…
1
vote
2 answers

Assistance in understanding sqr logic

Hello, I am new to learning how to develop sqr programs within PeopleSoft. I've been going through some programs we are utilizing and wanted to see if someone could help provide clarification with what the below snippet of code is doing in this…
Nick
  • 268
  • 8
  • 33
1
vote
1 answer

Alter variable format using SQR programming language

I am new to Peoplesoft and Peoplecode/SQR in general and I want to ask a question. What I wish to do, is to try and output a large (clob) string variable on a PDF file using SQR programming language, on 3 columns on the page, just as you can change…
Serban Spirescu
  • 139
  • 1
  • 4
  • 19
1
vote
2 answers

SQR string variable

I have a string variable which is getting approx 1184 var from query but it is displaying only 263 character in SQR report which is in CSV format. Please tell how to get whole character in my variable. Please help i m new to SQR Report
mayank sahai
  • 103
  • 4
  • 15
1
vote
1 answer

Are dynamic variables possible in SQR (not dynamic SQL)

I'm writing an SQR program to send a vendor a file containing employee info. The file contains a number of fields for which I've assigned the variables $Code_1 $Code_2 $Code_3 .... Each code has an associated rate, and I've assigned…
Chip
  • 1,653
  • 2
  • 20
  • 27
1
vote
2 answers

Checking for duplicates in SQR

I am currently trying to update an SQR to check for duplicate values across columns within a given record. We are allowing duplicates to be entered into the table, but we want an error flag to be checked as it breaks the next program. ID - 1 Var1…
Daniel J
  • 21
  • 3
1
vote
1 answer

Structuring procedural code for unit tests

If you're planning to write unit tests for a C program, what is the convention for placement of the main function? Do you put it in it's own separate file, with the functions in another file, that way you can include the functions file inside a…
yankees13
  • 125
  • 5
1
vote
2 answers

Scheduling a Peoplesoft SQR Process from SQR

In our project, we have a situation where we need to schedule an SQR on a specific date at the end of processing of another SQR. We can't set a recurrence since the date of the next run will be calculated based on rules and is not constant. Can…
urpandian
  • 15
  • 1
  • 5
1
vote
0 answers

SQR gives an error at NEW-PAGE command while printing a label

I am running a SQR to print a label from PeopleSoft. I am getting an error at the end of the process. Strange this is my printer is printing a label perfectly but PeopleSoft process is giving an error so I put some logs and finally I found that it…
1
vote
1 answer

Write an SQR condition statement

I'm new in SQR. I need help to write a variable and use it for a condition statement. my pseudo code goes declare $head_print let $head_print = (select * from PS_DTR_RPT_ACCT where RPT_TREE_NODE = 'REAL_ESTATE_EXP' or TREE_NODE_NUM between…
user3396478
  • 176
  • 2
  • 13
1
vote
2 answers

Upgrading SQR reports to Crystal Reports

We are currently using SQR reports and we would like to upgrade it to Crystal reports 2011. Is it possible to convert the SQR query for usage in the Crystal?
guitarist
  • 27
  • 2
  • 6
1
vote
1 answer

Addressing both commas and double quotes in a CSV

I am writing a report in SQR which produces a CSV output file. While testing, I ran into an instance where the following string is used in one of my fields: TABLE - 210" X 60" X 29", OAK, I currently have double quotes surrounding the string. When…
friedpikmin
  • 31
  • 1
  • 7
1
vote
3 answers

using UNIX command to zip/compress a file with PASSWORD in SQR

I want to use unix command in SQR to zip/ compress a file with password and after that verifying password option
1
vote
1 answer

Oracle SQR datediff, rounding off seconds, and type

in Oracle SQR (please, I know how already in SQL, I'm asking about SQR syntax), how can I: - determine the "type" of a variable? I can't find any "type" function - what is the data type returned by datediff()? - and finally, how do I round off…
noogrub
  • 872
  • 2
  • 12
  • 20
0
votes
1 answer

How to convert SQR report to CSV file

I am trying to convert SQR report to CSV file by command. I am using SQR Version: SQR V4.3.4 What I actually tried: from official documentation: -EH_CSVONLY Creates a CSV file but does not create an HTML file. so the command that I am…
ahmed abdelqader
  • 3,409
  • 17
  • 36