PL/SQL function return type integer : Invalid Identifier - sql

I have a function called get_pid in a file called func.sql . The function get_id takes an
input: given_price Parts.price%type and returns an integer.
To call this function, I created a new file called main.sql. Then I login to sqlplus and I call main in this way:
SQL> #Q1_main
select get_pid(400) from dual
*
ERROR at line 1:
ORA-00904: "GET_PID": invalid identifier
Am I calling the function properly? What could possibly be wrong, I looked at the other questions posted about this topic, but I can't figure out what I am doing wrong.

Try to inform the name of the scheme where are your function.
for example, the username (schema) is dev, then you have to try like this.
select dev.get_pid(400) from dual.

when you are on prompt you always have to use the scheme name "." your function/procedure.

Related

Error : Field "S_MARA-MATNR" is unkown during FOR statement

DATA: t_mara type STANDARD TABLE OF mara WITH EMPTY KEY.
DATA(t_data1) = VALUE ty_data( FOR s_mara IN t_mara ( s_mara–matnr ) ).
I am trying to implement a similar code using FOR statement but I am getting an error that the field is unknown in the work area even though it would be declared inline.
Can you please let me know what went wrong? This is my first time I am facing this error on FOR loop.
Not sure because you are not providing too much detail but try this:
DATA t_mara type STANDARD TABLE OF mara WITH EMPTY KEY.
DATA(t_data1) = VALUE ty_data( FOR s_mara IN t_mara ( matnr = s_mara-matnr ) ).

String interpolation in HiveQL

I'm trying to create an external table that routes to an S3 bucket. I want to group all the tables by date, so the path will be something like s3://<bucketname>/<date>/<table-name>. My current function for creating it looks something like
concat('s3://<bucket-name>/', date_format(current_date,'yyyy-MM-dd'), '/<table-name>/');
I can run this in a SELECTquery fine; however when I try to put it in my table creation statement, I get the following error:
set s3-path = concat('s3://<bucket-name>/', date_format(current_date,'yyyy-MM-dd'), '/<table-name>/');
CREATE EXTERNAL TABLE users
(id STRING,
name STRING)
STORED AS PARQUET
LOCATION ${hiveconf:s3-path};
> FAILED: ParseException line 7:9 mismatched input 'concat' expecting StringLiteral near 'LOCATION' in table location specification
Is there any way to do string interpolation or a function invocation in Hive in this context?
you can try something like this. retrieve udf results in Hive. Essentially, as workaround, you can create a script and call it from the terminal passing the parameter like a hive config.

PostgreSQL DBLink: No function matches the given name and argument types

I was playing around with DBLINK and I wanted to try it. So I run this simple query
CREATE EXTENSION dblink;
SELECT *
FROM dblink(('dbname=genesis_admin')::text,
('SELECT * FROM user_account')::text);
then to my surprise
[WARNING ] CREATE EXTENSION dblink
ERROR: extension "dblink" already exists
[WARNING ] SELECT * FROM dblink(('dbname=genesis_admin')::text, ('SELECT * FROM user_account')::text)
ERROR: function dblink(text, text) does not exist
LINE 1: SELECT * FROM dblink(('dbname=genesis_admin')::text, ('SELE...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
How can it not be existing if it already exists?
I encountered the same error and the reason is that this is because DBLink gets installed (by default) in Public schema and you have probably modified the search_path to a list that doesn't include public). The Database although contains the function DBlink(text, text) is therefore unable to find that function.
To get this to work, you need to add specific schema to the DBlink function call.
SELECT public.dblink(xxx, yyy);

Entity Framework ExecuteStoreCommand gives {"ORA-00936: missing expression"}

I'm trying to run the following in a VB.NET application using Entity Framework 6 on an Oracle database:
mrstage.ExecuteStoreCommand("DELETE FROM CB_LISTINGS WHERE ELIGIBLE={0}", eligible)
When it executes, I get the error: {"ORA-00936: missing expression"}
On my table, ELIGIBLE is of type VARCHAR2, and the eligible variable is a string.
If I hardcode the parameter, for example:
mrstage.ExecuteStoreCommand("DELETE FROM CB_LISTINGS WHERE ELIGIBLE='ECB'")
It works fine.
I'd be very grateful if someone can offer any suggestions.
Thanks!
James
In Oracle parameters are named differently, use a column parameter like :0 instead of {0}.
So your code is now:
mrstage.ExecuteStoreCommand(
"DELETE FROM CB_LISTINGS WHERE ELIGIBLE=:0",
eligible)

Why can't my As400 select from a newly created member alias?

I have set up the code as described in this question.
Creating an alias works, as well as dropping it.
For members that I have created myself, this is working correctly, but for existing members I get the following error when selecting from the alias:
SQL State: 42704
Vendor Code: -204
Message: [SQL0204] MyMemberName in MyLib type *FILE not found.
Cause . . . . . : MyMemberName in
TPLWHS type *FILE was not found. If the member name is *ALL, the table
is not partitioned. If this is an ALTER TABLE statement and the type
is *N, a constraint or partition was not found. If this is not an
ALTER TABLE statement and the type is *N, a function, procedure,
trigger or sequence object was not found. If a function was not found,
MyMemberName is the service program that contains the function. The
function will not be found unless the external name and usage name
match exactly. Examine the job log for a message that gives more
details on which function name is being searched for and the name that
did not match.
Recovery . . . : Change the name and try the request
again. If the object is a node group, ensure that the DB2 Multisystem
product is installed on your system and create a nodegroup with the
CRTNODGRP CL command. If an external function was not found, be sure
that the case of the EXTERNAL NAME on the CREATE FUNCTION statement
exactly matches the case of the name exported by the service program.
Any help you can offer is much appreciated. Thanks!
EDIT: Here is my code:
create alias MyLib.MyAlias for MyLib.MyLogicalFile(MyMember);
select * from MyLib.MyAlias;
drop alias MyLib.MyAlias;
The format of Lib.Alias has worked for me when I directly created the phyiscal and logical members. Perhaps the logical file is missing? I'll double check...
This error message can indicate that the file/logical file/member does not exist.