Will Oracle SQL Developer version 19.2 and Oracle APEX version 4.2 support each other when making changes to application? - version

My query in SQL Developer is executing fine, but when I implement in APEX, the application won't even run. So just wondering if Developer version and APEX version are compatible.

There is no relationship between SQL Developer and your APEX application, at least as far as the scenario you're describing.
It would help to show your query, show your application not running, i.e. error messages encountered when running the query.
If you wanted, you could test the query in the APEX SQL Workshop.
SQL Developer runs its queries through a jdbc driver as a client application. APEX SQL runs inside the database via stored procedures.

Based on a comment you posted: what you executed in Apex' SQL Workshop is an anonymous PL/SQL block.
By the way, what is a? You never declared it.
How to transform it to a function? For example:
create or replace function f_test (a number)
return varchar2 is
begin
return case when a < 10 or a > 57 then 'Value is not in valid range'
else null
end;
end;
/
Call it as e.g. (in function's body)
return f_test(:P1_DEPTNO);
Aha, yet another comment: that is supposed to be a validation. Its type should be "PL/SQL function returning error text":
return case when :P1_DEPTNO < 10 or :P1_DEPTNO > 57
then 'Value is not in valid range'
else null
end;

Related

ColdFusion 9.01 -> Lucee 5.3.3.62 and <cfinsert> / <cfupdate>

I’ve inherited a big application which is running on CF 9.01.
I’m in the process to port it to Lucee 5.3.3.62, but have some problems with and
I know that I should replace it with , but this application has ~1000 source files (!!), and replacing all those tags is currently not obvious for timing reasons.
Lucee is throwing errors like:
“An object or column name is missing or empty. For SELECT INTO
statements, verify each column has a name. For other statements, look
for empty alias names. Aliases defined as “” or are not allowed.
Change the alias to a valid name.”
At first, I thought there were problems with date field, because Lucee is handling them differently than CF 9.01, but this is not the case.
So, I created a test table (on MS-SQL Server 2008R2):
CREATE TABLE [dbo].[LuceeTest01](
[Field1] [nvarchar](50) NULL,
[Field2] [nvarchar](50) NULL ) ON [PRIMARY]
In Lucee, I’m using as datasource: Microsoft SQL Server (Vendor Microsoft), called “one”
This is my test application:
<cfset Form.Field1 = "Field1">
<cfset Form.Field2 = "Field2">
<cfoutput>
<cfinsert datasource="one"
tablename="LuceeTest01"
formfields="Field1, Field2">
</cfoutput>
When I run this, I get the same error. Any idea why?
Full trace here: https://justpaste.it/6k0hw
Thanks!
EDIT1:
Curious. I tried using “jTDS Type 4 JDBC Driver for MS SQL Server and Sybase” as datasource driver, and now the error is:
The database name component of the object qualifier must be the name
of the current database.
This traces back to this statement:
{call []..sp_columns 'LuceeTest01', '', '', 'null', 3}
When I try this in the Microsoft SQL Server Management Studio, I get the same error.
However, when I specify the database name (‘one’ as third argument), no error in MS SQL SMS.
EXEC sp_columns 'LuceeTest01', '', 'one', 'null', 3
Shouldn’t Lucee take this argument from the datasource configuration or something?
EDIT2:
As suggested by #Redtopia, when "tableowner" and "tablequalifier" are specified, it works for the jTDS driver. Will use this as workaround.
Updated sample code:
<cfset Form.Field1 = "Field1">
<cfset Form.Field2 = "Field2">
<cfinsert datasource="onecfc"
tableowner="dbo"
tablename="LuceeTest01"
tablequalifier="one"
formfields="Field1,Field2">
EDIT3:
Bug filed here: https://luceeserver.atlassian.net/browse/LDEV-2566
I personally would refactor CFINSERT into queryExecute and write a plain InsertInto SQL statement. I wish we would completely remove support for cfinsert.
Consider using
<cfscript>
Form.Field1 = "Field1";
Form.Field2 = "Field2";
// Don't forget to setup datasource in application.cfc
QueryExecute("
INSERT INTO LuceeTest01 (Field1, Field2)
VALUES (?, ?)
",
[form.field1, form.field2]
);
</cfscript>
I am 99% confident that this is a Lucee / JDK / JDBC Driver bug and not a fault in your config.
Source:
I initially suspected some low-hanging fruit such as your leading whitespace in ' Field2'. Then I saw your comment showing that you had tried with that trimmed and your Edit1 with the different error when using a different DB Driver. So I set to work trying to reproduce your issue.
On Lucee 5.2.4.37 and MS SQL Server 2016, armed with your sample code and two new datasources - one each for jTDS (MSQL and Sybase) driver and Microsoft SQL Server (JDBC4 - Vendor Microsoft) on SQL, I was unable to reproduce either issue on either driver. Even when selectively taking away various DB permissions and changing default DB for the SQL user, I was still only able to force different (expected) errors, not your error.
As soon as I hit the admin update to Lucee 5.3.3.62 and re-ran the tests, boom I hit both of your errors with the respective datasources, with no other change in DB permissions, datasource config or sample code.
Good luck convincing the Lucee guys that this anecdotal evidence is proof of a bug, but give me a shout if you need an extra voice. Whilst I don't use cfinsert/cfupdate in my own code, I have in the recent past been in the position of supporting a legacy CF application of similar sounding size and nature and empathise with the logistical challenges surrounding refactoring or modernising it!
Edit:
I tried the tablequalifier suggestion from #Redtopia in a comment above. Adding just the tablequalifier attribute did not work for me with either DB driver.
Using both tablequalifier="dbname" and tableowner="dbo" still didn't work for me with the MS SQL Server driver, but does seem to work for the jTDS driver, so it's a possible workaround meaning changing every occurrence of the tag, so ideally the Lucee guys will be able to fix the bug from their end or identify which Java update broke it if Lucee itself didn't.

What does 'infinite' mean in MS Access query

I am trying to re-make some Access queries using SSMS. I ran across the below statement and I am a bit confused. it uses the term 'infinite' and I have never seen that in Access. Any help?
Code:
Bal: IIf([Infinite]<1,0,[infinite])
It's referring to a field in the database named "Infinite" (or "infinite").
What it's trying to do is return 0 if [Infinite] is less than 1, and return the actual value if it's not less than 1.
However if your SQL Server is set to case sensitive collation, the statement will fail because Infinite <> infinite

Moving IF statement from Crystal Reports to SQL Server Management Studio

Background: I have an IF statement from Crystal Reports XI and would like to transfer/translate it to SQL Server Management Studio 2012 as a CASE statement. I understand IF/CASE statements, but I'm having trouble understanding this one- one section in particular. I looked everywhere on this site and the web and could not find a similar situation.
Question: I want to take the IF statement below and change the format to run correctly in SQL Server Management Studio 2012. The part I do not understand are the comma’s after tblLin.QtyShipped. To me that seems like an extra argument is trying to be performed…maybe like a SUMIF? The IF statement from Crystal is a “Formula Field”.
This is the original code from Crystal Reports:
IF {tblProd.UnitsInABox} > 0
THEN Sum {tblLin.QtyShipped}, ({tblProd.ProdNumb}/{tblProd_1.Servings})
ELSE Sum {tblLin.QtyShipped}, ({tblProd.ProdNumb})/{tbl.WProd.MstrQuantity})
END AS QtyShipped
This is what I've got for (SQL Server Management Studio) which is wrong, but showing effort.
CASE
WHEN (tblProd.UnitsInABox) > 0
THEN Sum(tblLin.QtyShipped), (tblProd.ProdNumb/tblProd_1.Servings)
ELSE Sum(tblLin.QtyShipped), (tblProd.ProdNumb/tbl.WProd.MstrQuantity)
END AS QtyShipped
Thank you and please let me know if I didn't follow any specific rules for posting.
You can't handle two columns at the same time, so you have to take the first column out of the case statement.
Sum(tblLin.QtyShipped) AS QtyShipped
,CASE
WHEN (tblProd.UnitsInABox) > 0
THEN (tblProd.ProdNumb/tblProd_1.Servings)
ELSE (tblProd.ProdNumb/tbl.WProd.MstrQuantity)
END

