PL/SQL vs Pro*C / Cobol
Can any one tell me whether PL/SQL can totally replace Pro*C /
Cobol?
I remember there is a PL/SQL package called UTL_FILE, which
enable user to do File I/O. However, I wonder whether it really
excel the File I/O capability of the conventional Cobol or C
language.
I am going to create programs to output external data files and
sophisticated reports. Do you think it is possible, or suitable,
to apply PL/SQL in ALL cases?
Can any one tell me whether PL/SQL can totally replace
Pro*C /
Cobol?
Well Pro*C/Cobol have much more advanced features
available outside of the Oracle interface, obviously. Also
UTL_FILE is not a very fast way of producing text files if you
need very high throughput.
It is not possible or suitable to apply PL/SQL to al cases, but
if you are just producing text files and reports, no matter how
complex the formatting, PL/SQL is going to do it for you.
However my own preference is to use the minimum number
of technologies reasonably possible when doing a job. By
using Pro*C or Cobol you increase the maintenance
workload, so I would stick to PL/SQL if you can.
Similar Messages
-
Hi,
We are researching upgrading to 10g(10.1) for database and Developer tools. The database is currently 8.0.6 and we use Oracle Forms 5.0.6.8.0; Oracle Reports 3.0.5.8.0; and precompile Pro*C/COBOL programs with the 8.0.4.4 environment. There appears to be quite a bit of information on the database upgrade. I am looking for Forms and Reports data as well as Pro*C and Pro*COBOL. The platform is currently AIX 4.3.3 ML11 and we will be upgrading to AIX 5.2.5 prior to the database upgrade. Would someone be able to point me to some reference materials? Are there any land mines I should be concerned with? Is this possible? Would going to 6i or 9i for Developer be an option if 10g is not?
Thanks!Migrating Forms to the web:
http://www.oracle.com/technology/products/forms/pdf/forms9icstowebmigration.pdf
There are so many other related documents on OTN. Just go to
http://www.oracle.com/technology/products/ids/index.html -
In dealing a large volume of data, I'm using DBMS UTL_FILE package to write files on the OS. Replacing PL/SQL blocks with PRO*C shows better performance ?
nullHi,
Sorry for delay.
It is there in this we site itself. Or O'reilly's PL/sql books contains some examples or Oracle press PL/sql book contains some examples.
Why can not you send mail directly?
Thanks,
Boby Jose Thekkanath.
Consultant,CWO.
NSW-AUS. -
Dynamic pl/sql in pro*c/c++
I have a stored procedure to query and will receive a result by it....
I used the dbms_sql package to give name of the table at run-time
then it runs in sql*plus well...
but If i called it in pro*c/c++, it would not return result...
This is my examples..
(1) stored procedure
CREATE OR REPLACE PACKAGE XDMS_STORE_PKG
IS
PROCEDURE isExistInstance(table_name IN VARCHAR2, url IN VARCHAR2, num OUT N
UMBER);
END XDMS_STORE_PKG;
CREATE OR REPLACE PACKAGE BODY XDMS_STORE_PKG IS
PROCEDURE isExistInstance (table_name IN VARCHAR2, url IN VARCHAR2, num OUT NUMBER)
IS
cursor1 integer;
rows_processed integer;
tmp NUMBER;
tmp_char VARCHAR2(10);
BEGIN
cursor1 := dbms_sql.open_cursor;
dbms_sql.parse (cursor1, 'SELECT count(*) FROM ' | | table_name | | ' WHERE DocURL = ' | | ':x', dbms_sql.v7);
dbms_sql.bind_variable(cursor1, 'x', url);
dbms_sql.define_column (cursor1, 1, tmp);
rows_processed := dbms_sql.execute (cursor1);
loop
if dbms_sql.fetch_rows (cursor1) > 0 then
dbms_sql.column_value (cursor1, 1, tmp);
num := tmp;
else
exit;
end if;
end loop;
dbms_sql.close_cursor (cursor1);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(sqlerrm);
if dbms_sql.is_open (cursor1) then
dbms_sql.close_cursor (cursor1);
end if;
END isExistInstance;
END XDMS_STORE_PKG;
(2) In the sqlplus
set serveroutput on;
DECLARE
cnt NUMBER;
dtdid VARCHAR2(10) := 'DT_AAAAC';
url VARCHAR2(200) := 'http://www.ce.cnu.ac.kr/~xdms/data/personnel.xml';
BEGIN
XDMS_STORE_PKG.isExistInstance(dtdid, url, cnt);
dbms_output.put_line(to_char(cnt));
END;
(3) In the pro*c/c++
bool StorageManager::isExistInstance(char *this_url)
EXEC SQL BEGIN DECLARE SECTION;
int count = 0;
char dtdid[6];
char url[200];
EXEC SQL END DECLARE SECTION;
if(isNewDtd) return false;
sprintf(dtdid, "DT_%s", this_dtdid);
strcpy(url, this_url);
EXEC SQL EXECUTE
BEGIN
XDMS_STORE_PKG.isExistInstance(:dtdid, :url, :count);
END;
END-EXEC;
if(count < 1) return false;
else return true;
thanks...
nullThis is tough it seems. However here are a few thoughts if they can help:
- Generate(build) a dynamic pl/sql block like :
Begin
Your Procedure Name
End;
keep building this piece of code for each one of your procedures in C or C++. And then execute it as any PL/sql code in the form of a 'constructed' string. Pro*C also has DEscribe Using BInd, but i do not know if that can help. -
Improving Performance of Dynamic SQL in Pro*C
I am using Dynamic sql format 3 in pro*C,
i.e prepare sqlstmt from :sql_stmt
declare cursor c1 for sqlstmt
But the query is slow .I am also using
order by with ltrim(rtrim(colname))
& sometimes group by .
can anyone tell how to improve performance
of cursors in dynamic sql,or how can
I use the same in Pl/sql with simultaneous
printing of the rows returned,on a file.
nullManoj,
Typically, the slow performance is due to the SQL statement itself rather than the dynamic SQL execution code in Pro*C.
Check your explain plan to see if the query performs well. I suspect that you will find your problem here. -
I'm modifying some C code in Linux and I encountered a warning when compiling; the warning is on a fetch from a cursor, the fetch using an indicator variable:
EXEC SQL
FETCH SALES_MODEL_CURSOR INTO :sales_model_sql :sales_model_ind;
The warning message is:
program.pc: In function `get_sales_model':
program.pc:1348: warning: cast to pointer from integer of different size
'sales_model_ind' is declared as 'short' and 'sales_model_sql' is 'varchar';That is the line of code in the .pc file, the line number pointing at the 'EXEC SQL' and the remainder of the statement (i.e., the FETCH) is on the next line. I'm not sure what pointer it's referring to; the indicator variable is declared as a 'short' as it should be.
-
NVL2 in pro cobol giving the error.
For some reason we are getting an compiler error when we use NVL2 function in embedded sql statement in a pro-cobol module. Here is the output from the compiler. Do we have to add any options to recognize the new functions/keywords?
procob iname=vas107h2.pco include=/oracle/home/product/9.2.0/precomp/public ireclen=132 oreclen=132 sqlcheck=full ltype=none
" PICX=VARCHAR2 include=/jsbatch/vista/dev/cobol/cpy
Pro*COBOL: Release 9.2.0.7.0 - Production on Tue Oct 31 13:49:35 2006
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
System default option values taken from: /oracle/home/product/9.2.0/precomp/admin/pcbcfg.cfg
Error at line 595, column 12 in file vas107h2.pco
EXEC SQL DECLARE DRIVER CURSOR FOR
...........1
PCB-S-00576, PLS-201: identifier 'NVL2' must be declared
Error at line 595, column 12 in file vas107h2.pco
EXEC SQL DECLARE DRIVER CURSOR FOR
...........1
PCB-S-00576, PLS-0: SQL Statement ignored
*** Error code 1
make: Fatal error: Command failed for target `vas107h2'
Thanks,I'm not familiar with Pro*Cobol, but there's a similar issue with Pro*C, the parser does not recognize this built-in function. Given workaround is:
1) Use NVL() instead of NVL2().
2) Use Dynamic Sql in Pro*C. For example:
EXEC SQL EXECUTE
declare
v_var varchar2(100);
BEGIN
execute immediate 'select nvl2(user, user, 'N/A') from dual' into v_var;
END;
END-EXEC;
If that doesn't help, you should contact Oracle support.
Werner -
Dynamic SQL and IN CLAUSE from Pro C code
Hi Guys,
Tyring to embed sql in Pro C. Here I don't know in hand how many items will be there in the IN Clause of my dynamic sql. Tried this with a loop and then adding actual values to the stement and then executing it. This worked but as this hard coding makes it literal sql and hence hampers performance. Can any one help me with how to put bind variables where we don't know how many of them will be there in a dynamic sql.
Thanks,Dynamic SQL supports user defined types, try passing a collection and using TABLE(CAST(collection)) in the SQL statement.
In the current approach (creating IN clause at runtime) keep in mind that in a IN clause you can put a maximum of 255 elements...
Max -
PRO*C 에서 PL/SQL 을 CALL 하기
제품 : PRECOMPILERS
작성날짜 : 1997-12-14
pl/sql 을 call 하는 방법은 다음과 같습니다.
stored procedure call하는 방법
=================================
pl/sql program 이름이 demo_package 안의 procedure_name 라면
EXEC SQL EXECUTE
begin
demo_package.procedure_name (:empno, :deptno) ;
end;
END-EXEC ;
function call 하는 방법 :
======================
pro*c 에서 pl/sql block 을 call 하고 , 실행하는 방법은 다음과 같다 .
EXEC SQL EXECUTE
DECLARE
var1 NUMBER;
BEGIN
var1 := function_name(:param);
END;
END-EXEC
이때 precompile option SQLCHECK=semantics, USERID=scott/tiger 를
주어야 합니다.Echo Justin's comment that what you want to do is very unusual.. as pretty much everything you can do in Pro*C, can these days be done using PL/SQL inside Oracle.. so why then, from PL/SQL, call Pro*C?
Besides the options listed by Justin, there's also EXT PROC that allows the definition of external procedures. In this case the Pro*C code needs to be shared object/dynamic link library.
Examples posted in OTN threads Re: Problem with external procedure and Unix Command run successfully through PL/SQL but showing no impact in UNIX.. -
Running first Pro*COBOL application
I am working at a software house maintaining an application written in MF Object COBOL V4.0 which has DB2 SQL statements. These SQL statements are processed by the DB2 pre-processor by our build scripts which is then compiled into DLL's, EXE's, etc.
Our long-term plan (at the moment) is to re-engineer this system using Visual COBOL and use ODBC to interface with the (any) DB. It is a successful product that is still selling well and provides a good source of revenue for the company.
A short term requirement has arisen for the system to use a Oracle DB rather than DB2. I'm not close to the decisions that have been made for this, so I'll just go with it.
We've installed the Oracle bits and I have managed to get the pre-processor in place with the following command line.
PROCOB MODE=ANSI INPUT-NAME.CBL OUTPUT-NAME.CBL
This gives me a new output program that has replaced the SQL code with the Oracle calls. A good start.
I'm now struggling to discover how to actually execute these new bits of code. Previously, our code was previously 'linked' with DB2API.LIB which I'm guessing is how the previous version of the system allowed the DB2 calls to work. I guess I need something equivalent now but I don't know what or where to find it.
The previous LINK command in the script was:
LINK -OUT:%1.DLL -SUBSYSTEM:WINDOWS,4.0 -NODEFAULTLIB -DLL -DEF:%1.DEF %1.OBJ CBLLDS.OBJ ..\RESOURCE\%1.RES MFRTS32.LIB MSVCRT.LIB KERNEL32.LIB DB2API.LIB>>%1.ERR
Note the DB2API.LIB, which is now unnecessary obviously.
The system is on Windows.
I did encounter a couple of SQL differences too.
The CONNECT syntax was different, so:
EXEC SQL
CONNECT TO :WS-SQL-DBNAME
IN SHARE MODE
USER :WS-SQL-USERID
USING :WS-SQL-PASSWORD
END-EXEC.
Is replaced with:
MOVE "db1RMSG" TO WS-SQL-DBNAME
MOVE "PASSWORD" TO WS-SQL-PASSWORD
EXEC SQL
CONNECT :WS-SQL-DBNAME IDENTIFIED BY :WS-SQL-PASSWORD
END-EXEC.
Straightforward enough, BUT how to maintain? I would like the same program to be used for both versions of the system. If I use a compile-time switch then (I think) both SQL statements are examined by the pre-processors as they don't understand the compile-time code. Any ideas for this.
Also, there doesn't appear to be a DISCONNECT statement in Oracle although I haven't investigated this yet.
Within my 'DECLARE CURSOR' statements I use 'FOR FETCH ONLY'. Oracle doesn't like this, so I have removed them for now. Of course more investigation needed here. (FOR READ ONLY I believe is the replacement)
Any help from you chaps is appreciated.
Regards
RazorYou are asking a Cobol language question in a PL/SQL and SQL language forum. Very few active Cobol programmers here, if any. As far as I know, the few that are familiar with Cobol are like me - programmed once in it, a long time ago, in a galaxy mainframe far far away.
Even embedded SQL is pretty much an old thing. Most languages have abstraction interfaces (o-o classes) dealing with database interaction.
As for having a single embedded SQL code base in Cobol for both DB2 and Oracle pre-compiler support... ouch. I do not see an easy way with this, but via compiler macros and conditional compilation. -
Calling Cobol program from PL/SQL
What is the caling convention for PL/SQL to call a Cobol program?
You cannot do it directly from PL/SQL. PL/SQL is.. well, kind of abstract ito the actual platform it runs on. PL/SQL cannot talk directly to operating system. It cannot (itself) do socket calls, file I/O calls, use the printer, etc.
<p>
All this has to be done using a lower level implementation library - like UTL_FILE for example that wraps internal C written modules that does file I/O. PL/SQL can call these to do I/O on its behalf. Ditto for wrappers like UTL_TCP and others.
<p>
There is no default wrapper for calling external processes from PL/SQL. It can however be done indirectly using the external procedure (EXTPROC) feature, or using Java to do it.
<p>
The latter is the easiest. You create a Java stored proc that can access the operating system and run external programs and commands. You punch a big hole in the Oracle Java security to allow this Java stored proc access to the operating system. Next you create a PL/SQL wrapper for this Java proc which then in turn can be called from PL/SQL.
Just remember that you MUST secure this hole you've punched into Oracle security. If any Oracle user can access this PL/SQL wrapper, they can hack, compromise, trash or simply destroy your entire Oracle account on that server.
Here is the basic code:
create or replace and compile Java Source named "OSCommand" as
-- java: OS COMMAND
-- descr: Executes an Operating System Command using the JAVA RTS
-- IN parameter: os command to execute (including fully qualified path names)
-- OUT parameter: returncode [\nstring]
-- where string a max of 32000 chars of the output of the command
-- (note that \n is used as separators in the string)
-- returncode=-1 Java RTS error occurred (e.g. command does not exist)
-- returncode=255 o/s command failed (e.g. invalid command params)
import java.io.*;
import java.lang.*;
public class OSCommand{
public static String Run(String Command){
Runtime rt = Runtime.getRuntime();
int rc = -1;
try{
Process p = rt.exec( Command );
int bufSize = 32000;
int len = 0;
byte buffer[] = new byte[bufSize];
String s = null;
BufferedInputStream bis = new BufferedInputStream( p.getInputStream(), bufSize );
len = bis.read( buffer, 0, bufSize );
rc = p.waitFor();
if ( len != -1 ){
s = new String( buffer, 0, len );
return( s );
return( rc+"" );
catch (Exception e){
e.printStackTrace();
return( "-1\ncommand[" + Command + "]\n" + e.getMessage() );
show errors
create or replace function OSexec( cCommand IN string ) return varchar2 is
-- function: OS EXEC
-- descr: PL/SQL wrapper for the Java OSCOMMAND stored proc
language JAVA
name 'OSCommand.Run(java.lang.String) return java.lang.String';
show errors
-- Punching a hole into the Java VM sandbox. The following must be run as
-- sysdba. Substitute SCOTT with the applicable schema that owns the OSEXEC
-- and OSCOMMAND stored procs.
declare
SCHEMA varchar2(30) := 'SCOTT';
begin
dbms_java.grant_permission(
SCHEMA,
'SYS:java.io.FilePermission',
'<<ALL FILES>>',
'execute'
dbms_java.grant_permission(
SCHEMA,
'SYS:java.lang.RuntimePermission',
'writeFileDescriptor',
dbms_java.grant_permission(
SCHEMA,
'SYS:java.lang.RuntimePermission',
'readFileDescriptor',
commit;
end;
-- example: running the Unix/Linux date command to get the current date and time
SQL> select OSexec('/usr/bin/date') as STDOUT from dual;
STDOUT
Fri Sep 1 08:09:34 SAST 2006
1 row selected.
SQL>Edited by: Billy Verreynne on Sep 4, 2008 6:26 PM to make the code snippet readable with the new Jive forum s/w. -
PL/SQL vs C++ ?
I have developed an inventory control application in MS Access & VBA that has been instrumental in saving my company $6 million so far, with at least another 4 to 5 million over the next 18 months. We are a processing plant and part of a global group of mining companies. My tool has sparked interest across the group and I am about to release an evaluation copy to other sites. Our corporation is in the process of aggressively standardising on SAP (and I extract the data from our SAP system)with Oracle of various flavours being the underlying DB as far as I can tell.
Access is a superb prototyping tool and an excellent standalone platform, however I am considering something rather more professional. For example, to generate the statistical data for 23,000 items with 50 months consumption in VBA takes about 45 minutes, tests indicate the same can be done in C++ in under a minute and the last time I used PL/SQL to calculate Single Exponentially Smooothed Forecasts for the same data set it was done in a matter of seconds.
I have a little Oracle knowledge, I had been studying for certification but dropped it in favour of a B.Comp Sc which I have commenced this year. And now to the question.
What would be the best way to proceed? Learn enough PL/SQL to write the statistical and forecasting engine and use Java to develop a front end? Or C++ and Java? Or <cough> Access and <shudder> ODBC? All of this of course would depend on me convincing our corporate IT department to letting me write an application that digs under SAP, (I know when I first asked for access to SQLplus to get to our data under SAP it felt like I had offered to buy the IT managers daughter).
Looking forward to hearing what real Developers/Analysts would do ( I am but a humble storeman).Can any one tell me whether PL/SQL can totally replace
Pro*C /
Cobol?
Well Pro*C/Cobol have much more advanced features
available outside of the Oracle interface, obviously. Also
UTL_FILE is not a very fast way of producing text files if you
need very high throughput.
It is not possible or suitable to apply PL/SQL to al cases, but
if you are just producing text files and reports, no matter how
complex the formatting, PL/SQL is going to do it for you.
However my own preference is to use the minimum number
of technologies reasonably possible when doing a job. By
using Pro*C or Cobol you increase the maintenance
workload, so I would stick to PL/SQL if you can. -
Writing BLOB column from Cobol
Hi,
I´m using the Pro*Cobol pre-compile to execute SQL statements into programs Cobol Net Express.
I need two helps.
1 - How can do to the Pro*Cobol cut the blanks on the right into PIC X Varying hosts variables ?
For example :
..... LastName VARCHAR(20)
..... 05 LASTNAME PIC X(20) VARYING.
The Pro*Cobol documentation say that precompile transform the elementary item LASTNAME to the group item bellow :
05 LASTNAME.
10 LASTNAME-LEN PIC S9(04) COMP.
10 LASTNAME-ARR PIC X(20).
When a string less than 20 is moved to LASTNAME-ARR, the exact string lenght is moved to the LASTNAME-LEN and the string is writen
into DB without blanks on right.
When a string is red from DB, the precompile write into LASTNAME-LEN the exact string lenght and the LASTNAME-ARR receive the
string value without blanks on write.
Occurs that when I compile the program the Pro*Cobol/Micro Focus don´t recognize LASTNAME-LEN and LASTNAME-ARR.
Am I correct ? May I use any directive that resolve that ?
2 - I need to check these step-by-step to write a text file generated from cobol into a BLOB column.
The LOAD FROM FILE statement receive SQLCODE -22275 : Invalid LOB locator specified.
Assumptions :
MAG-RELAT-BFILE SQL-BFILE.
MAG-RELAT-BLOB SQL-BLOB.
The fiel R1401 exists in D:\Petros\NE\
Source Code :
MOVE 'D:\Petros\NE\' TO ALIAS
MOVE 13 TO ALIAS-L
MOVE 5 TO FILENAME-L
MOVE 'R1401' TO FILENAME
EXEC SQL
ALLOCATE :IMAG-RELAT-BFILE
END-EXEC.
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO ALLOCATE' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BFILE' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
EXEC SQL
LOB FILE SET :IMAG-RELAT-BFILE
DIRECTORY = :ALIAS,
FILENAME = :FILENAME
END-EXEC.
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO LOB FILE SET' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BFILE' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
EXEC SQL
ALLOCATE :IMAG-RELAT-BLOB
END-EXEC
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO ALLOCATE' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BLOB' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
EXEC SQL
LOB LOAD :TOTAL-BYTES
FROM FILE :IMAG-RELAT-BFILE
INTO :IMAG-RELAT-BLOB
END-EXEC.
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO LOAD FFOM FILE' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BFILE, IMAG-RELAT-BLOB' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
Thanks,907466 wrote:
Hi,
I´m using the Pro*Cobol pre-compile to execute SQL statements into programs Cobol Net Express.
I started my career as a cobol programmer in 1981, and the last project I worked on before transitioning to DBA was implementing MF Cobol. It's been a number of years but ...
I need two helps.
1 - How can do to the Pro*Cobol cut the blanks on the right into PIC X Varying hosts variables ?
For example :
..... LastName VARCHAR(20)
..... 05 LASTNAME PIC X(20) VARYING.
The Pro*Cobol documentation say that precompile transform the elementary item LASTNAME to the group item bellow :
05 LASTNAME.
10 LASTNAME-LEN PIC S9(04) COMP.
10 LASTNAME-ARR PIC X(20).
When a string less than 20 is moved to LASTNAME-ARR, the exact string lenght is moved to the LASTNAME-LEN and the string is writen
into DB without blanks on right.
When a string is red from DB, the precompile write into LASTNAME-LEN the exact string lenght and the LASTNAME-ARR receive the
string value without blanks on write.
Occurs that when I compile the program the Pro*Cobol/Micro Focus don´t recognize LASTNAME-LEN and LASTNAME-ARR.
Am I correct ? May I use any directive that resolve that ?
I don't know if you are correct or not. Is the pre-compiler or compiler step throwing an error message? If you are correct, there should be an error message that you should share with us.
2 - I need to check these step-by-step to write a text file generated from cobol into a BLOB column.
The LOAD FROM FILE statement receive SQLCODE -22275 : Invalid LOB locator specified.
Assumptions :
MAG-RELAT-BFILE SQL-BFILE.
MAG-RELAT-BLOB SQL-BLOB.
The fiel R1401 exists in D:\Petros\NE\
Source Code :
MOVE 'D:\Petros\NE\' TO ALIAS
MOVE 13 TO ALIAS-L
MOVE 5 TO FILENAME-L
MOVE 'R1401' TO FILENAME
EXEC SQL
ALLOCATE :IMAG-RELAT-BFILE
END-EXEC.
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO ALLOCATE' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BFILE' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
EXEC SQL
LOB FILE SET :IMAG-RELAT-BFILE
DIRECTORY = :ALIAS,
FILENAME = :FILENAME
END-EXEC.
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO LOB FILE SET' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BFILE' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
EXEC SQL
ALLOCATE :IMAG-RELAT-BLOB
END-EXEC
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO ALLOCATE' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BLOB' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
EXEC SQL
LOB LOAD :TOTAL-BYTES
FROM FILE :IMAG-RELAT-BFILE
INTO :IMAG-RELAT-BLOB
END-EXEC.
IF SQLCODE NOT EQUAL +0
MOVE 'ERRO COMANDO LOAD FFOM FILE' TO WW-CA-MENSAGEM
MOVE 'IMAG-RELAT-BFILE, IMAG-RELAT-BLOB' TO WW-CA-ARQUIVO
MOVE SQLCODE TO WW-ST-ARQUIVO
MOVE 08 TO RETURNO-CODE
PERFORM 999-TRATA-ERRO THRU 999-FIM
END-IF.
Thanks,So far you haven't shown us any symptoms, errors, etc. Just a description of what you are doing and a statement that you assume it won't work. Your executable code has a lot of reference to host variables that we can only assume a spelled correctly to match to variables you've declared in your data division. Are you going straight from submitting precompile to run-time, or are you using the very excellent interactive source-level debugger that is a prime feature of MF Cobol? -
Hi all,
I used the following code to create a new Database (ScottChangDB) and a new Table (marvel) in my SQL Server 2012 Management Studio (SSMS2012) successfully:
-- ScottChangDB.sql saved in C://Documents/SQL Server XQuery_MacLochlainns Weblog_code
-- 14 April 2015 09:15 AM
USE master
IF EXISTS
(SELECT 1
FROM sys.databases
WHERE name = 'ScottChangDB')
DROP DATABASE ScottChangDB
GO
CREATE DATABASE ScottChangDB
GO
USE ScottChangDB
CREATE TABLE [dbo].[marvel] (
[avenger_name] [char] (30) NULL, [ID] INT NULL)
INSERT INTO marvel
(avenger_name,ID)
VALUES
('Hulk', 1),
('Iron Man', 2),
('Black Widow', 3),
('Thor', 4),
('Captain America', 5),
('Hawkeye', 6),
('Winter Soldier', 7),
('Iron Patriot', 8);
SELECT avenger_name FROM marvel ORDER BY ID For XML PATH('')
DECLARE @x XML
SELECT @x=(SELECT avenger_name FROM marvel ORDER BY ID FOR XML PATH('Marvel'))--,ROOT('root'))
SELECT
person.value('Marvel[4]', 'varchar(100)') AS NAME
FROM @x.nodes('.') AS Tbl(person)
ORDER BY NAME DESC
--Or if you want the completed element
SELECT @x.query('/Marvel[4]/avenger_name')
DROP TABLE [marvel]
Now I am trying to create my first XML Schema Collection to do the Validation on the Field Name (Column Title) of the "marvel" Table. I have studied Chapter 4 XML SCHEMA COLLECTIONS of the book "Pro SQL Server 2008 XML" written by
Michael Coles (published by Apress) and some beginning pages of XQuery Language Reference, SQL Server 2012 Books ONline (published by Microsoft). I mimicked Coles' Listing 04-05 and I wanted to execute the following first-drafted sql in
my SSMS2012:
-- Reference [Scott Chang modified Listing04-05.sql of Pro SQL Server 2008 XML by Michael Coles (Apress)]
-- [shcColes04-05.sql saved in C:\\Documents\XML_SQL_Server2008_code_Coles_Apress]
-- [executed: 2 April 2015 15:04 PM]
-- shcXMLschemaTableValidate1.sql in ScottChangDB of SQL Server 2012 Management Studio (SSMS2012)
-- saved in C:\Documents\XQuery-SQLServer2012
tried to run: 15 April 2015 ??? AM
USE ScottChangDB;
GO
CREATE XML SCHEMA COLLECTION dbo. ComplexTestSchemaCollection_all
AS
N'<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="marvel">
<xsd:complexType>
<xsd:all>
<xsd:element name="avenger_name" />
<xsd:element name="ID" />
</xsd:all>
</xsd:complexType>
</xsd:element>
</xsd:schema>';
GO
DECLARE @x XML (dbo. ComplexTestSchemaCollection_all);
SET @x = N'<?xml version="1.0"?>
<marvel>
<avenger_name>Thor</name>
<ID>4</ID>
</marvel>';
SELECT @x;
GO
DROP XML SCHEMA COLLECTION dbo.ComplexTestSchemaCollection_all;
GO
I feel that drafted sql is very shaky and it needs the SQL Server XML experts to modify to make it work for me. Please kindly help, exam the coding of my shcXMLTableValidate1.sql and modify it to work.
Thanks in advance,
Scott ChangHi Scott,
2) Yes, FOR XML PATH clause converts relational data to XML format with a specific structure for the "marvel" Table. Regarding validate all the avenger_names, please see below
sample.
DECLARE @x XML
SELECT @x=(SELECT ID ,avenger_name FROM marvel FOR XML PATH('Marvel'))
SELECT @x
SELECT
n.value('avenger_name[1]','VARCHAR(99)') avenger_name,
n.value('ID[1]','INT') ID
FROM @x.nodes('//Marvel') Tab(n)
WHERE n.value('ID[1]','INT') = 1 -- specify the ID here
--FOR XML PATH('Marvel') --uncommented this line if you want the result as element type
3)i.check the xml schema content
--find xml schema collection
SELECT ss.name,xsc.name collection_name FROM sys.xml_schema_collections xsc JOIN sys.schemas ss ON xsc.schema_id= ss.schema_id
select * from sys.schemas
--check the schema content,use the name,collection_name from the above query
SELECT xml_schema_namespace(N'name',N'collection_name')
3)ii. View can be viewed as virtual table. Use a view to list the XML schema content.
CREATE VIEW XSDContentView
AS
SELECT ss.name,xsc.name collection_name,cat.content
FROM sys.xml_schema_collections xsc JOIN sys.schemas ss ON xsc.schema_id= ss.schema_id
CROSS APPLY(
SELECT xml_schema_namespace(ss.name,xsc.name) AS content
) AS cat
WHERE xsc.name<>'sys'
GO
SELECT * FROM XSDContentView
By the way, it would be appreciated if you can spread your questions into posts. For any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Oracle 11g and PRO*C : pre-compile errors only with 11g !
Hi !
I didn't find a forum specific to pro*c, so here i am.
I've downloaded Oracle 11g and recompiled our applications using pro*c
We currently precompiling without any problem our sources against Oracle 7, 8, 9, 10.
With Oracle 11g, it doesn't work !
every EXEC SQL followed by a command works.
every EXEC SQL followed by a query generates the same error.
Example :
char *oracle_date_courante()
static char buf[SIZE_ORADATE+1];
EXEC SQL SELECT sysdate into :buf from DUAL;
if(ORA_SQLERROR())
oracle_error("sélection date courante");
buf[0]=0;
return buf;
PRO*C output :
Erreur Ó la ligne 105, colonne 2 dans le fichier src\oracle.pc
EXEC SQL
.1
PLS-S-00000, SQL Statement ignored
erreur sÚmantique Ó la ligne 105, colonne 2, fichier src\oracle.pc:
EXEC SQL
.1
PCC-S-02346, PL/SQL a trouvÚ des erreurs sÚmantiques
So, we investigated... And found that thoses errors come when we use the option sqlcheck=semantics.
If we use an inferiour check level, it works but because we use PL/SQL keywords, pro*c prints errors and wants us to provide the 'semantics' sqlcheck level !
So, it's a vicious circle !
Any ideas ?
Thanks...
VincentAdding the option common_parser=yes removes the errors !
But brings errors linked to the PL/SQL parser such like
CSF-S-00000, ORA-06544: PL/SQL : erreur interne, arguments : [55916], [], [], []
1>, [], [], [], []
1>ORA-06553: PLS-801: erreur interne [55916]
Really vicious..and still not precompiling !
By the way : Server is 10.2.0.1... and i guess thoses errors are normal since the common parser is not available in this version...
So bye bye option common_parser and i'm back to my orignals errors.
Message was edited by:
Vicenzo
Maybe you are looking for
-
My airplay button will not show up on any of my devices anymore.
My airplay button no longer will show up on any of my devices. I have the new Ipad, Iphone 4s, Ipod touch, and macbook pro. Every device is on the same wifi network and the network is secure and 100% strong. I was just using airplay yesterday and now
-
Document entry - header fields status?? control of posting/document date.
Hi all, I have a question regarding document date and posting date fields. I wonder if it is possible to make these fields display only and of course make the field document date obtain a value from the posting date field, which by default is the tod
-
hi everyone i just updated my nokia lumia 1020 to the new lumia black software. the problem is that after doing the update, raw support doesn't show under camera settings, neither story teller, neither live folder. does anybody have a solution?
-
Billing Plan Tab required in Sales Order - Item Level
Hi, I am trying to create a Sales Order, in which at Item level I also require Billing Plan Tab. This is for scenario Periodic billing & milestone billing. If you could also help with configuration & business process document of Periodic & milestone
-
Hi I am new to this forum and wanted to ask how to take digital input from external switches I am making a project which needs to control different sections of a labview project design file via a footswitch ,the switches i will be using are momentary