I am new to db2 stored procedures.
I am looking to read a SQL file as a parameter and looking to execute that SQL query to get the records.
Can anyone help me with this?
thanks in advance.
Use utl_file procedure to read file and build sql string. Use dynamic sql to execute sql string. Check following links for more details.
utl_file:
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_9.7.0/com.ibm.db2.luw.sql.rtn.doc/doc/r0053697.html
dynamic sql:
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_9.7.0/com.ibm.db2.luw.apdv.plsql.doc/doc/c0053894.html
Related
Is it possible to encrypt stored procedures in Teradata?
I would like to hide the code of procedure from others and I have no idea if it is even possible.
Some ideas?
Thanks,
Cris
There's no need to encrypt the source code of a SP in Teradata, you can simply use the NO SPL option and then no source code is stored.
Either during creation using ODBC, CLI or BTEQ, e.g. in BTEQ
.COMPILE FILE 'mysp.spl' WITH NOSPL
But the common way is to CREATE it first and then run:
ALTER PROCEDURE mySP COMPILE WITH NO SPL;
I need to know a syntax of CREATE TRIGGER and CREATE PROCEDURE operations in ANSI SQL standard. But as I know each databases use a custom SQL syntax in some details, so I don't know that is from all variants is ANSI SQL. And I can't find ANSI SQL standard docs (in any case in public access).
Can someone tells me where I can find it? Or which database uses a correct syntax to read its docs?
P.S. I am a nobie in SQL just I need it for my exams. At work I used PostgreSQL always but I noticed that it is not same like ANSI SQL.
I am getting an error while trying to execute a dynamic insert query in volt db using the voltQueueSQLExperimental() function. The SQL is fine as i ran it separately on the volt web studio. The error is as follows:
Error: VOLTDB ERROR: USER ABORT Attempted to queue DML adhoc sql
'insert into volt_temp_constraints
(asset_id,config_id,session_id,sam_id) values (12,13,'abc',12)' from
read only procedure at
procedures.testPrcUpdateConstraint.run(testPrcUpdateConstraint.java:155)
Please note that the SQL generated is dynamic and adhoc and this cannot be generated statically before hand.
Documentation is not their strength... ;), but I could reproduce your bug.
As I see it VoltDB marks compiled Procedures as read-writer or read-only. As one can infer from here. Unfortunately there currently does not seem to be any other way around it other than creating a INSERT/UPDTE/UPSERT SQLStatement as a Object Property and simply not using it.
Maybe you can contact one of the developers to add a some way on confutation for this.
By the way, the Exception can be found here: https://github.com/VoltDB/voltdb/blob/master/src/frontend/org/voltdb/ProcedureRunner.java in line 620
A group in my company granted me access to execute a stored procedure, and the stored procedure, if executed from excel, gives me a table. I want to store this table in SQL via SSIS.
I tried this via:
Within DFT, I created a connection using SQL Server Native Client. And within source assissstant, I entered SQL command
EXEC [dbname].[storedprocedure]
But then it returns an error:
No column information was returned by the SQL command.
Is there anyway to make this work?
Add the proper data source and then connect it to the OLE DB Command. Under the Connection Manager tab, setup your connection. Under the Component Properties Tab in the SqlCommand line enter EXEC [Stored Procedure Name] ? use as many ?s for as many variables declared in your Stored Procedure. Under the Column Mappings tab you will map your variables from the Stored Procedure to the relevant columns in your SQL Server DB.
I would like to find out the dependencies of a stored procedure in Sybase IQ, considering that it does not seem to have sysdepends, can any one let me know how to list the dependencies for a given stored procedure?
In Sybase IQ, the dependency information is held in the SYSDEPENDENCY system view. To find dependency information, you can join SYSDEPENDENCY, SYSOBJECT, and SYSPROCS to find dependencies of your stored procedures.
Its been a while, but thought someone might benefit from this.
select soRef.name, soRef.type, soRef.id,suRef.user_name, soDep.name, soDep.type,
suDep.user_name, soDep.id from SYSDEPENDENCY sd
join sysobjects soREf on soRef.id=sd.ref_object_id
join sysobjects soDep on soDep.id=sd.dep_object_id
join sysuser suRef on suRef.user_id=soREF.uid
join sysuser suDep on suDep.user_id=soDep.uid
where suRef.user_name='myusername'
There is no system procedure to find the dependencies of a proc in sybase IQ.
sysdependency contains the info for only the views so its not much of help in this scenario.
You might try to do it using unix script , where you can search all the tables which are used in the proc but again that is not a short sure solution.