DSN-less Connection MS Access front end and SQL server backend

I don't normally program in MS Access VBA so forgive my question if it's stupid.
So I'm using MS Access 2010 as a front end and SQL Server 2014 as a backend. (I don't have a choice in frontend interface so please no suggestions on alternate options).
I'd like to programatically link SQL server's backend to my MS Access frontend. I read here at DJ Steele's DSN-less connection page that I can use the code he provided here to make a DSN-less connection to SQL server as a backend.
So I copied that into a VBA Access module and opened another module and ran this code to run the DJ Steele code in an attempt to connect to a small SQL Server database I made:
Option Compare Database
Sub runThis()
FixConnections "AServerNameHere", "MS_Access_BackEnd_Test"
End Sub
As far as I can tell from the VBA debugger it gets to
Set dbCurrent = DBEngine.Workspaces(0).Databases(0)
then that value seems to be empty. I'm not sure how else to proceed with this since as far as I was able to find this is one of the few full examples of a DSN-less connection I could find.
I'd like to not use the DSN method of linking a SQL server to a database since that would require me to go visit people and their computers in order to make the links. (And who'd want to to that? LOL)
I've also looked at similar questions that were linked to me while writing this question and this was close to what I wanted, but it kept giving me "Compile error: Constant expression required" for input of:
LinkTable "MS_Access_BackEnd_Test", "Table_1"
and
LinkTable "MS_Access_BackEnd_Test", "Table_1", , "AServerNameHere"
Again I'm not familiar with MS Access VBA so forgive the question if it's lame.
Looking at DJ Steele's code, I got it working apart from the line
' Unfortunately, I'm current unable to test this code,
' but I've been told trying this line of code is failing for most people...
' If it doesn't work for you, just leave it out.
tdfCurrent.Attributes = typNewTables(intLoop).Attributes
which I had to comment out.
Using Set dbCurrent = CurrentDb() does essentially the same thing as Set dbCurrent = DBEngine.Workspaces(0).Databases(0) but the latter is meant to be a lot faster ... which these days means it takes 10 microseconds instead of 100 :-o
You still need dbCurrent as a reference to the current Access front end which is where the linked table objects live, even if the data is coming from elsewhere.
Edit: working for me
I added a debug.print line to monitor what's going on
' Build a list of all of the connected TableDefs and
' the tables to which they're connected.
For Each tdfCurrent In dbCurrent.TableDefs
Debug.Print tdfCurrent.Name, tdfCurrent.Connect
If Len(tdfCurrent.Connect) > 0 Then
If UCase$(Left$(tdfCurrent.Connect, 5)) = "ODBC;" Then
...
and then
? currentdb().TableDefs("dbo_Person").Connect
ODBC;DSN=TacsData;APP=Microsoft Office 2003;WSID=TESTXP;DATABASE=TacsData;Trusted_Connection=Yes;QuotedId=No
FixConnections "TESTXP\SQLEXPRESS", "TacsData"
MSysAccessObjects
MSysAccessXML
...
MSysRelationships
Table1
dbo_Person ODBC;DSN=TacsData;APP=Microsoft Office 2003;WSID=TESTXP;DATABASE=TacsData;Trusted_Connection=Yes;QuotedId=No
? currentdb().TableDefs("dbo_Person").Connect
ODBC;DRIVER=sql server;SERVER=TESTXP\SQLEXPRESS;APP=Microsoft Office 2003;WSID=TESTXP;DATABASE=TacsData;Trusted_Connection=Yes

