Apex not accepting 0x00000000 - apex-code

In Java I can write the following statement:
Integer data = 0x00000000;
But in Apex the same line of code gives me the following error:
Error: Compile Error: expecting a semi-colon, found 'x00000000'
What am I doing wrong?

It appears that Apex Code does not allow hexadecimal integer literals. Integer data = 0; should accomplish what you're looking for.

Related

Getting exception while trying to execute a Pig Latin Script

I am learning Pig on my own and while trying to explore a dataset I am encountering an exception. What is wrong in the script and why:
movies_data = LOAD '/movies_data' using PigStorage(',') as (id:chararray,title:chararray,year:int,rating:double,duration:double);
high = FILTER movies_data by rating > 4.0;
high_rated = FOREACH high GENERATE movies_data.title,movies_data.year,movies_data.rating,movies_data.duration;
DUMP high_rated;
At the end of the MAP Reduce execution I am getting the below error.
2018-07-22 20:11:07,213 [main] ERROR org.apache.pig.tools.grunt.Grunt
ERROR 1066: Unable to open iterator for alias high_rated.
Backend error : org.apache.pig.backend.executionengine.ExecException:
ERROR 0: Scalar has more than one row in the output.
1st : (1,The Nightmare Before Christmas,1993,3.9,4568.0),
2nd :(2,The Mummy,1932,3.5,4388.0)
(common cause: "JOIN" then "FOREACH ... GENERATE foo.bar" should be "foo::bar" )
First, let's see how we can fix your problem. You don't need to access your fields using the alias name. Your third line could be simply:
high_rated = FOREACH high GENERATE title, year, rating, duration;
If you wanted to use the alias name for some reason you should use the referential operator (::) as can be seen in the ERROR suggestion. Then your line would look like:
high_rated = FOREACH high GENERATE movies_data::title, movies_data::year, movies_data::rating, movies_data::duration;
Next, let's try to understand the exact reason behind the error message. When you try to access the fields using a dot operator (.), pig will assume that the alias is a scalar (alias having only one row). Since your alias had more than one row, it complained. You can read more about scalars in Pig here: https://issues.apache.org/jira/browse/PIG-1434
In the JIRA's release notes section, you will notice at the end, the expected error message matches the error you are getting:
If a relation contains more than single tuple, a runtime error is generated:
"Scalar has more than one row in the output"
this works for you without error.
movies_data = LOAD '/movies_data' using PigStorage(',') as (id:chararray,title:chararray,year:int,rating:double,duration:double);
high = FILTER movies_data by rating > 4.0;
high_rated = FOREACH high GENERATE title,year,rating,duration;
DUMP high_rated;
The FILTER command to allowed all the column records which are satisfy the filter condition.

Laravel Excel Formula Error: Unexpected operator '='

I am using Laravel Excel Maatwebsite package. When I try to read to excel I am getting this error:
Formula Error: Unexpected operator '='
How can disable read formula in this package.I want to only get field value from excel ?
Thanks
According to the documentation you can enable / disable calculating formulas like this:
// Enable calculation
$reader->calculate();
// Disable calculation
$reader->calculate(false);

ORA-01460: unimplemented or unreasonable conversion requested

When I run the following .Net code:
using (var c = Shared.DataSources.BSS1.CreateCommand())
{
c.CommandText = "\r\nSelect c1, c2, c3, rowid \r\nFrom someSpecificTable \r\nWhere c3 = :p0";
var p = c.CreateParameter() as Oracle.DataAccess.Client.OracleParameter;
c.Parameters.Add(p);
p.OracleDbType = Oracle.DataAccess.Client.OracleDbType.Varchar2;
p.DbType = System.Data.DbType.AnsiString;
p.Size = 20;
p.Value = "007";
p.ParameterName = ":p0";
using (var r = c.ExecuteReader())
{
r.Read();
}
}
I get the following error:
ORA-01460: unimplemented or unreasonable conversion requested
ORA-02063: preceding line from XXX
This is not my database, and I don't have control over the select statements that I get, that table IS from a database link.
The funny thing is that if I add the following code just before the ExecuteReader it runs fine.
c.CommandText = c.CommandText.Replace("\r\n", " ");
Unfortunately that is not a good solution in my case as I can't control to SQL nore can I change it that way.
As for the table itself, the columns are:
c1 Number(5)
c2 varchar2(40)
c3 varchar2(20).
I know that ORA-02063 that comes after indicate something about a database link, but I looked in the synonim table and it didn't come from any database_link, and also I don't think that \r\n should affect database link.
I tried running the query without bound parameters, and it did work - but again bad practice to do so in a general term.
The trouble is that a competing tool that is not .Net based, is working and thus it's not a general problem.
I also couldn't reproduce the problem in my own environment, this is a customer database and site.
I am using instant client 11.1.6.20 and also tested it with instant client 11.2.3.0
The db is 10 and the db link is to an oracle v8 database
Any help would be appreciated
This problem can be recreated with straight forward steps. That is, any SQL query having a string literal, in where clause, more than 4000 characters in length gives an error "ORA-01704: string literal too long"
But, when the same query is executed through JDBC it gives "ORA-01460: unimplemented or unreasonable conversion requested"
Finally I found the answer!!!
After investigating and reflecting into the code I found that by changing the Direction of the Parameter to input output - the problem was resolved.
p.Direction = ParameterDirection.InputOutput;
After much investigation I found out that it's all about the fact that we have bound parameters that are used from ODP.NET and targeting tables from a DBLINK to a V8 Oracle server.
Once I eliminated the bound parameters it all worked.
It was a while back, but I think it's had something to do with varying string lengths of the strings sent to the bound parameter.
It seems that it ignored the size property, so if in the first query I sent a string with length 10 and in the second string I sent a string with length 12, I'll get that error.
I also found the oracle articles about it :
https://community.oracle.com/thread/2460796?tstart=0
and the patch for it:
https://support.oracle.com/CSP/main/article?cmd=show&type=NOT&id=745005.1
But - I found a fix in my code that actually solved it - see my next answer.
Hope this helps anyone.
The accepted answer didn't work for me. However, after reading the attached links, I applied the following – although it does involve editing the SQL.
In my case, I knew the maximum left of the bind variable (the length reducing after the first call is what causes the issue). So I padded the .NET string, and added a TRIM in the SQL. Following your example:
c.CommandText = "\r\nSelect c1, c2, c3, rowid \r\nFrom someSpecificTable \r\nWhere c3 = TRIM(:p0)";
...
p.Value = "007".PadRight(10);

