I’m new to Oracle, so bear with me on this – I’ll do as best I can.
I’m writing a stored procedure. After the AS statement completes, I have the following code:
BEGIN
IF v_Node = NULL
BEGIN
SET v_Node = LEFT(v_Tag, INSTR('.', v_Tag)-1)
SET v_Node = (SELECT v_NodeId FROM DBO.nodes WHERE Node = v_Node)
END
which we I compile spits out the following error:
Error(23,5): PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following: * & - + / at mod remainder rem then <an exponent (**)> and or || multiset
Can anyone help with this?
Cheers
I suspect that you want something like
The explanation
NULL, not even anotherNULL. You need to use theIS NULLoperator.LEFTfunction. You probably wantSUBSTR.SETis not a valid PL/SQL operator. You can use the:=operator to assign the result of an expression to a variable. And you can useSELECT ... INTOto assign the result of a SQL query to a local variable.The remaining issues
v_Nodeboth to assign theNodestring you want to search for and to hold the presumably numericv_NodeIdthat you select from the table. If that is really your intention, you would want separate variables.SELECTstatement that you wrote doesn’t make sense. Ifv_NodeIdis a local variable, as the naming convention implies, it doesn’t make sense to select it from thedbo.nodestable. It would seem more likely that you want to select theNodeId(assuming that is a column indbo.nodes).