Error
Error Code:
1358
SAP S/4HANA Error 1358: Missing SQLScript USING Clause
Description
This error indicates that a SQLScript library or function is being invoked within a procedure, function, or view without a preceding `USING` statement. The `USING` statement is essential in SAP HANA SQLScript to declare dependencies on external libraries or to assign aliases, allowing the system to resolve the referenced objects correctly. It typically occurs during compilation or execution of database objects.
Error Message
ERR_SQLSCRIPT_LIB_WITHOUT_USING
Known Causes
4 known causesUndeclared Library Usage
A SQLScript library function is called within a procedure, function, or view without a corresponding `USING` statement to declare its availability.
Incorrect USING Syntax
The `USING` statement is present but contains syntax errors, an incorrect library name, or an improperly formatted alias, preventing proper resolution.
Cross-Schema Library Reference
Attempting to use a library or function residing in a different schema without explicitly qualifying it within the `USING` statement.
Typographical Error
A typo in the library name or function name within the `USING` clause or the actual function call leads to the system failing to find the declared object.
Solutions
3 solutions available1. Add REQUIRED Libraries to SQLScript easy
Explicitly declare the necessary SQLScript libraries using the USING clause.
1
Identify the SQLScript procedure or function that is failing with error 1358.
2
Examine the SQLScript code to determine which libraries or functions are being called without being declared.
3
Add the missing libraries to the `USING` clause at the beginning of your SQLScript procedure or function definition. The `USING` clause should list all external SQLScript libraries that your code depends on. For example, if you are using functions from `SAP_DW_ECOSYSTEM.SQLSCRIPT_FUNCTIONS`, you would add it like this:
PROCEDURE MY_PROCEDURE() LANGUAGE SQLSCRIPT OPTIONS READ_ONLY
DEFAULT SCHEMA <your_schema>
-- Add or ensure these libraries are listed in the USING clause
USING <your_schema>.MY_LIBRARY, SAP_DW_ECOSYSTEM.SQLSCRIPT_FUNCTIONS
AS
BEGIN
-- Your SQLScript code here
END;
4
Redeploy or re-execute the SQLScript object. Verify that the error is resolved.
2. Review and Correct Library Dependencies medium
Ensure all referenced external SQLScript libraries are correctly defined and accessible.
1
Locate the source code of the failing SQLScript object (procedure, function, or table function).
2
Carefully review all calls to external SQLScript functions or procedures. For each external call, verify that the schema and library name are correctly specified.
3
Check if the referenced libraries themselves exist and are active within your SAP HANA database. You can query the catalog views to verify:
SELECT * FROM SYS.LIBRARIES WHERE SCHEMA_NAME = '<library_schema>' AND LIBRARY_NAME = '<library_name>';
4
If the library does not exist or is inactive, you may need to import or activate it. This often involves deploying a `.lrep` or `.hdbcollection` file containing the library.
5
Once the library is confirmed to exist and be active, ensure it is listed in the `USING` clause of the calling SQLScript object, as described in the previous solution.
6
Recompile and execute the SQLScript object to confirm the fix.
3. Update Outdated SQLScript Definitions medium
Recreate or update SQLScript objects that might have incorrect or missing library references.
1
Identify the specific SQLScript object causing the error (e.g., a stored procedure or function).
2
If possible, obtain the latest version of the SQLScript definition from your development team or version control system.
3
Drop the existing SQLScript object from the SAP HANA database.
DROP PROCEDURE <your_schema>.<procedure_name>;
-- or
DROP FUNCTION <your_schema>.<function_name>;
4
Re-create the SQLScript object using the updated definition, ensuring the `USING` clause correctly lists all required external libraries.
-- Example of re-creation with USING clause
CREATE PROCEDURE <your_schema>.<procedure_name>() LANGUAGE SQLSCRIPT OPTIONS READ_ONLY
DEFAULT SCHEMA <your_schema>
USING <your_schema>.MY_LOCAL_LIB, SAP_DW_ECOSYSTEM.ANALYTICS_FUNCTIONS
AS
BEGIN
-- Updated SQLScript logic
END;
5
Execute the newly created SQLScript object to verify the error is resolved.