Runtime Error 438 when using VB6 procedures

From what I understand about runtime error 438, it indicates binary compatibility problems like a referenced ActiveX library is not compatible with the distributed library. I can see no reason why this runtime error would be generated for basic VB6 procedures like CLng or Round.
Dim X as Integer
Dim Y as Single
Dim result as Long
X = GetX() ' Returns 0
Y = GetY() ' Returns 0.75
result = CLng(X / Y) ' throws runtime error 438
result = Round(X / Y) ' throws runtime error 438
Is there something obvious I'm missing here?
EDIT:
I have confirmed that the problem lies in the project, not the code. It seems that this error/situation is a quirk specific to the development environment offered by General Electric's Proficy iFIX 8.1.
I just tried out your code in vb6 and it worked fine.
You mention 2 errors in your post, 438 and 483.
VB6 help gives the following descriptions for those errors:
Object doesn't support this property or method (Error 438)
Printer driver does not support specified property (Error 483)
I can't see how either of those errors are being raised
Integer division against a Single will return an integer. Your variable "result" is declared as long. With Integers in division, you should use the other slash ( \ ) also.

Oracle "SQL Error: Missing IN or OUT parameter at index:: 1"

I have an Oracle script that looks like the following:
variable L_kSite number;
variable L_kPage number;
exec SomeStoredProcedureThatReturnsASite( :L_kSite );
exec SomeStoredProcedureThatAddsAPageToTheSite( :L_kSite, :L_kPage );
update SiteToPageLinkingTable
set HomePage = 1
where kSite = :L_kSite and kPage = :L_kPage;
Supposedly the last statement is a valid use of a bind variable but when I try to run the script I get this on the last line:
SQL Error: Missing IN or OUT parameter at index:: 1
I'm not sure how to proceed here as I'm not especially proficient in Oracle.
I had a similar error on my side when I was using JDBC in Java code.
According to this website (the second awnser) it suggest that you are trying to execute the query with a missing parameter.
For instance :
exec SomeStoredProcedureThatReturnsASite( :L_kSite );
You are trying to execute the query without the last parameter.
Maybe in SQLPlus it doesn't have the same requirements, so it might have been a luck that it worked there.
Based on the comments left above I ran this under sqlplus instead of SQL Developer and the UPDATE statement ran perfectly, leaving me to believe this is an issue in SQL Developer particularly as there was no ORA error number being returned. Thank you for leading me in the right direction.
I think its related with jdbc.
I have a similar problem (missing param) when I have a where condition like this:
a = :namedparameter and b = :namedparameter
It's ok, When I have like this:
a = :namedparameter and b = :namedparameter2 (the two param has the same value)
So it's a problem with named parameters.
I think there is a bug around named parameter handling, it looks like if only the first parameter get the right value, the second is not set by driver classes. Maybe its not a bug, only I don't know something, but anyway I guess that's the reason for the difference between the SQL dev and the sqlplus running for you, because as far as I know SQL developer uses jdbc driver.
I got the same error and found the cause to be a wrong or missing foreign key. (Using JDBC)
I had this error because of some typo in an alias of a column that contained a questionmark (e.g. contract.reference as contract?ref)
I had issue in SQL Developer because I was using binds incorrectly. Was using this, copied from log:
variable = ?
should be
variable = :variable
Now SQL Developer prompts me for values.
I got the same error sporadically appearing on some user setup, while others were content with the same report. I had my parameters written in altered case and with nordic letters, for example: Henkilö. I changed them to HENKILO, using only upper case and no nordics, and it did the trick.
The driver is some unknown or varying JDBC version to Oracle.
My error desc was originated from some 3rd party bin:
Excel Plugin Error: Failed executing statement (Missing IN or OUT parameter at index:: 4)
SQL Statement failed. Please verify and correct it!

Resources