Error message Multi Part Identifier could not be bound - validation

I am writing a SQL query to use in a Boyum validation that will flag and BP Master Data NAMES that are LIKE
Here is the query I have written
IF OCRD.Cardname IN (Select OCRD.Cardname from OCRD WHERE OCRD.Cardname
LIKE '%'+Cardname+'%')
BEGIN
SELECT 'Duplicate'
FOR BROWSE
END
Here is the error message I have received
[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]The multi-part identifier "OCRD.Cardname" could not be bound.
2). [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Statement(s) could not be prepared.
)

That is invalid SQL you provided. You can't reference a table column like that
IF EXISTS (Select OCRD.Cardname from OCRD WHERE OCRD.Cardname LIKE '%'+Cardname+'%')
BEGIN
SELECT 'Duplicate'
FOR BROWSE
END

Related

MariaDB-Statement in Bash here-Document of a Procedure-Block throws ERROR 1064 (42000) [duplicate]

I keep getting this error for the below MySQL SP
any ideas?
CREATE PROCEDURE productpricing(
OUT pl DECIMAL(8,2), OUT ph
DECIMAL(8,2), OUT pa DECIMAL(8,2) )
BEGIN SELECT Min(amount) INTO pl
FROM Card Error Code: 1064 You have an
error in your SQL syntax; check the
manual that corresponds to your MySQL
server version for the right syntax to
use near '' at line 9 0.000 sec
DROP PROCEDURE IF EXISTS productpricing;
CREATE PROCEDURE productpricing(
OUT pl DECIMAL(8,2),
OUT ph DECIMAL(8,2),
OUT pa DECIMAL(8,2)
)
BEGIN
SELECT Min(amount)
INTO pl
FROM Card;
END;
Did you define a delimiter?
Try adding delimiter // before the CREATE PROCEDURE statement. Also replace END; with END;//. I checked and it works for me.
See the MySQL doc on stored procedures
you need group by if you use min,max i think. if that doesnt work try #p1 to create a temp table. May be problem is the table you are inserting it to.

datastage error - odbc function "SQLNumResultCols"

I am trying to select table from an oracle database using datastage.
In the ODBC Connector, If i do
select *
from Table_Name
I get this error -
'ODBC function "SQLNumResultCols" reportted: STATE=102:Native Error
Code = 0: Msg = [IBM(DataDirect OEM)][ODBC 20101 driver] 251'.
However if i use -
select cast(colA as varchar(50) as A,
cast(colB as varchar(50) as B
instead of
select *
from table_name
it works just fine. The data type of these columns is NVARCHAR2.
Is there a way to directly get it from
select *
from table_name
(there are about 20 columns in each of these tables)
Found a fix. Changed nvarchar parameter in odbc file

No more data to read from socket (Oracle SQL Developer)

I have created one trigger that calls one procedure, using oracle sql developer. Here is the code for trigger:
CREATE OR REPLACE TRIGGER noteTrigger
BEFORE
INSERT OR
UPDATE OF valoare OR
DELETE
ON note
BEGIN
CASE
WHEN INSERTING THEN
DBMS_OUTPUT.PUT_LINE('Inserting');
updateBursa();
WHEN UPDATING('valoare') THEN
DBMS_OUTPUT.PUT_LINE('Updating valoare');
updateBursa();
WHEN DELETING THEN
DBMS_OUTPUT.PUT_LINE('Deleting');
updateBursa();
END CASE;
END;
/
Now, the procedure is written here:
CREATE OR REPLACE PROCEDURE updateBursa IS
v_countBursieri NUMBER := 0;
BEGIN
UPDATE STUDENTI SET bursa = null;
FOR v_i IN (SELECT nr_matricol from studenti natural join note group by nr_matricol having avg(valoare) =
(select max(avg(valoare)) from studenti natural join note group by nr_matricol)) LOOP
v_countBursieri := v_countBursieri + 1;
END LOOP;
FOR v_i IN (SELECT nr_matricol from studenti natural join note group by nr_matricol having avg(valoare) =
(select max(avg(valoare)) from studenti natural join note group by nr_matricol)) LOOP
UPDATE STUDENTI SET bursa = 1000/v_countBursieri where nr_matricol = v_i.nr_matricol;
END LOOP;
END;
/
And when I try to modify note table by this:
INSERT INTO note VALUES ('111', '25', 5, TO_DATE('20/06/2015', 'dd/mm/yyyy'));
I get error:
Error report -
ORA-00603: ORACLE server session terminated by fatal error
ORA-00600: internal error code, arguments: [kqlidchg0], [], [], [], [], [], [], [], [], [], [], []
ORA-00604: error occurred at recursive SQL level 1
ORA-00001: unique constraint (SYS.I_PLSCOPE_SIG_IDENTIFIER$) violated
00603. 00000 - "ORACLE server session terminated by fatal error"
*Cause: An Oracle server session was in an unrecoverable state.
*Action: Log in to Oracle again so a new server session will be created
automatically. Examine the session trace file for more
information.
Error report -
SQL Error: No more data to read from socket
This is Ora-600 you should deeply explore reasons why is raised in your case, maybe you should open SR.
also, in the code you are referencing the table "note" on which you are creating a trigger, which could lead to mutating table, so consider the option of changing your code logic.
In my understanding, you need statement level trigger, not row level trigger?
ORACLE server session terminated by fatal error
Try this, had the same problem on the same "topic" let's say :) And setting things as shown previously just solved my problem. Good luck!

SELECT a table from oracle data dictionary

I am new to SQL and recently installed Oracle 11g. I read the post here on selecting all tables from user_tables. I'm trying to select a specific table and following some of the suggestions in the post does not appear to work.
The following executes fine and returns all tables available to me including a table named faculty_t:
select * from user_tables;
select * from dba_tables;
select * from all_tables;
desc faculty_t;
But I get error when I do the following:
select * from user_tables where table_name = FACULTY_T;
The first set of statements confirm that I do have a table named faculty_t. However, trying to select this table from user_tables, all_tables, or dba_tables does not appear to work for me right now. The error message reads something like:
ORA-00904: "FACULTY_T": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 208 Column: 8
Any thoughts? Thanks!
String literals in SQL are wrapped in '. So:
select * from user_tables where table_name = 'FACULTY_T';
When you did a desc faculty_t, the SQL engine knew that a table name was expected at that spot (the syntax expects a table name there). But in your select query, sql is just looking for the value of a column that happens to have a string data type, so you need to use the ' for a string literal.

The mystic getClobVal()

I have a table (AKADMIN) with an XMLTYPE column which name is XML.
I would like to use the getClobVal() with this column.
select t.xml.getClobVal() /**/
, t.xml.getClobVal() --
, t.xml.getClobVal() as clobval
, t.xml.getClobVal()
from akadmin t where ROWID = 'AAAQc6AAIAAAADDAAA' ;
In the resultset the first 4 column give CLOB type, but the fifth column XMLTYPE. I have to type any comment or alias after getClobVal() to correct (CLOB) type of the result. Why?
Another issue, when I leave the alias of tablename:
select xml.getClobVal()
from akadmin t where ROWID = 'AAAQc6AAIAAAADDAAA' ;
It throws an ORA-00904 string: invalid identifier
Hmmm...
Does anybody have any idea?
Addition info about environment:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0;
PL/SQL Developer 10.0.5.1710
But a tried this in our Java apllication via OJDBC6 with same results
You should put xml in a brackets:
select (xml).getClobVal() from akadmin;
works for me

Resources