Is this code written in Pl/Sql, and if not, then what language is it? - plsql

I have encountered this code... Is this Pl/Sql? What do you think it is?
[Script 1.0]
script package up is
import native def_1;
procedure p(
i_g text
)
is
l_txt text;
begin
with mem_m(idx) as msg do
with book_aud(evt_id) as book do
book.upd_pkt(
evt_nr => i__nr
,ref_nr => msg.h.id
,account_nr => msg.h.id
,status => '1'
);
end with;
end with;
end p;
I am surprised by import and end with;
It is not the full code. It is reduced version of it.
It also contained familiar elements such as:
c_max constant number := 95;
c_VE_BA constant text := 'A07000';
-- comment
if i_mt is null then
return rpad('/',16);
else
if i_id = zconst_.c_JPY then
l_fmt := '9999999999999999';
else
l_fmt := '9999999999999D99';
end if;
end if;
case i_typ_id
when def_typ.contr then
l_zuonr := zfx2.c_avqt;
when def_typ.fx then
l_zuonr := zfx2.c_avqd;
when def_typ.fxswap then
l_zuonr := zfx2.c_avqd;
when def_typ.forex then
l_zuonr := zfx2.c_avqd;
when def_typ.xfer then
l_zuonr := zfx2.c_avqd;
when def_typ.intr then
l_zuonr := zfx2.c_avqt;
else
assert(false,'Meta Typ');
end case;
It looks like an extension of Pl/Sql.
Based on the responses and my own research, I guess it is Avaloq+PL/Sql.
I contacted Avaloq,I am still waiting for official answer.

It looks like Avaloq Script, used by (ahem) Swiss banks, and while there is very little about it online, I found a grammar which perfectly matches the terms in your samples.
Avaloq Script, the Avaloq Banking
System's script language, facilitates
entering specific business logic. The
structure of the data that can be
accessed through Avaloq Script is
defined in a DDIC (Data Dictionary),
making it unnecessary to know the data
storage structure.

yes it is avaloq script. its some kind of pl/sql pre compiler, you should be able to find a package called s#up where the real pl/sql code resides.

It definitely is Avaloq Script. The code snippet is a script package that Avaloq compiler compiles into PL/SQL. The point of Avaloq Script is to disallow direct database access and make the customizer of the Avaloq product to use the Avaloq API instead. The API is the Avaloq script language and a whole array of other ways like setting up rule tables to be loaded or special syntax to define forms, reports, workflows etc. often allowing snippets of Avaloq script within that other kind of sources.
Avaloq script has many PL/SQL elements but also some VB language concepts can be found. Here are some comments in the code to give some idea what the code means.
[Script 1.0] -- Have not seen other than 1.0 version
script package up is -- The PL/SQL package name is going to be s#up
import native def_1; -- import native means a PL/SQL package named
-- def_1 can be used, without native it is
-- another Avaloq script package
procedure p( -- declares a procedure with the name "p"
i_g text -- input variable i_g defined text.
-- in PL/SQL this becomes a VARCHAR2
)
is
l_txt text; -- local variable VARCHAR2(4000) in PL/SQL
begin
with mem_m(idx) as msg do -- mem_m is a DDIC (Data Dictionary)
-- It actually is a kind of "class" with
-- fields and methods
-- "with" is like in VB to avoid writing
-- mem_m(idx) all the time e.g. mem_m(idx).h.id
with book_aud(evt_id) as book do -- book_aud is another DDIC that it is not
-- prefixed with mem implies this is not a
-- in memory structure but direct access
-- to a Oracle table book_aud with index
-- evt_id which looks undefined to me and
-- should bring a compiler error
book.upd_pkt( -- method call in the book_aud DDIC
evt_nr => i__nr -- like in PL/SQL named parameters
,ref_nr => msg.h.id
,account_nr => msg.h.id
,status => '1'
);
end with;
end with;
end p;
I could also comment on the other code snippet above but I think you already get out the general concept. Neither mem_m nor book_aud is a known DDIC in the Avaloq version I am working with, wonder where you got it from. Since your post is many years old I suppose this was a very old Avaloq release.

I'm sure that isn't PL/SQL.
I know this doesn't directly answer your question but I might suggest that you go though the list here. It might be listed in here. There are several examples of programs in different programming languages. It may be hard to 100% identify the language unless someone happens to recognize it and finds a "finger print" to prove the language... Do you have more examples you could post?
http://www.ntecs.de/old-hp/uu9r/lang/html/lang.en.html
I don't think that is a functional language. Knowing this might help narrow your search.

The only language I can think of offhand that has "with...end with" syntax is visual basic. Could this be some scripting form of VB?

