Why aren't my bind variables working in APEX 19? - oracle-apex

I've been using APEX ever since version 4, and I remember making Classic Reports with queries like "select b, c, d from my_table where a = :P1_A_VALUE"
:P1_A_VALUE might have been created on page 1 as a static value for page item P1_A_VALUE, with a value of say, 'shoes', always set regardless of session state. So, in my report I would have retrieved the b, c, d records from my_table where a = 'shoes'.
When I do this in 19, the app server crashes with a 500 error, and the java crash report in the Tomcat logs is tremendous, though unhelpful.
If I write the query as "select b, c, d from my_table where a = 'shoes', it works fine. If I can somehow write the where clause with a function somehow, like "where a = func(z)", where func(z) returns 'shoes', it also works fine. Only if I use the bind variable :P1_A_VALUE in the query does it break.
Has the behavior of APEX changed in the last couple of releases? I went from 5 to 19, so many things could have happened.
Thanks for any tips.

Related

io.r2dbc.spi.R2dbcBadGrammarException: Duplicate column name "?column?"; SQL statement

I try to test my code with H2 DB. I've some migrations for all steps(init, schema, data). For running my migrations I use nkonev r2dbc-migrate
When I try to run a test I catch an exception "SQL Grammar exception" with means that H2 doesn't work with 'LIMIT". I made some changes
r2dbc:h2:mem:///testdb?options=MODE=PostgreSQL
But it gave me only an other problem:
io.r2dbc.spi.R2dbcBadGrammarException: Duplicate column name "?column?"; SQL statement:
insert into "migrations_lock"(id, locked) select * from (select 1, false) x where not exists(select * from "migrations_lock") [42121-214]
I've tried all dialects like a mode property. I've tried all dialects like a migration dialect. But nothing changed.
What did I make wrong?
Application is: Spring Boot 2.7.5 + WebFlux + Kotlin
My gradle dependencies:
implementation("name.nkonev.r2dbc-migrate:r2dbc-migrate-spring-boot-starter:2.7.8")
implementation("io.r2dbc:r2dbc-pool:0.9.2.RELEASE")
implementation("io.r2dbc:r2dbc-spi:1.0.0.RELEASE")
implementation("io.r2dbc:r2dbc-postgresql:0.8.13.RELEASE")
implementation("io.r2dbc:r2dbc-h2:0.9.1.RELEASE")
When I run the app with PostgreSQL as usual everything works well.
I tried to change a dialect for H2. I thought it can help me with my problem. But PostgreSQL/Oracle didn't help. Oracle has problem with SERIAL and I changed my migrations for solving this problem.
The solution in my case was in changing the position of keyword LIMIT with OFFSET
From
order by v.id asc
offset 0
limit 10
To
order by v.id asc
limit 10
offset 0
This small change gives me an option return back to default H2 setup.

SAS Data Integration issue with empty string showing as "NULL"

I am having an issue with SAS DI.
In certain columns, I would like the empty strings to appear as empty, instead of them being displayed as "NULL".
While they some times appear as empty, once I later run them in SQL, they come up as "NULL". I have attempted to use NUMCHAR variable in SAS DI, but I am not quite sure how to implement it as I am new to this language.
EDIT:
I will try to be more specific. In short, I have a workflow (Job) in SAS DI, where I have a table, I am using the table loader to choose some of the variables (i.e. A, B and C). The aforementioned variables have both values and empty values. On the occasion where an empty value appears, the table entry of that value is saved, although when I load it it shows as "NULL". What I would like to do, is change the workflow (either visually or using a code) to tell SAS DI to show values of columns A and B (but not C) as only empty (rather than "NULL")

Django jumping model id number (AutoField) [duplicate]

