If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > DB2 WIN / AIX Script compatibility

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-03-08, 23:24
gblanco gblanco is offline
Registered User
 
Join Date: Nov 2008
Posts: 2
DB2 WIN / AIX Script compatibility

Hi Ev.,

I Have a complete Create Database w/ procs, views, triggers,etc created on a AIX DB2.

I'm having problems to run that script o a Win DB2 v9.5

Here's an Example:

--------------------------------------------------------
CREATE PROCEDURE DBO.PROCESOS_SELECC ( )
SPECIFIC DBO.PROCSSEL
DYNAMIC RESULT SETS 1
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
READS SQL DATA
INHERIT SPECIAL REGISTERS
L_Procesos_Selecc: BEGIN NOT ATOMIC
DECLARE curProcs_Sel CURSOR WITH RETURN FOR
SELECT Proceso, Descripcion,
Tipo, Frecuencia, Tareas
FROM DBO.Procesos
ORDER BY Proceso
FOR READ ONLY;
OPEN curProcs_Sel;
END L_Procesos_Selecc;
-----------------------------------------------------------------

And this is the output I get:

------------------------------------------------------
DB21034E El mandato se ha procesado como una sentencia de SQL porque no era
un mandato válido para el procesador de línea de mandatos. Durante el proceso
SQL se ha devuelto:
SQL0104N Se ha encontrado un símbolo "END-OF-STATEMENT" inesperado a
continuación de "o FOR READ ONLY". Los símbolos esperados pueden
incluir: "<psm_semicolon>". LINE NUMBER=15. SQLSTATE=42601

OPEN curProcs_Sel
DB21028E No se ha declarado el cursor "CURPROCS_SEL".

END L_Procesos_Selecc
DB21034E El mandato se ha procesado como una sentencia de SQL porque no era
un mandato válido para el procesador de línea de mandatos. Durante el proceso
SQL se ha devuelto:
SQL0104N Se ha encontrado un símbolo "END-OF-STATEMENT" inesperado a
continuación de "ND L_Procesos_Selecc". Los símbolos esperados pueden
incluir: "JOIN <joined_table>". SQLSTATE=42601

SQL0104N Se ha encontrado un símbolo "END-OF-STATEMENT" inesperado a continuación de "ND L_Procesos_Selecc". Los símbolos esperados pueden incluir: "JOIN <joined_table> ".

Explicación:

Se ha detectado un error de sintaxis en la sentencia de SQL o en la
serie del mandato de entrada para el procedimiento SYSPROC.ADMIN_CMD en
el símbolo especificado después del texto "<texto>". El campo "<texto>"
indica los 20 caracteres de la sentencia de SQL o de la serie del
mandato de entrada para el procedimiento SYSPROC.ADMIN_CMD que preceden
al símbolo que no es válido.

Como ayuda, se proporciona una lista parcial de símbolos válidos en el
campo SQLERRM del SQLCA como "<lista-símbolos>". Esta lista da por
supuesto que la sentencia es correcta hasta ese punto.

No se puede procesar la sentencia.

Respuesta del Usuario:

Revise y corrija la sentencia en el área del símbolo especificado.
-------------------------------------------------------------------------

I can't find a way around it, and I have thousands of line of code to move.

Tnx in advance. Any help will be of use.
Reply With Quote
  #2 (permalink)  
Old 11-04-08, 03:35
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
Since this is a stored procedure, you'll have to use db2 Development Workbench for creating stored procedures and UDF's.

some useful links -
I have worked on a previous version of workbench and it had an import option from where you can import whole store procedures.... something similar will definitely be available here....

What is basically happening in your case is when you run your command db2 treats the following statements as seperate statements since semi-colon specifies end of statement. Whereas in reality it is one whole block.

Code:
CREATE PROCEDURE DBO.PROCESOS_SELECC ( )
SPECIFIC DBO.PROCSSEL
DYNAMIC RESULT SETS 1
LANGUAGE SQL
NOT DETERMINISTIC
CALLED ON NULL INPUT
READS SQL DATA
INHERIT SPECIAL REGISTERS
L_Procesos_Selecc: BEGIN NOT ATOMIC
DECLARE curProcs_Sel CURSOR WITH RETURN FOR
SELECT Proceso, Descripcion,
Tipo, Frecuencia, Tareas
FROM DBO.Procesos
ORDER BY Proceso
FOR READ ONLY;
Code:
OPEN curProcs_Sel;
Code:
END L_Procesos_Selecc;

Last edited by nick.ncs; 11-04-08 at 03:38.
Reply With Quote
  #3 (permalink)  
Old 11-04-08, 08:09
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
There's the answer in this thread: http://www.dbforums.com/showthread.p...62#post6363662
Reply With Quote
  #4 (permalink)  
Old 11-04-08, 08:36
gblanco gblanco is offline
Registered User
 
Join Date: Nov 2008
Posts: 2
Thanks

Thanks...that solved it.

Now, question 2....

In Workbench I'm able to import my Stored Procedures from my .sql file one by one.

Is there a way to run the whole .sql and go from the Create database, procedures, grants, triggers, etc etc etc on one run.

Tnx in advance.

Gustavo
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On