how the 'tmpdata' and 'Get_Parameter_List' works in OracleForm? - oracle

I am new in OracleForms and Plsql, i found this code in a proyect:
PROCEDURE grabar IS
...
Pl_id paramlist;
...
BEGIN
pl_id := Get_Parameter_List ('tmpdata');
IF NOT Id_Null(pl_id) THEN
Destroy_Parameter_List( pl_id );
END IF;
pl_id := Create_Parameter_List('tmpdata');
i want to konw that if 'tmpdata' does not exist i will get an error?
whit the line:
pl_id := Get_Parameter_List ('tmpdata');
am i inserting the data of 'tmpdata' in 'PL_id'
it is the 'tmpdata' a default variable of Oracleforms or something?
it is not OracleForms but it is a tool based in it so is so similar
I proved to change to:
pl_id := Get_Parameter_List ('tmpdata_HELLO');
enter code hereand the program passed to of this
the console show me this:
may 25, 2018 4:46:30 PM org.apache.tomcat.util.http.Parameters processParameters
INFORMACIÓN: Character decoding failed. Parameter [value] with value [%null] has been ignored. Note that the name and value quoted here may be corrupted due to the failed decoding. Use debug level logging to see the original, non-corrupted values.
Note: further occurrences of Parameter errors will be logged at DEBUG level.

In this example, "tmpdata" is the name of a parameter list that may or may not exist. The "ID_NULL" is checking for the existence of the parameter list by checking of the ID returned has a value or not. If it has a value (ie, ID_NULL returns FALSE), then the parameter list is destroyed so that the "Create_Parameter_List" command will not get an error.
"Get_Parameter_List" will not throw an error if there is no parameter list by the given name ("tmpdata", in this case); it just returns null.

Related

Inno Setup to modify key values in app.config file while running setup.exe