This question already has answers here:
Identity increment is jumping in SQL Server database
(6 answers)
Closed 7 years ago.
I have a strange scenario in which the auto identity int column in my SQL Server 2012 database is not incrementing properly.
Say I have a table which uses an int auto identity as a primary key it is sporadically skipping increments, for example:
1,
2,
3,
4,
5,
1004,
1005
This is happening on a random number of tables at very random times, can not replicate it to find any trends.
How is this happening?
Is there a way to make it stop?
This is all perfectly normal. Microsoft added sequences in SQL Server 2012, finally, i might add and changed the way identity keys are generated. Have a look here for some explanation.
If you want to have the old behaviour, you can:
use trace flag 272 - this will cause a log record to be generated for each generated identity value. The performance of identity generation may be impacted by turning on this trace flag.
use a sequence generator with the NO CACHE setting (http://msdn.microsoft.com/en-us/library/ff878091.aspx)
Got the same problem, found the following bug report in SQL Server 2012
If still relevant see conditions that cause the issue - there are some workarounds there as well (didn't try though).
Failover or Restart Results in Reseed of Identity
While trace flag 272 may work for many, it definitely won't work for hosted Sql Server Express installations. So, I created an identity table, and use this through an INSTEAD OF trigger. I'm hoping this helps someone else, and/or gives others an opportunity to improve my solution. The last line allows returning the last identity column added. Since I typically use this to add a single row, this works to return the identity of a single inserted row.
The identity table:
CREATE TABLE [dbo].[tblsysIdentities](
[intTableId] [int] NOT NULL,
[intIdentityLast] [int] NOT NULL,
[strTable] [varchar](100) NOT NULL,
[tsConcurrency] [timestamp] NULL,
CONSTRAINT [PK_tblsysIdentities] PRIMARY KEY CLUSTERED
(
[intTableId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
and the insert trigger:
-- INSERT --
IF OBJECT_ID ('dbo.trgtblsysTrackerMessagesIdentity', 'TR') IS NOT NULL
DROP TRIGGER dbo.trgtblsysTrackerMessagesIdentity;
GO
CREATE TRIGGER trgtblsysTrackerMessagesIdentity
ON dbo.tblsysTrackerMessages
INSTEAD OF INSERT AS
BEGIN
DECLARE #intTrackerMessageId INT
DECLARE #intRowCount INT
SET #intRowCount = (SELECT COUNT(*) FROM INSERTED)
SET #intTrackerMessageId = (SELECT intIdentityLast FROM tblsysIdentities WHERE intTableId=1)
UPDATE tblsysIdentities SET intIdentityLast = #intTrackerMessageId + #intRowCount WHERE intTableId=1
INSERT INTO tblsysTrackerMessages(
[intTrackerMessageId],
[intTrackerId],
[strMessage],
[intTrackerMessageTypeId],
[datCreated],
[strCreatedBy])
SELECT #intTrackerMessageId + ROW_NUMBER() OVER (ORDER BY [datCreated]) AS [intTrackerMessageId],
[intTrackerId],
[strMessage],
[intTrackerMessageTypeId],
[datCreated],
[strCreatedBy] FROM INSERTED;
SELECT TOP 1 #intTrackerMessageId + #intRowCount FROM INSERTED;
END

Oracle Pro*C for insert with a sub select query causing ORA-01403: no data found

I am using C++ code with embedded Pro*C (Version: 11.2.0.3.0) for Oracle DB. I am running a bulk insert clause as below:
insert int TBL1 (col1, col2)
select a.col1, b.col2 from TBL2 a, TBL3 b
where a.col1 = :v and a.col2 = b.col2
I run this query for a set of records to be inserted, and binding values for :v in place.
However, while some records could be inserted, some failed with
ORA-01403: no data found
I see from sqlca.sqlerrd[2], the number of rows that could be inserted. So, I know M out N records could be inserted. Now, I would like to know which records did fail, so I need a clue of list of all a.col1 values that could cause this failure.
Is there any way out? Any clue or direction would be very helpful.
This is a bit long for a comment.
The error you are referencing is a PL/SQL error, documented here. This is not an error that an insert would normally produce.
My one guess is that the table has an insert trigger and this trigger is causing the problem.
It is also possible that your code is in a larger block, and something else in the block is causing the error.

Web Service returning a null dataset occasionally

I am having the most frustrating problem, basically I have a website and a webservice running on the same server. Both use ADO.net to connect to data tables using a couple of custom calls I have created myself, the website has never had a problem with connecting to a particular proc to return data, however the webservice, once in say every 100 calls to that proc, returns an empty dataset even though it should have come back populated and does in a query in SQL Mgmt Studio. The weird thing is it works most times, but on the odd occasion returns this error:
System.IndexOutOfRangeException: Cannot find table 0. at System.Data.DataTableCollection.get_Item(Int32 index)
Dim SQLCmd As SqlCommand = CreateSPCommand("VerifyCredentialsSP")
SQLCmd.Parameters.AddWithValue("#Password", Credentials.Password)
GetData(SQLCmd)
ds.DataSetName = "Customer"
If ds.Tables(0) IsNot Nothing Then
ds.Tables(0).TableName = "Customer"
End If
One way to do this is to catch the exception being thrown, but the better method is to check for null or nothing in your case.
Do not access the index ds.Tables(0)....
Do a check if your dataset ds is null before accessing it like so:
If ds IsNot Nothing then
'only then can you index ds.
end if
In this way you avoid a lookup on the index of your dataset given that it contains some valid reference. In your method you are accessing Tables(0) which may or may not exist, without a valid check your code could potentially throw an exception, and in this case it has!