Questions tagged [sql-pl]

Use this tag for DB2 SQL Procedural Language (SQL PL) questions

40 questions
0
votes
1 answer

Getting error in oracle sql developer trying to print xml

I am trying to print the following XML as PLCO_ID is A-006884-2 Trt_numc is 103 Trt_familyc is 1 Trt_days is 2513 Neoadjuvant is 0 PLCO_ID is A-008288-4 Trt_numc is 104 Trt_familyc is 1 Trt_days …
0
votes
1 answer

SQL0526N when referencing a DGTT (Declared global temporary table) in a FUNCTION

I would like to return content from a pre-created DGTT as a result-set for a table function. But when I reference it, I get SQL SQL0526N / SQLSTATE 42995 error. I can't see why. Documentation says only 3 reasons for 42995 sqlstate…
Samuel Pizarro
  • 267
  • 1
  • 8
0
votes
1 answer

SQL0628N with MODIFIES SQL DATA when creating a table function

I am trying to encapsulate the functionality from this sample code here, inside a Table-Function. I can run the sample alone without any problem. But when I create a table function, just with a single call to OPEN_CURSOR , I receive SQL0577N CREATE…
Samuel Pizarro
  • 267
  • 1
  • 8
0
votes
2 answers

How to do a sub procedure in sql / pl

I am doing a procedure migration in pl / sql (oracle) to sql / pl (DB2) and I don't know how to pass a subprocedure to DB2 As I am not a system administrator I cannot change DB2 to be pl / sql compatible EXAMPLE create or replace PROCEDURE …
0
votes
0 answers

DB2 and Stored Procedure - How to recover the bind parameters?

I'm writing a Stored Procedure (SQL / PL - DB2 V11 or later) and I need to access the SYSIBM.SYSCOLUMNS to retrieve the columns of 'HELLO_WORLD' table. On SYSIBM.SYSCOLUMNS the table 'HELLO_WORLD' is present with different TBCREATOR. TBCREATOR | …
killer
  • 11
  • 6
0
votes
2 answers

Declare mariaDB error. How can fix this query?

I'm trying to fill a table with some columns from another table giving an id, but I got this error: 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near…
0
votes
2 answers

OUT Parameter Issue in DB2 Stored Procedure

I am getting an error complaining about the OUT Parameter ID as an Undefined name when I try to set its value at the end of the procedure. Commenting it out the procedure executes fine. What am I doing wrong? CREATE PROCEDURE P3.CUST_CRT(IN NAME…
TheMokuaBrand
  • 45
  • 1
  • 10
0
votes
1 answer

IF SET Help Oracle to DB2

I have to migrate all procedures from Oracle to DB2 database. I'd like to know, how do I do SET syntax inside of IF as Oracle works. Variable has been using in Oracle is ps_iPkCooperativa and are receiving 0. Oracle Code : BEGIN SELECT CCOOP …
Luiz
  • 141
  • 2
  • 14
0
votes
0 answers

Is it possible to set notepad++ as a query editor in db2

I have just installed db2 on windows 8.1 and I want to run some queries. Ideally it would be easier using an editor like notepad++ to edit the queries before running them on the db2 command line as opposed to using the db2 command line. How do I set…
TheMokuaBrand
  • 45
  • 1
  • 10
0
votes
1 answer

DB2 DROP AND CREATE TABLE

I'm trying to ensure when i run a stored procedure it checks if a table exists and if it does it drops it then re-creates the table. Using the following stored proc CREATE PROCEDURE PROCEDURE1 () DYNAMIC RESULT SETS 1 P1: BEGIN if( exists( select 1…
ojuang
  • 1
  • 1
  • 2
0
votes
2 answers

IF condition with FOR loop db2 plsql

I'm creating a procedure on db2 that will insert values into a table only if the table is empty. I've created the following statements, but something is wrong since I'm getting error: [42601][-104] An unexpected token "END-OF-STATEMENT" was…
Janna Sherazi
  • 167
  • 1
  • 1
  • 15
0
votes
0 answers

DBMS_SQL Character constraint

I encountered the following error, i'm learning about DBMS_SQL. I was playing around with the below code which drops a table and recreates a new table. I noticed for the recreation of the new table, i'm running into a character constraint. Just…
saggart
  • 25
  • 6
0
votes
1 answer

Move to next iteration in WHILE loop SQL-PL DB2

Is there a way to tell a program to move to the next iteration of a while loop in SQL-PL for DB2? I know that there is a CONTINUE statement, but it isn't working for me. I basically want: WHILE .... DO IF condition_met THEN -- Move to…
colmulhall
  • 1,548
  • 3
  • 18
  • 33
0
votes
1 answer

Change folder path in field with SQL-PL

I've got a field in a DB2 table which holds a file path. The value will look something like this: N:\Folder1\Folder2\Folder3\Folder4\ITP201602 I need a stored procedure which will change the last folder with a time stamp, which will appear as…
devkev
  • 1
  • 1
0
votes
1 answer

SQL/pl Procedure to delete all products supplied by vendor x and references

I have to create a procedure to delete all products supplied by vendor x and all references in a another table called tab_line. Not sure if I'm doing it right, but it states that I'm missing an expression when I run this code. Any help or a better…
PhiOrder
  • 5
  • 1
  • 5