I need to change the values of some keys in app.config file. I'm planning to use Inno Setup for this task.
I have found excellent tips of using XML parser and xpath selectors in this kind of tasks. However, I don't know what path to use to point to the key & value I want to change.
My app.config looks approximately like this:
<configuration>
<runtime>
</runtime>
<appSettings>
<add key="DefaultUrl" value="http://localhost/Some_application"/>
</appSettings>
</configuration>
So, I want to access the key "DefaultUrl" and change it's "value". How to point there?
$x("//configuration/appSettings[#key='DefaultUrl']")
doesn't seem to be correct since it returns nothing.
EDIT after Mirtheil's comment:
To change the key values I use this procedure:
procedure SaveAttributeValueToXML(const AFileName, APath, AAttribute,
AValue: string);
var
XMLNode: Variant;
XMLDocument: Variant;
begin
XMLDocument := CreateOleObject('Msxml2.DOMDocument.6.0');
try
XMLDocument.async := False;
XMLDocument.load(AFileName);
if (XMLDocument.parseError.errorCode <> 0) then
MsgBox('The XML file could not be parsed. ' +
XMLDocument.parseError.reason, mbError, MB_OK)
else
begin
XMLDocument.setProperty('SelectionLanguage', 'XPath');
XMLNode := XMLDocument.selectSingleNode(APath);
XMLNode.setAttribute(AAttribute, AValue);
XMLDocument.save(AFileName);
end;
except
MsgBox('An error occured!' + #13#10 + GetExceptionMessage,
mbError, MB_OK);
end;
end;
I call it
SaveAttributeValueToXML(Some_Application.exe.config', '//configuration/appSettings[#key=''DefaultUrl'']', 'value', 'https://Server_Name/Other_Application');
This call generates an exception on line
XMLNode.setAttribute(AAttribute, AValue);
Exception message: "Variant is null, cannot invoke"
EDIT 2:
I found the answer. Calling
SaveAttributeValueToXML(Some_Application.exe.config', '//configuration/appSettings/add[#key=''DefaultUrl'']', 'value', 'https://Server_Name/Other_Application');
changes the value of key "DefaultUrl".
I found the answer.
$x("//configuration/appSettings/add[#key='DefaultUrl']")
returns the node I want.

Can't remove Null terminator from byte array?

I'm using this library in Go (on OSX) to interact with a windows DNS server.
When running the below snippet, I get an error about a null terminator.
$ ~/go/bin/winrm-dns-client create -d domain.com -n node-0 -t A -v 10.90.61.30
2018/06/03 12:40:22 Error creating DNS record: Reading record: Reading record: Unmarshalling response: Unmarshalling json: invalid character '\x00' after array element
My suspicion is that there's a null terminator added here when the helper method calls sprintf to concat json responses into an array.
However, even after adding a bytes.Trim like shown below... I still get a null terminator error and it seems that the null terminator still exists...
func unmarshalResponse(resp string) ([]interface{}, error) {
var data interface{}
byteRespTrim := []byte(resp)
fmt.Print("found a null terminator at -- ")
fmt.Println(bytes.Index(byteRespTrim, []byte("\x00")))
fmt.Print("total length = ")
fmt.Println(len(byteRespTrim))
byteRespTrim = bytes.Trim(byteRespTrim, "\x00")
fmt.Print("after trim found a null terminator at -- ")
loc := bytes.Index(byteRespTrim, []byte("\x00"))
fmt.Print(loc)
When calling I get the below
(master)⚡ % ./windows-dns-test create -d domain.com -n openshift-node-0 -t A -v 10.90.61.30
found a null terminator at -- 2102
total length = 2615
after trim found a null terminator at -- 2102
From your logs, the offending character seems to be found at position 2102, while the whole array has 2615 elements.
So it looks Trim won't solve it since the problem is not necessarily the final character of the array.
Did you try removing all occurrences, using Replace for example?
byteRespTrim = bytes.Replace(byteRespTrim, []byte("\x00"), []byte{}, -1)

How to know what node is not valid with XMLTYPE

Here is the code to validate an xml file in PL_SQL using XMLTYPE
doc := dbms_xmldom.newdomdocument;
... xml file is build
v_xml:=DBMS_XMLDOM.GETXMLTYPE(doc);
v_schema:=v_xml.createSchemaBasedXML('xml.xsd');
BEGIN
v_schema.schemavalidate();
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('XML File is not valid');
END;
Is there way to know where the file is not valid, what node ?
Thank you
Note : the exception hidden that way is this one :
ORA-31154: invalid XML document
ORA-19202: Error occurred in XML processing
LSX-00333: literal "" is not valid with respect to the pattern
dbms_utility.format_error_stack is providing more error details, including LSX error messages, which gives you the type of validation error, like
dbms_output.put_line( dbms_utility.format_error_stack);
ORA-31154: invalid XML document
ORA-19202: Error occurred in XML processing
LSX-00220: "" is wrong length, should be 12
ORA-06512: at "SYS.XMLTYPE", line 354

Executing SQL Script using OSQL do not return resultcode

I am executing some sql queries using OSQL through inno setup. I am using following code to run OSQL. This is just for example purpose
SQLQuery:= '"EXEC sp_addserver ''PCNAME'';"';
Param:= '-S(local) -Usa -Psa -Q ' + SQLQuery;
Exec('osql.exe', Param, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
This works fine. The problem is ResultCode value is always 0. Even if the query does not get executed. For example if I try same query like below where I pass in an invalid stored procedure name the ResultCode is still 0.
SQLQuery:= '"EXEC sp_invalidname ''PCNAME'';"';
Param:= '-S(local) -Usa -Psa -Q ' + SQLQuery;
Exec('osql.exe', Param, '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
Why don't this return me a proper code. If I run the second query in management studio I get an error like this
Msg 2812, Level 16, State 62, Line 1
Could not find stored procedure 'sp_invalidname'
Here return code is 2812. Why dont I get this when I run it through inno. What do I need to do to get this error code in inno?
Thanks to TLama, I updated my code as below and its working now. I had to add -b command line parameter and now it returns 1 if the command fails.
-b
Specifies that osql exits and returns a DOS ERRORLEVEL value when an error occurs. The value returned to the DOS ERRORLEVEL variable is 1 when the SQL Server error message has a severity of 11 or greater; otherwise, the value returned is 0. Microsoft MS-DOS batch files can test the value of DOS ERRORLEVEL and handle the error appropriately.
I updated my code as below.
Param:= '-S(local) -Usa -Psa -b -Q ' + SQLQuery;
Its explained in the documentation.

How to solve distinct-values error

How to solve this error in XQuery. I want the data to be distinct with out duplication in XML result. I tried to add distinct-values in front of the doc in for statement, but this error was depicted.
Engine name: Saxon-PE XQuery 9.5.1.3
Severity: fatal
Description: XPTY0019: Required item type of first operand of '/' is node(); supplied value has item type xs:anyAtomicType
Start location: 23:0
URL: http://www.w3.org/TR/xpath20/#ERRXPTY0019
This is code :
for $sv1 in distinct-values(doc('tc.xml')//term/year)
let $sv2 := doc('tc.xml')//term[year= $sv1]
let $sv3 := doc('tc.xml')//student[idStudent= $sv1/idStudent](:HERE IS THE ERROR LINE:)
let $sv4 := doc('tc.xml')//program[idStudent= $sv3/idStudent]
return
<Statistics>
{$sv1 }
<Count_Student>{count($sv2)}</Count_Student>
<a50_60>{count(doc('tc.xml')/mydb//program[doc('tc.xml')/mydb//term/year =$sv1][avg>= 50 and avg < 60])}</a50_60>
</Statistics>
thank you in advance.
distinct-values() will atomize your input, this means that $sv1/idStudent won't work because $sv1 is not an element. Instead of using $sv1 on the line that give an error I think you should be using $sv2.

Resources