PowerBuilder not storing error message from SQL Server Properly

I seem to be experiencing a strange issue when using the SqlErrText from a DataWindow in our application.
The DataWindow executes a stored procedure, lets call it vp_ut_storedProc, and in my case it throws an error when the DataWindow is updated.
When I go into the function to build the error message for our application, the SqlErrText is passed in as follows (as parameter asErrText):
SQLSTATE = 42000
Microsoft SQL Server Native Client 10.0
TimestampNV|Someone Has Updated the Record. Please Refresh.
No changes made to the database
execute dbo.vp_ut_storedProc
I know that PowerBuilder receives the entire error text which is a good thing. But, when we try to save the error text into a local variable
isErrText = asErrText
The value of isErrText is: SQLSTATE = 42000
So, for some reason, it completely ignores everything after the second line. I figure it has something to do with the way the PowerBuilder is reading in the string, but I don't know why this happens.
I should also note that it's not just limited to this one DataWindow. It happens on quite a few of them.
put this in your dberror event of your datawindow
string s_temp
long l_start, l_end
l_start = 42 +Pos(sqlerrtext,'Microsoft SQL Server Native Client 10.0')
l_end = Pos(sqlerrtext,sqlsyntax) - l_start - 3
IF l_end <=0 THEN l_end = Len(sqlerrtext) - l_start
s_temp = Mid(sqlerrtext,l_start,l_end)
fw_msg(s_temp) //can write this at messagebox(this.title,s_temp) // instead
RETURN 1
if its insert or select error. it ignores the syntax and outputs the error. if its a different error. it shows the rest of the errcode

Resources