Related

Is there a way to import multiple enumerands in IBM Rhapsody?

I have an enumerand of around 150 entries, which I need to get into IBM Rhapsody.
Doing this by hand is clearly lengthy and error prone. I have google extensively but found only things that tell me how to edit the generated code -- not go the other way.
The question is: How is this done? And if there is no way -- please someone post that as an answer.
David,
I would jump into the Java API (plugin subsystem) and do it that way. If you haven't learned how to use the API, there is a bit of a learning curve. There are two ways to go about it: Implement a Java (or your favorite JVM language--I use Scala) app that realizes the Rhapsody Plugin framework and then you choose to package it up and deploy it so that it gets loaded when you load your model, or, if it is a one off job, do everything up to the point of packaging it up and then run it from within your IDE and you are done. If you are comfortable with Scala, I can post some code.
So what I did in the end was I edited the relevant .sbs file, used a small python program to generate the items I required, and then update the length of the array accordingly.
all_the_literals = ["enum_name = 0x4e", enum_name2 = 0xF2", ... ,]
for field1, waste, field1_value in map(lambda x: x.split(" "),
all_the_literals):
literal_string = f""" {{ IEnumerationLiteral
- _id = GUID {uuid.uuid4()};
- _name = \"{field1}\";
- codeUpdateCGTime = 5.16.2022::19:24:18;
- _modifiedTimeWeak = 5.16.2022::19:24:18;
- _value = \"{field1_value}\";
}}"""
print(literal_string)
Note the above "code" snippet purely prints the items, which you then copy-paste into the relevant field in the sbs file. YMMV -- this was the correct format for an enum in Rhapsody (and note how I fudged the update time, but it worked successfully, so you'll need to do the same if you use this answer).
Also note it's probably better to use bauhaus9's answer, but I definitely didn't have time for it.

type object alternatives in plsql

I don't have a lot of knowledge about PL/SQL, I did this script using a type object:
CREATE OR REPLACE TYPE num_array is table of NUMBER:
/
DECLARE
jobTypeId NUMBER;
jobs num_array:= num_array();
BEGIN
//some code
This code work fine, but now I don't have privilegies to create a type, then i am searching some alternative but how I said prviously I am not an expert about PL/SQL.
Any idea???
Thanks for your time and sorry for my english,It is not my native languaje.

File Exists and Exception Handling in U-Sql

Two questions
How to check file exists or not before EXTRACT?
we have scenario where new inputs file is generated every day for catalog data. we need to merge new input with d-1 file. before merge we what to make sure that new input file exists at source location
does u-sql supports try...catch block?
Regarding checking if a file exists. We recently released a compile-time IF statement that indeed can check for partition existence (and other objects such as files and tables are on the roadmap).
Once that feature is released (still one or two refreshs out at the time of this answer) it may look something like (syntax subject to change):
IF FILE.EXISTS("/mydir/myfile.csv") THEN
#data = EXTRACT ... FROM "/mydir/myfile.csv" USING ...;
...
#jobstate = SELECT * FROM (VALUES("job completed")) AS T(status);
ELSE
#jobstate = SELECT * FROM (VALUES("file not ready. Job not executed.")) AS T(status);
END;
OUTPUT #jobstate TO "/jobs/myjobstate.csv" USING Outputters.Csv();
You will be able to provide the name as a parameter as well. Please let me know if that will work for your scenario.
An other alternative is to use the file set syntax, especially if you want to use a dynamic value to determine the process. That would simply create an empty rowset:
#data = EXTRACT ..., date DateTime
FROM "/mydir/{date:yyyy}/{date:MM}/{date:dd}/data.csv"
USING ...;
#data = SELECT * FROM #data WHERE date == DateTime.Now.AddDays(-1);
... // continue processing #data that is empty if yesterday's file is not yet there
Having said that, you may want to check of your job orchestration framework (such as ADF) may be a better place to check for existence before submitting the job in the first place.
As to the try catch block: U-SQL itself is a script-level optimizable, declarative language where the plan gets generated and optimized at runtime over the whole script. Thus providing a dynamic TRY-CATCH is currently not available, since it would severely impact the ability to optimize the script (e.g., you cannot move predicates or column pruning outside of a try-catch block). Also TRY/CATCH can lead to some very hard to understand and debug code, especially if it is used to mimic procedural workflows in an otherwise declarative environment.
However, you can use try/catch inside your C# functions without problems if you need to catch C# runtime errors.
FILE.EXISTS() always returns True when executed locally. However, it works when executing against Azure Data Lake.
Tried MSDN example and the following returns True, True
DECLARE #filepath_good = "/Samples/Data/SearchLog.tsv";
DECLARE #filepath_bad = "/Samples/Data/zzz.tsv";
#result =
SELECT FILE.EXISTS(#filepath_good) AS exists_good,
FILE.EXISTS(#filepath_bad) AS exists_bad
FROM (VALUES (1)) AS T(dummy);
OUTPUT #result
TO "/Output/FileExists.txt"
USING Outputters.Csv();
I have Microsoft Azure Data Lake Tools for Visual Studio version 2.2.5000.0

How to rename a document in MarkLogic?

I have simple task to do but unable to find the exact solutions for this.I have saved a file as abc.xml in MarkLogic.How can i rename the file as some example.xml using XQuery?
Code which I tried:
xquery version "1.0-ml";
xdmp:document-rename ("/aaa.xml","/final.xml");
This is showing an error.
There is no way, that I know of, to change the document URI of an existing document. The only way I can think of is to create a new document with the same content and the new URI, and delete the existing one, in the same transaction.
Where it gets tricky is to make sure to preserve the ownership, the permissions, all the properties, the property document, make sure that the old URI is not used anywhere to link to the existing document, etc.
But usually, the document URI is never really used. You should first considering whether you really need to rename the document, and why.
(Note that saying "this is showing an error" is rarely useful on SO or on mailing lists, if you do not show what the error is.)
Florent is correct, a true 'rename' is not possible, or perhaps not even meaningful. ( analogy - rename a file from one disk to another )
"Move" however is meaningful (copy then delete in a transaction).
Defining "Move" is use case dependent - i.e. what metatdata also needs to 'move' ? permissions? collections ? document properties ? inherited permissions ?
xmlsh (http://www.xmlsh.org) implements a 'rename' (http://www.xmlsh.org/MarkLogicRename) command for the marklogic extension which is really a 'move', with the implemenation borrowed from postings on markmail (http://markmail.org/)
The implementation is the following XQuery - it doesnt do everything you might want and it might do more then you want. YMMV
https://github.com/DALDEI/xmlsh/blob/master/extensions/marklogic/src/org/xmlsh/marklogic/resources/rename.xquery
( it was also written long ago - it is likely to benefit from improvement )
I have working example this works for me.
xquery version "1.0-ml";
declare function local:document-rename(
$old-uri as xs:string, $new-uri as xs:string)
as empty-sequence()
{
xdmp:document-delete($old-uri),
let $permissions := xdmp:document-get-permissions($old-uri)
let $collections := xdmp:document-get-collections($old-uri)
return xdmp:document-insert(
$new-uri, doc($old-uri),
if ($permissions) then $permissions
else xdmp:default-permissions(),
if ($collections) then $collections
else xdmp:default-collections(),
xdmp:document-get-quality($old-uri)
)
,
let $prop-ns := namespace-uri(<prop:properties/>)
let $properties :=
xdmp:document-properties($old-uri)/node()
[ namespace-uri(.) ne $prop-ns ]
return xdmp:document-set-properties($new-uri, $properties)
};
(: function call :)
local:document-rename ("/opt/backup/x.xml","y.xml");
MarkLogic has a tutorial up addressing file renaming (moving):
https://developer.marklogic.com/recipe/move-a-document/
Importantly, it uses the function xdmp:lock-for-update() to prevent modifications to the source file while it is being copied to the target location.
Also, if you are doing a batch renaming you'll want to make sure that each file URI you rename corresponds to a document in the database or you'll get runtime errors.

variable substitution in plpgsql(postgres) REINDEX query

--DROP FUNCTION tempscript();
CREATE OR REPLACE FUNCTION tempscript()
RETURNS integer AS
$BODY$
DECLARE
my_index TEXT;
b integer;
BEGIN
my_index := 'example_index';
RAISE NOTICE '% ', my_index;
reindex index my_index; /* problem with this line , we are not able to pass local variable as paramenter*/
b :=2;
return b;
END;
$BODY$
LANGUAGE
plpgsql VOLATILE
COST 100;
SELECT * from tempscript();
please find my comment in the above code where exactly i am facing the problem.
please let me know the solution or workaround.
Thank you.
Per the user manual, you can only use variables where query parameters are permitted. That doesn't include identifiers and utility statements.
You need to use the PL/pgSQL EXECUTE statement for dynamic SQL.
EXECUTE format('REINDEX %I', my_index);
Separately, if you need to automate REINDEXing then you're almost certainly doing something else wrong. It should not be necessary in most situations. Maybe you've turned autovacuum down too far so it's failing to keep up?
If you're writing a function for a one-off, use a DO block so you don't have to create, execute, and drop the function.

Resources