I have an oracle package with a constant value at the top of PKB file as below
create or replace
PACKAGE BODY GEOHELPER AS
g_SRID pls_integer := 4326;
...
...
For some customers I want to user 4326 and for some 5638. What is the best method to change this value at compile/ release time from a .bat file? I do not want to have two versions of my package. Any ideas?
As stated in the comment, conditional compilation is an option if you are using at least Oracle 10g R2.
In your script used for package recompilation, use the following ALTER to set specific conditional compilation flag which you can use later, during package compilation:
ALTER SESSION SET plsql_ccflags='variable_name:1';
Then, in the package body, use the conditional compilation IF statement:
create or replace
PACKAGE BODY GEOHELPER AS
$IF $$variable_name = 1
$THEN
g_SRID pls_integer := 4326;
$ELSIF $$variable_name = 2
$THEN
g_SRID pls_integer := 5232;
$ELSE
g_SRID pls_integer := 0;
$END
...
Related
I have parent package designed in such a way that
step 1: Data flow task fetches the list of configuration from db and stores in recordset.
step 2: for each loop having child package being called with it's project parameters set with values from previous task.
Now the scenario: if I get 2 records from step 1 then step 2 executes 2 times sequentially. How to execute the step 2 parallely for 2 configurations fetched from step1.
After googling for some amount of time, I copied child execute package task 2 times inside for each loop but the values assignment from previous task to child package parameter is not mapping correctly. Please advise what I am doing incorrectly
Note: I am looking for workaround on Execute package task which calls the copies of child package inside for each loop of parent package to run asynchronously. The child package is generic and requires parameter binding where variable values from parent package is assigned to child package parameter values.So, each copy of child package should be able to fetch different variable value from the list and do parameter binding. Please let me know if this is possible.
Execute package task parameter bindings
In your foreach loop add an execute SQL and add this code and fill the correct info and parameters...
DECLARE #execution_id BIGINT
EXEC [SSISDB].[catalog].[create_execution]
#package_name=N'Package1.dtsx'
, #project_name=N'Project1'
, #folder_name=N'Folder1'
, #use32bitruntime=False
, #reference_id=NULL
, #execution_id=#execution_id OUTPUT
-- Execute the package
EXEC [SSISDB].[catalog].[start_execution] #execution_id
This will kick off the package and NOT wait.
If you have package parameters to set, add this (between create and start) foreach one:
EXEC [SSISDB].[catalog].[set_execution_parameter_value]
#execution_id
, #object_type = 30 -- package parameter
, #parameter_name = N'ParameterName'
, #parameter_value = 1
I'm getting an compilation error, when I try to use validate_conversion in plsql.
Error: PLS-00801: Interner Fehler [*** ASSERT at file pdz2.c, line 5361; The_Exp is null.; TEST__DBNAME__B__2920081[10, 3]]
Line: 10
Text: END;
Funny thing is, this error only occurs if compiled in a package. An MWE is:
CREATE OR REPLACE PACKAGE test IS
PROCEDURE my_VALIDATE_CONVERSION(asNbr VARCHAR2);
END test;
/
CREATE OR REPLACE PACKAGE BODY test IS
PROCEDURE my_VALIDATE_CONVERSION(asNbr VARCHAR2) IS
BEGIN
CASE VALIDATE_CONVERSION(asNbr AS NUMBER, '999999D99', ' NLS_NUMERIC_CHARACTERS = '',.''')
WHEN 1 THEN
DBMS_OUTPUT.PUT_LINE('He');
ELSE
DBMS_OUTPUT.PUT_LINE('Cu');
END CASE;
END;
BEGIN
NULL;
END test;
/
If compiled as standalone procedure my_VALIDATE_CONVERSION it works just fine.
CREATE OR REPLACE PROCEDURE my_VALIDATE_CONVERSION(asNbr VARCHAR2) IS
BEGIN
CASE VALIDATE_CONVERSION(asNbr AS NUMBER, '999999D99', ' NLS_NUMERIC_CHARACTERS = '',.''')
WHEN 1 THEN
DBMS_OUTPUT.PUT_LINE('He');
ELSE
DBMS_OUTPUT.PUT_LINE('Cu');
END CASE;
END;
What's going on here?
Im using:
PL/SQL Developer Version 13.0.6.1911 (64 bit)
Oracle Database 18c Standard Edition 2 Release 18.0.0.0.0
Seems like a bug in the database. I would try upgrading to Oracle 19c or apply the latest patch set to your database. I was able to compile your package in my database (version 19.6.0.0.0) without any errors.
This internal failure for sure will happen with the procedure compilation. The fact that it did not suggests that the compilation of the package was done with PLSQL_DEBUG turned on, and the compilation of the procedure was done without.
When you use this function in package in
Select Validate_Conversion(String AS Number) Into variable From Dual, is compiled successful.
Select Validate_Conversion(p_Oran AS Number) Into IsNumeric From dual; --COMPILED
IsNumeric := Validate_Conversion(p_Oran AS Number); --FAILURE
If Validate_conversion(p_Oran AS Number) = 0 Then --FAILURE
enter image description here
I saw here
that it is possible to manually insert specific fields to the manifest:
name := "project"
version := "2.3.5"
packageOptions := Seq(Package.ManifestAttributes(
("Implementation-Version", "2.3.5")))
I would like to use version directly, without recopying the version number.
Putting version instead of "2.3.5" gives an error. Can I somehow use version directly, without recopying the version number?
Get the value of a setting by calling .value on it like so
packageOptions := Seq(
Package.ManifestAttributes(("Implementation-Version", version.value))
)
In general, value can be called in the following scenarios:
value can only be used within a task or setting macro, such as :=, +=, ++=, Def.task, or Def.setting."
I am trying to create a package in Oracle SQL Developer and want to have a public input parameter that another user can input a date to. I tried the following code -
Create PACKAGE Assignment_1_Pack is
vstartDate date := to_date('&startDate', 'DD/MM/YYYY');
vendDate date := to_date('endDAte', 'DD/MM/YYYY');
END;
When I try to run it I get the following message
Empty package Assignment_1_pack definition (no public members).
I was expecting the window that pops up to prompt for an input but I haven't used packages before so I am not sure what it is I am doing wrong
run set define on;
Use a command create OR REPLACE package Assignment_1_Pack ...
SET DEFINE ON/OFF toggles the substitution variables on or off. Probably the substitution of variables was turned off, so SQLDeveloper doesn't ask for the value
See this for details: https://docs.oracle.com/cd/B19306_01/server.102/b14357/ch12040.htm#sthref2736
SET DEF[INE] {& | c | ON | OFF} Sets the character used to prefix
substitution variables to c.
ON or OFF controls whether SQL*Plus will scan commands for
substitution variables and replace them with their values. ON changes
the value of c back to the default '&', not the most recently used
character. The setting of DEFINE to OFF overrides the setting of the
SCAN variable.
create OR REPLACE package ... prevents from errors in a case when the package has already been created. Simple CREATE PACKAGE xxx command fails if the package already exists. If you create the package for the first time, then all subsequent attempts will fail. Create OR REPLACE ... drops the package if it already exists, and then creates it again, so it newer fails.
I'm trying to get a couple of tasks to be able to call each other, but I don't seem very good with this limited with thing..
I have a spec sctrain-trains.ads
limited with SCTrain.Stations;
with SCTrain.Travellers, SCTrain.Tracks, Ada.Strings.Unbounded;
use SCTrain.Travellers, SCTrain.Tracks, Ada.Strings.Unbounded;
package SCTrain.Trains is
type my_station_access_t is access all Stations.Station;
task type Train is
entry Start(leaving: my_station_access_t; arriving: my_station_access_t);
end Train;
end SCTrain.Trains;
and its .adb
with SCTrain.Stations;
use SCTrain.Stations;
package body SCTrain.Trains is
task body Train is
destination: my_station_access_t;
begin
accept Start(leaving: my_station_access_t; arriving: my_station_access_t) do
destination := arriving;
end Start;
destination.Gogo(1);
end Train;
end SCTrain.Trains;
I found in the documents I've been reading that withing the "circular" package in the body would allow smooth executions, but apparently I still have an invalid prefix in selected component "destination" because dereference must not be of an incomplete type (RM 3.10.1), and those errors stay there even without the with and use in the package body.
I'm sure I'm missing something, possibly something very basic, and I'd really love to know what that is. The problem I'm trying to solve is that the Train needs a signal from the Station to be allowed to leave and still able to communicate its arrival time afterwards.
I'm using the latest GNAT-GPL.
Thank you very much.
edit: adding Station's code
limited with SCTrain.Trains;
with Ada.Calendar, Ada.Strings.Unbounded, Ada.Text_IO;
use Ada.Calendar, Ada.Strings.Unbounded, Ada.Text_IO;
package SCTrain.Stations is
task type Station is
entry Gogo(name_d : Integer := 0);
end Station;
end SCTrain.Stations;
and the body:
with SCTrain.Trains;
use SCTrain.Trains;
package body SCTrain.Stations is
task body Station is
name : Integer;
begin
accept Gogo (name_d : Integer := 0) do
name := name_d;
Put_Line("Station " & Integer'Image(name) & " is alive");
end Gogo;
end Station;
end SCTrain.Stations;
Use limited with in one direction only, and a normal with in the other.
Replace the declaration of destination by
destination: access Stations.Station;
or replace the offending line by
destination.all.Gogo(1);
I don't know whether this is a compiler bug or proper behaviour; it looks suspicious!
Later: I posted a still-more-cut-down example on comp.lang.ada and one of the resident experts agrees that it's a bug; I'll report it to AdaCore.