New User-Defined Functions in Elliott DDF

Release Date: 12/6/17

In the future DDF (target to be released with Elliott 8.3,), we will add the following four user-defined functions:
  • ELIDATE2SQL
  • SQLDATE2ELI
  • ELITIME2SQL
  • SQLTIME2ELI
For example, you can use the following SELECT statement:
                select order_no, ELIDATE2SQL(order_date) from cpordhdr;
The date return in the above sample statement will be in the native SQL date format, instead of the Elliott 8-digit date.

The following is the detail of the script that we use to create these four user-defined functions:

CREATE FUNCTION ELIDATE2SQL(:ELIDATE NUMERIC(8,0))
RETURNS DATE
AS 
BEGIN
DECLARE :C CHAR(8);
DECLARE :D DATE;
IF (:ELIDATE = 0) THEN
  SET :D=NULL;
ELSE
  SET :C=CONVERT(:ELIDATE,SQL_CHAR);
  SET :D=CONVERT(concat(concat(concat(concat(left(:C,4),'-'),substring(:C,5,2)),'-'),right(:C,2)),SQL_DATE);
END IF;
RETURN :D;
END;
 
CREATE FUNCTION SQLDATE2ELI(:SQLDATE DATE)
RETURNS NUMERIC(8,0)
AS 
BEGIN
DECLARE :C CHAR(10);
DECLARE :Y NUMERIC(4,0);
DECLARE :M NUMERIC(2,0);
DECLARE :D NUMERIC(2,0);
DECLARE :N NUMERIC(8,0);
IF (:SQLDATE = NULL) THEN
  SET :N=0
ELSE
  SET :C=CONVERT(:SQLDATE,SQL_CHAR);
  SET :Y=CONVERT(LEFT(:C,4),SQL_NUMERIC);
  SET :M=CONVERT(SUBSTRING(:C,6,2),SQL_NUMERIC);
  SET :D=CONVERT(RIGHT(:C,2),SQL_NUMERIC);
  SET :N=:Y * 10000 + :M * 100 + :D;
END IF;
RETURN :N;
END;
 
CREATE FUNCTION ELITIME2SQL(:ELITIME NUMERIC(6,0))
RETURNS TIME
AS 
BEGIN
DECLARE :C VARCHAR(12);
DECLARE :T TIME;
SET :C=CONVERT(:ELITIME,SQL_CHAR);
-- PAD ZEROES ON THE LEFT
SET :C=RIGHT(CONCAT('000000',:C),6);
SET :T=CONVERT(concat(concat(concat(concat(left(:C,2),':'),substring(:C,3,2)),':'),right(:C,2)),SQL_TIME);
RETURN :T;
END;
 
CREATE FUNCTION SQLTIME2ELI(:SQLTIME TIME)
RETURNS NUMERIC(6,0)
AS
BEGIN
DECLARE :C CHAR(8);
DECLARE :H NUMERIC(2,0);
DECLARE :M NUMERIC(2,0);
DECLARE :S NUMERIC(2,0);
DECLARE :N NUMERIC(6,0);
IF (:SQLTIME=NULL) THEN
  SET :N=0;
ELSE
  SET :C=CONVERT(:SQLTIME,SQL_CHAR);
  SET :H=CONVERT(LEFT(:C,2),SQL_NUMERIC);
  SET :M=CONVERT(SUBSTRING(:C,4,2),SQL_NUMERIC);
  SET :S=CONVERT(RIGHT(:C,2),SQL_NUMERIC);
  SET :N=:H * 10000 + :M * 100 + :S;
END IF;
RETURN :N;
END; 


EMK

Pervasive PSQL

  1. Btrieve Error Codes 001 - 199
  2. Btrieve Error Codes 3000 - 3099
  3. Btrieve Error Codes 3100 - 3199
  4. PSQL Version Required by Each Elliott Version
  5. Do I Need to Change PSQL Server Engine Default Parameters After Installing It?
  6. New Elliott PSQL Server Processor and RAM Suggestions
  7. Can I Dynamically Adjust Elliott / PSQL 11 Server Memory?
  8. Received "Your Computer Does Not Have PSQL 10 or 11 Client " Even though PSQL Client Is Just Installed
  9. Btrieve Error 161 on Password File When Starting Up Elliott
  10. Problems with Using Pervasive Rebuild Utility on APOPNFIL and AROPNFIL Tables
  11. Security Issue with Installing PSQL Client Remotely on User's Workstation
  12. PSQL and Distributed File System (DFS)
  13. How Do I Turn on PSQL Relational Engine Security?
  14. An Example of Debugging NOTE_ORD_VIEW PSQL Expression Evaluation Error
  15. Btrieve Error 025 on COP Open Order by Salesman Report
  16. What Is the *.^01 File for My PSQL Btrieve Table?
  17. Suggested Files to be Monitored by Audit Master
  18. Pervasive Backup Agent Is Not Compatible with Creating Work Files
  19. Hardware Recommendations for Your PSQL Database Server
  20. How to Optimize SQL SELECT Statement When Retrieving Data from Invoice History
  21. New User-Defined Functions in Elliott DDF
  22. How to Improve Query Performance When Retrieving Data from Notes & Invoice History
  23. How to Retrieve Tracking Number for an Order from Notes
  24. Actian PSQL Not Started Automatically After Server Reboot
  25. Create a New Database in the PCC for Relational Engine Access
  26. Slow PSQL Relational Engine Performance
  27. IPV6 May Cause Problem for PSQL 11 Relational Query
  28. DDF Files in DATA Folder May Confuse PSQL
  29. What to Do When PSQL 11 License Is Disabled
  30. Quick Installation Guide for Audit Master
  31. Quick User Guide for Audit Master

Feedback and Knowledge Base