Datatype equivalent of long[]
Hi all,
If my java stored procedure returns a datatype of long[] , what should the return type of my stored function ?
Andy,
I suggest a Oracle nested table type.
create type LONG_ARRAY as table of numberGood Luck,
Avi.
Similar Messages
-
Equivalent rect long and short sides
Not so sure if anybody else already came across this problem or not. Any suggestion is welcome.
I have a simple isolated object to be fitted into an ideal rectangle which will then be used for a metrology purpose in following step. I was trying to make use of the equivalent rect long and shot sides from particle analysis operation, but it seems the particle analysis always gives a same value to the long side and short side. Attached picture shows the calculation results from vision assistant. I tried to calculate the equivalent rect sides from the given area and perimeter. The results tends to become complex values as the perimeter seems smaller than it should be(i.e.. P^2 smaller than 16*A). It may be one reason to produce same value to equivalent rect long and short side.
PS: the expression for calculation of equivalent rect long and short side in the page: http://zone.ni.com/reference/en-XX/help/372916L-01/nivisionconcepts/particle_measurements/ seems not right. It should be (P-sqrt(P^2-16A))/4, rather than P/4-sqrt(P^2-16A).
Attachments:
results from vision assistant.jpg 131 KB
ROI.jpg 8 KBHi paris_sun,
I am assuming you are using the latest version of Vision Assistant 2011 SP1.
I would just like to clarify what you are trying to achieve. This is to measure the long and short (length and width) side of a rectangular shape in your image by using:
Processing Functions: Binary >> Particle analysis
Something I could suggest is to play around with a more definative rectangle and see if this helps. I have tried using a rectangle and the measurements have come out fine.
The shape you are measuring happens to have the same size dimensions i.e. a square.
Where are you acquiring your image from? And are you expecting it to be a square?
With regards to the formulas being incorrect I will look into this for you.
Kev R
Kevin R
Applications Engineer
National Instruments UK&Ireland
Attachments:
NI Vision Rectangle.jpg 373 KB
Rectangle.jpg 8 KB -
Error: PL/SQL ORA-00932 inconsistent datatype when using LONG value
Good morning:
I am using a work PL/SQL script where I am using a LONG value in a cursor. When I execute it, I am receiving:
PL/SQL ORA-00932 inconsistent datatype: expected NUMBER got LONG
set serveroutput ON SIZE 1000000
set heading off
set feedback off
set trimspool off
set echo off
set term off
set pagesize 0
SPOOL &so_outfile;
DECLARE
v_data_file varchar2(30);
-- v_sch_code varchar2(10);
-- v_instance_name varchar2(10);
ws_path payroll.pybutfl.pybutfl_utl_file_path%TYPE;
v_data_line VARCHAR2 (2000) := NULL;
fhandle_o UTL_FILE.file_type;
v_line_count NUMBER := 0;
v_selected_count NUMBER := 0;
v_error_count NUMBER := 0;
v_written_count NUMBER := 0;
v_error_text VARCHAR2 (50) := ' AMACONF_ERR: Unable to write the line. ';
v_errm VARCHAR2 (255);
v_sqlerrm VARCHAR2 (255);
v_payment_type VARCHAR2(10);
CURSOR C1 IS
select RTRIM
AMRCONF_PIDM_ERR ||'|'||
AMRCONF_IDEN_CODE_ERR ||'|'||
AMRCONF_ENTRY_DATE_ERR ||'|'||
AMRCONF_CONFID_IND_ERR ||'|'||
*AMRCONF_COMMENT_ERR ||'|'||*
AMRSUBJ_SUBJ_CODE_ERR ||'|'||
ERROR_CODE ||'|'||
ERROR_CODE_TEXT ) data_line
from WSUALUMNI.AMRCONF_ERR;
BEGIN
DBMS_OUTPUT.put_line ('Program Generating AMACOMT Mass Update Error File ');
IF UTL_FILE.is_open (fhandle_o)
THEN
UTL_FILE.fclose (fhandle_o);
END IF;
/* Name The File Here */
v_data_file := ('Amaconf_error.txt');
SELECT RTRIM (pybutfl_utl_file_path)
INTO ws_path
FROM payroll.pybutfl;
fhandle_o := UTL_FILE.fopen (ws_path, v_data_file, 'w');
DBMS_OUTPUT.put_line ('UTLFILE file for this run is: ' || ws_path||'/'||v_data_file);
v_written_count := 0;
FOR c1_rec IN C1 LOOP
BEGIN
v_selected_count := v_selected_count + 1;
v_data_line := rtrim(c1_rec.data_line);
UTL_FILE.put_line (fhandle_o, v_data_line);
v_written_count := v_written_count + 1;
EXCEPTION
WHEN OTHERS
THEN
DBMS_OUTPUT.put_line (v_error_text);
v_error_count := v_error_count + 1;
END;
END LOOP;
DBMS_OUTPUT.put_line ('Number of Records Selected: ' || v_selected_count);
DBMS_OUTPUT.put_line ('Number of Records Written: ' || v_written_count);
IF UTL_FILE.is_open (fhandle_o)
THEN
UTL_FILE.fclose (fhandle_o);
END IF;
END;
SPOOL OFF;If I comment out the "AMRCONF_COMMENT_ERR ||'|'||" line, then the script works fine. The table was created as:
Create Table WSUALUMNI.AMRCONF_ERR
AMRCONF_PIDM_ERR NUMBER (8) NOT NULL,
AMRCONF_IDEN_CODE_ERR VARCHAR2(5) NOT NULL,
AMRCONF_ENTRY_DATE_ERR DATE NOT NULL,
AMRCONF_CONFID_IND_ERR VARCHAR2(1),
AMRCONF_COMMENT_ERR LONG,
AMRSUBJ_SUBJ_CODE_ERR VARCHAR2(5) NOT NULL,
ERROR_CODE VARCHAR2(12) NOT NULL,
ERROR_CODE_TEXT VARCHAR2(50) NOT NULL
); I don't get what is the problem here in the script.Hi,
Feew suggestions
1) LONG is a deprecated type hence if possible start working on changing that column
2) CLOB will your preferred datatype over LONG.
3) you cannot use RTRIM on long.
here is a very quick example
drop table h
create table h (x long,y varchar2(100))
select rtrim(x) from h
select rtrim(y) from hSolution:
[http://www.oracle.com/technology/oramag/code/tips2003/052503.html]
need a better solution change the datatype to clob and
drop table h
create table h (x clob,y varchar2(100))
select dbms_lob.substr( x, 4000, 1 ) from h
select rtrim(y) from hCheers!!!
Bhushan -
ORA - 00997 Illegal Use Of Long Datatype when no Long is used
I have a query that was working fine for years. We have upgraded to 10.2.0.5 on a test instance and we now get this error.
The view in the FROM clause is an org specific view on xxc_affi_relation_headers_all. All of the fields in the view and underlying table are either VARCHAR2, NUMBER, or DATE.
I have simplified the query to one that still gives the error.
The query is:
SELECT *
FROM xxc_affi_relation_headers xarh
WHERE xarh.affi_relation_id = (select xarh.affi_relation_id
from xxc_affi_relation_headers xarh
where xarh.execute_vendor_id = 125
connect by prior xarh.affi_relation_id = xarh.parent_relation_id
start with xarh.affi_relation_id = 214
If I run the sub query by itself, as below, there is no error and the result is 214.
select xarh.affi_relation_id
from xxc_affi_relation_headers xarh
where xarh.execute_vendor_id = 125
connect by prior xarh.affi_relation_id = xarh.parent_relation_id
start with xarh.affi_relation_id = 214
If I run the main query and replace the sub query with 214, as below, thre is no error.
Is there something that would cause an implicit conversion to a LONG datatype in this query? I am not able to find a reason for this error message that fits the query.
The original query that caused the error was:
SELECT xarh.affi_relation_id
FROM
xxc_affi_relation_headers xarh
WHERE NOT EXISTS (SELECT 1 FROM xxc_oe_order_line_dist xold
WHERE xold.line_id = p_line_id AND xold.dist_type = 'I'
AND xold.affi_relation_id = xarh.affi_relation_id)-- 1704
AND v_creation_date
BETWEEN NVL(xarh.start_date,v_creation_date-1) AND NVL(xarh.end_date,v_creation_date+1) --ES fix not a valid month
AND xarh.sale_segment1 = (SELECT gcco.segment1 --RT 9631
FROM oe_transaction_types_all otty, ra_cust_trx_types_all rctt, gl_code_combinations gcco
WHERE otty.transaction_type_id = p_order_type_id
AND otty.cust_trx_type_id = rctt.cust_trx_type_id
AND rctt.gl_id_rev = gcco.code_combination_id )
AND EXISTS(SELECT 1 FROM xxc_affi_relation_lines xarl WHERE xarl.affi_relation_id = xarh.affi_relation_id
AND NVL(xarl.element_value,v_item_type) = v_item_type)
connect by prior xarh.parent_relation_id = xarh.affi_relation_id
Start with
xarh.affi_relation_id = (select xarh.affi_relation_id
from xxc_affi_relation_headers xarh
where xarh.execute_vendor_id = p_vendor_id
AND xarh.affi_relation_id != p_parent_relation_id
AND NOT EXISTS (SELECT 1 FROM xxc_affi_relation_headers xarh2
WHERE xarh2.parent_relation_id = xarh.affi_relation_id)
AND v_creation_date BETWEEN NVL(xarh.start_date,v_creation_date-1) AND NVL(xarh.end_date,v_creation_date+1)--ES fix not a valid month
start with xarh.affi_relation_id = p_parent_relation_id
connect by prior xarh.affi_relation_id = xarh.parent_relation_id)
--ORDER BY NVL(parent_relation_id,-1), NVL2(xarl.element_value,1,2)
;Its a bug
See this Oracle Document
Bug 9726739 - ORA-997 from SQL with CONNECT BY and UNION [ID 9726739.8]
Best Regards
mseberg -
Create a table in SQL with datatype equivalent to LongBlob
I have a mySQL or phpMyadmin table (nor sure) (with longblob fields) that I want to convert to SQL Server.
Here is a link to a Rar with two files, the 'ORIGINAL CODE.sql' is the original code sample and the 'NEW_SQL_CODE.sql' is the code I am writing in SQL to create a database.
Click to download the two files.
I fail to make the insert in the 'NEW_SQL_CODE.sql', it says (translated from spanish) something like "The binary data will be truncated"
INSERT INTO inmuebles_fotos (ci_inm, pos, foto, mini, comentario, inet, impr_cartel, impr_visita) VALUES
(6, 0, 0xffd8ffe000104a46494600010100000100010...etc...
I don’t know how if I have defined the wrong data type (image) equivalent to the MySQL LongBlob. All I want to do is to make that insert in SQL and save that image as jpg if possible. I don't know if it's not posible in SQL and can only
be done in MySQL.
Thanks for any help.The original table is not mine; I am just trying to save the images as .jpg in hard drive.
Here is the original table I have that has 500Mb in pictures, in the sample there is only 1 picture:
CREATE TABLE IF NOT EXISTS `inmuebles_fotos` (
`ci_inm` int(10) unsigned DEFAULT NULL,
`pos` smallint(6) DEFAULT NULL,
`foto` longblob,
`mini` longblob,
`comentario` varchar(100) DEFAULT NULL,
`inet` tinyint(3) unsigned DEFAULT '0',
`impr_cartel` smallint(6) DEFAULT '0',
`impr_visita` smallint(6) DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
And here is the equivalent table in SQL that I am trying to create to import al registers so I can save the pictures from SQL Server that is what we use here.
CREATE TABLE [dbo].[inmuebles_fotos2](
[ci_inm] [int] NULL,
[pos] [int] NULL,
[foto] [image] NULL,
[mini] [image] NULL,
[comentario] [varchar](1) NULL,
[inet] [int] NULL,
[impr_cartel] [int] NULL,
[impr_visita] [int] NULL
Sorry for the trouble, I am trying everything I get my hands on until I get to save those images in “0x1234567890ABCDE…….” Format.
I'll try anything you sugest me but I have only use SQL Server so that's why I'm trying this road first.
Thanks for your help. -
HS generic and long datatypes in Oracle 8i
I have a problem importing LONG datatype columns
from Hyperion Pillar to Oracle (version 8.1.6.0.0) using
the (Hyperion supplied) ODBC driver and generic HS.
The error message I get is
ORA-03001: unimplemented feature
ORA-02063: preceding line from PILLAR.WORLD
From the message it seems clear that Oracle cannot
deal with longs using generic connectivity (at least
in v. 8.1.6).
My questions:
1) Is there a workaround ?
2) Does this work in 9i ?
Notes:
1) The problem is not with the ODBC driver, as I
can see the long datatype columns using another
tool which connects to Pillar via ODBC.
2) HS has been set up correctly because all datatypes
other than long can be viewed in Oracle without any
problems.
3) Operating System: Windows NT 4.00.1381
Any help would be much appreciated!
Kailash.Thanks for the reply.
Pillar LONGS (or MEMO, as they are referred to in Pillar)
map to ODBC SQL_LONGVARCHAR. So it appears that the
mapping is OK, and that SELECTing from these columns
should be possible via generic connectivity.
Any other ideas on what may be wrong? Any help is
much appreciated.
Thanks,
Kailash. -
How to process a large XML string passed to a LONG variable?
I am attempting to extract and loop through some XML that is stored in a variable (v_xml_string) that is defined as LONG data type. However, I am receiving an ORA-01460: unimplemented or unreasonable conversion requested when the string value exceeds 20 records in the XML layout below. When I performed a LENGHTB on a sample XML string containing 19 records (just below the threshold of erroring), I get 3895, which I'm assuming is in BYTES...this is not near the 32,760 byte limit of PL/SQL variables defined as LONG. I suppose my other alternative is that I use CLOB datatype instead of LONG.
XML layout:
<?xml version="1.0"?>
<DocumentElement>
<tblElections>
<EmpID>872G4</EmpID>
<MgrNTID>JohnDoe</MgrNTID>
<Entity>050595</Entity>
<AddlAmt>1000</AddlAmt>
<CheckedForSave>Y</CheckedForSave>
</tblElections>
</DocumentElement>sample of code where error appers to be occurring:
DECLARE
v_xml_string LONG;
BEGIN
FOR v_xml_rec IN (SELECT t.COLUMN_VALUE.extract('/tblElections/EmpID/text()') .getStringVal() EmpID,
t.COLUMN_VALUE.extract('/tblElections/MgrNTID/text()') .getStringVal() MgrNTID,
t.COLUMN_VALUE.extract('/tblElections/FAEntity/text()') .getStringVal() FAEntity,
t.COLUMN_VALUE.extract('/tblElections/AddlSLEAAmt/text()') .getStringVal() AddlSLEAAmt,
t.COLUMN_VALUE.extract('/tblElections/CheckedForSave/text()') .getStringVal() CheckedForSave
FROM TABLE(xmlsequence(XMLTYPE(v_xml_string) .extract('/DocumentElement/tblElections'))) t)
LOOP
... <do some stuff here>
END LOOP;
END;Strings in SQL are limited to 4000 in length, the long variable will work up to 32K as long as it is not used in SQL, if it goes over 4000 you will get the error.
SQL> declare
2 l long;
3 begin
4 l := rpad('x',32000,'x');
5 dbms_output.put_line('length is : ' || to_char(length(l)));
6 end;
7 /
length is : 32000
PL/SQL procedure successfully completed.
SQL> edi
Wrote file afiedt.sql
1 declare
2 l long;
3 n number;
4 begin
5 l := rpad('x',32000,'x');
6 select length(l) into n from dual;
7 dbms_output.put_line('length is : ' || to_char(n));
8* end;
SQL> /
declare
ERROR at line 1:
ORA-01460: unimplemented or unreasonable conversion requested
ORA-06512: at line 6
SQL> edi
Wrote file afiedt.sql
1 declare
2 l long;
3 n number;
4 begin
5 l := rpad('x',4000,'x');
6 select length(l) into n from dual;
7 dbms_output.put_line('length is : ' || to_char(n));
8* end;
SQL> /
length is : 4000
PL/SQL procedure successfully completed.
SQL> edi
Wrote file afiedt.sql
1 declare
2 l long;
3 n number;
4 begin
5 l := rpad('x',4001,'x');
6 select length(l) into n from dual;
7 dbms_output.put_line('length is : ' || to_char(n));
8* end;
SQL> /
declare
ERROR at line 1:
ORA-01460: unimplemented or unreasonable conversion requested
ORA-06512: at line 6
SQL> -
Lightroom 4 resizing on export feature - using the "long edge" resize option - doesn't seem to work
In previous versions of Lightroom (prior to 4), when I used the resize feature while exporting, I often used the "long edge" value to resize.
Previously, when I selected 2500 as the "long edge" value, I would receive exported JPGs in a size of something like 2500x1650 or so for landscape shots and 1650x2500 for portrait shots.
With LR 4 (not sure if this started with the RCs or 4.0), using the same settings, I'm getting landscape shots that are 3700x2500 and portrait shots that are 1650x2500. This is acting more like I said I wanted a dimensional resize of _____ X 2500 instead of long edge of 2500.
I tried playing around with some of these settings, but nothing seems to give me the old behavior of 2500 on the long edge, even though that's what I've set it for.
Anyone else seen this type of issue?
I'm currently running LR 4 RC2, but also noticed this on RC1, but not sure of 4.0. I'm a Mac user, running the current version of Lion (10.7.3) on a 2010 Mac Pro.
Thanks,
MarkWith RC2 on Windows 7 (64 Bit) I get 2500x1667 for landscape and 1667x2500 for portrait, as expected. Seems to be an issue in the Mac version only.
A workaround might be to use "dimensions" instead and leave one of the fields empty (LR inserts "0" there, but one cannot enter "0" manually). I think this is equivalent to "long edge", but I am not 100% sure (edit: ok, I think I am nearly sure that it is). -
FRM-40831 : Truncation occured: value too long for filed MAST_EMP_NAME
Hi
I'm using Forms 5 and getting following error.
FRM-40831 : Truncation occured: value too long for filed MAST_EMP_NAME.
When i checked in the column Mast_emp_name, all the values are with in the limit.
Table contains some 9 lacs record.
Please help me. this is very urgentcheck the maximum length - property of all those 5 columns in your form. They have to be as long as in the database. Except number. They have to be 1 char longer than in the db.
Forms-Online-Help says:
This property can potentially limit the amount of data that an item is allowed to contain internally (in the Forms server) when it's in native format. It can also potentially limit the number of character (or bytes) displayed or entered by the end user. That is, it can specify a data limit and/or a user interface (UI) limit. The exact effect depends upon several factors, including the item's Data type, Data Length Semantics, and Format Mask properties. For a character item (datatypes CHAR, ALPHA, LONG), the Maximum Length property specifies a data limit. The property value specifies either the maximum number of bytes or else the maximum number of characters, depending upon the value of the Data Length Semantics property. Within a group of character mirror items, the Maximum Length property is always taken from the master mirror item. A compiler (generator) warning is issued if a non-zero non-default value is specified in a subordinate mirror item. If a character item has no format mask (the Format Mask property is null), then the Maximum Length property (taken from the master mirror item) also specifies a UI limit. When the Forms server is using the UTF8 character set , this UI limit has the same semantics (byte versus character) as the data limit. When the Forms server is using a multi-byte character set other than UTF8, and the Data Length Semantics property specifies byte semantics, Forms cannot prevent the end user from typing in too many bytes. Instead, it uses character semantics for the UI limit. In such a case, the end user is allowed to type in too many bytes. When the end user attempts to navigate out of the current validation unit, one of two things will happen. If the application property FLAG_USER_VALUE_TOO_LONG is set, an error will be flagged and the excess characters on the right will be selected. If this application property is not set, the excess characters will be quietly truncated, and the navigation will succeed. If a character item has a format mask, then the item's UI limit is derived from the format mask. This limit is always a character limit. For a number item (datatypes NUMBER, INT, MONEY, RNUMBER, RINT, RMONEY), the Maximum Length property specifies a user interface limit. This limit is always a character limit. There is no data limit. The data item can always internally hold up to 23 bytes (which is the maximum size of an Oracle number in native format), regardless of the value of the Maximum Length property. For a date or time item (datatypes DATETIME, DATE, TIME, JDATE, EDATE), the Maximum Length property specified in Forms Builder has almost no effect (See the Query Length property for a discussion of the only effect). As with "number" items, there is no data limit. For DATE and DATETIME items, the internal value is 7 bytes long, and for TIME, JDATE and EDATE items, the internal value is 4 bytes long . The user interface limit is derived from the format mask. This limit is always a character limit which is what is returned by GET_ITEM_PROPERTY(item, MAX_LENGTH). -
UTF-16 datatypes in Solaris 10
Unicode datatypes in Solaris support UTF-32. The datatype wchar_t is 4 bytes long. Are there datatypes in Solaris that support 2 bytes instead of 4?
I require this to support UTF-16 in my application. This is because my application "talks" to a Windows client (via an interface shared between Solaris and Windows) that supports Unicode datatypes 2 bytes long. (wchar_t is 2 bytes long in Windows).Ah, one of the guys I work with figured it out. /etc/services file was messed up. It's working now. :)
-
Can I increase the size of a Long column to 4000 characters?
Can I increase the size of a Long column to 4000 characters?
maximum sizeof 4 GB -1 byte RTFM there: Datatypes(click)
extracted: LONG: Character data of variable length up to 2 gigabytes, or 231 -1 bytes.
Not 4Gb. Or also, read Paul M post.
Regards,
Yoann. -
LONG - instr & insert..select
Hi,
Two queries:
a) How to search for a character/combination of characters in a LONG column
b) How to take a backup of a table which contains LONG column (might contain columns of other datatypes like number, varchar etc.)
I tried using INSTR and CREATE(INSERT)..SELECT options but both failed with errors.
SQL> CREATE TABLE T1(C1 LONG);
Table created
SQL> INSERT INTO T1 VALUES (';Z00:101CGEZZP1904300M5');
1 row inserted
SQL> SELECT INSTR(C1,'ZP') FROM T1;
SELECT INSTR(C1,'ZP') FROM T1
ORA-00932: inconsistent datatypes: expected NUMBER got LONG
SQL> CREATE TABLE T2 AS SELECT * FROM T1;
CREATE TABLE T2 AS SELECT * FROM T1
ORA-00997: illegal use of LONG datatype
SQL>Hi,
LONG is an old format with a bunch of limitations which will make your life miserable. If you need to copy your table to another one, use this opportunity to convert LONG to CLOB using to_lob() function.
create table t1(id long);
create table t2 (id clob);
insert into t2 (id) select to_lob(id) from t1;Best regards,
Nikolay -
Pro*c multithreaded application has memory leak
Hi there,
I posted this message a week ago in OCI section, nobody answer me.
I am really curious if my application has a bug or the pro*c has a bug.
Anyone can compile the sample code and test it easily.
I made multithreaded application which queries dynamic SQL, it works.
But the memory leaks when i query the SQL statement.
The more memory leaks, the more i query the SQL statement, even same SQL
statement.
I check it with top, shell command.
My machine is SUN E450, Solaris 8. Oracle 9.2.0.1
Compiler : gcc (GCC) 3.2.2
I changed source code which is from
$(ORACLE_HOME)/precomp/demo/proc/sample10.pc
the sample10 doesn't need to be multithreaded. But i think it has to work
correctly if i changed it to multithreaded application.
the make file and source code will be placed below.
I have to figure out the problem.
Please help
Thanks in advance,
the make file is below
HOME = /user/jkku
ORA = $(ORACLE_HOME)
CC = gcc
PROC = proc
LC_INCL = -I$(HOME)/work/dbmss/libs/include
lc_incl = include=$(HOME)/work/dbmss/libs/include
SYS_INCL =
sys_incl =
ORA_INCL = -I. \
-I$(ORA)/precomp/public \
-I$(ORA)/rdbms/public \
-I$(ORA)/rdbms/demo \
-I$(ORA)/rdbms/pbsql/public \
-I$(ORA)/network/public \
-DSLMXMX_ENABLE -DSLTS_ENABLE -D_SVID_GETTOD
INCLUDES = $(LC_INCL) $(SYS_INCL) $(ORA_INCL)
includes = $(lc_incl) $(sys_incl)
LC_LIBS =
SYS_LIBS = -lpthread -lsocket -lnsl -lrt
ORA_LIBS = -L$(ORA)/lib/ -lclntsh
LIBS = $(LC_LIBS) $(SYS_LIBS) $(ORA_LIBS)
# Define C Compiler flags
CFLAGS += -D_Solaris64_ -m64
CFLAGS += -g -D_REENTRANT
# Define pro*c Compiler flags
PROCFLAGS += THREADS=YES
PROCFLAGS += CPOOL=YES
# Our object files
PRECOMPS = sample10.c
OBJS = sample10.o
.SUFFIXES: .o .c .pc
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $*.c
.pc.c:
$(PROC) $(PROCFLAGS) $(includes) $*.pc $*.c
all: sample10
sample10: $(PRECOMPS) $(OBJS)
$(CC) $(CFLAGS) -o sample10 $(OBJS) $(LIBS)
clean:
rm -rf *.o sample10 sample10.c
the source code is below which i changed the oracle sample10.pc to
multithreaded application.
Sample Program 10: Dynamic SQL Method 4
This program connects you to ORACLE using your username and
password, then prompts you for a SQL statement. You can enter
any legal SQL statement. Use regular SQL syntax, not embedded SQL.
Your statement will be processed. If it is a query, the rows
fetched are displayed.
You can enter multi-line statements. The limit is 1023 characters.
This sample program only processes up to MAX_ITEMS bind variables and
MAX_ITEMS select-list items. MAX_ITEMS is #defined to be 40.
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <sqlda.h>
#include <stdlib.h>
#include <sqlcpr.h>
/* Maximum number of select-list items or bind variables. */
#define MAX_ITEMS 40
/* Maximum lengths of the names of the
select-list items or indicator variables. */
#define MAX_VNAME_LEN 30
#define MAX_INAME_LEN 30
#ifndef NULL
#define NULL 0
#endif
/* Prototypes */
#if defined(__STDC__)
void sql_error(void);
int oracle_connect(void);
int alloc_descriptors(int, int, int);
int get_dyn_statement(void);
void set_bind_variables(void);
void process_select_list(void);
void help(void);
#else
void sql_error(/*_ void _*/);
int oracle_connect(/*_ void _*/);
int alloc_descriptors(/*_ int, int, int _*/);
int get_dyn_statement(/* void _*/);
void set_bind_variables(/*_ void -*/);
void process_select_list(/*_ void _*/);
void help(/*_ void _*/);
#endif
char *dml_commands[] = {"SELECT", "select", "INSERT", "insert",
"UPDATE", "update", "DELETE", "delete"};
EXEC SQL INCLUDE sqlda;
EXEC SQL INCLUDE sqlca;
EXEC SQL BEGIN DECLARE SECTION;
char dyn_statement[1024];
EXEC SQL VAR dyn_statement IS STRING(1024);
EXEC SQL END DECLARE SECTION;
EXEC ORACLE OPTION (ORACA=YES);
EXEC ORACLE OPTION (RELEASE_CURSOR=YES);
SQLDA *bind_dp;
SQLDA *select_dp;
/* Define a buffer to hold longjmp state info. */
jmp_buf jmp_continue;
char *db_uid="dbmuser/dbmuser@dbmdb";
sql_context ctx;
int err_sql;
enum{
SQL_SUCC=0,
SQL_ERR,
SQL_NOTFOUND,
SQL_UNIQUE,
SQL_DISCONNECT,
SQL_NOTNULL
int main()
int i;
EXEC SQL ENABLE THREADS;
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
/* Connect to the database. */
if (connect_database() < 0)
exit(1);
EXEC SQL CONTEXT USE :ctx;
/* Process SQL statements. */
for (;;)
/* Allocate memory for the select and bind descriptors. */
if (alloc_descriptors(MAX_ITEMS, MAX_VNAME_LEN, NAME_LEN) != 0)
exit(1);
(void) setjmp(jmp_continue);
/* Get the statement. Break on "exit". */
if (get_dyn_statement() != 0)
break;
EXEC SQL PREPARE S FROM :dyn_statement;
EXEC SQL DECLARE C CURSOR FOR S;
/* Set the bind variables for any placeholders in the
SQL statement. */
set_bind_variables();
/* Open the cursor and execute the statement.
* If the statement is not a query (SELECT), the
* statement processing is completed after the
* OPEN.
EXEC SQL OPEN C USING DESCRIPTOR bind_dp;
/* Call the function that processes the select-list.
* If the statement is not a query, this function
* just returns, doing nothing.
process_select_list();
/* Tell user how many rows processed. */
for (i = 0; i < 8; i++)
if (strncmp(dyn_statement, dml_commands, 6) == 0)
printf("\n\n%d row%c processed.\n", sqlca.sqlerrd[2], sqlca.sqlerrd[2] == 1 ? '\0' : 's');
break;
/* Close the cursor. */
EXEC SQL CLOSE C;
/* When done, free the memory allocated for pointers in the bind and
select descriptors. */
for (i = 0; i < MAX_ITEMS; i++)
if (bind_dp->V != (char *) 0)
free(bind_dp->V);
free(bind_dp->I); /* MAX_ITEMS were allocated. */
if (select_dp->V != (char *) 0)
free(select_dp->V);
free(select_dp->I); /* MAX_ITEMS were allocated. */
/* Free space used by the descriptors themselves. */
SQLSQLDAFree(ctx, bind_dp);
SQLSQLDAFree(ctx, select_dp);
} /* end of for(;;) statement-processing loop */
disconnect_database();
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL COMMIT WORK RELEASE;
puts("\nHave a good day!\n");
return;
* Allocate the BIND and SELECT descriptors using sqlald().
* Also allocate the pointers to indicator variables
* in each descriptor. The pointers to the actual bind
* variables and the select-list items are realloc'ed in
* the set_bind_variables() or process_select_list()
* routines. This routine allocates 1 byte for select_dp->V
* and bind_dp->V, so the realloc will work correctly.
alloc_descriptors(size, max_vname_len, max_iname_len)
int size;
int max_vname_len;
int max_iname_len;
int i;
* The first sqlald parameter determines the maximum number of
* array elements in each variable in the descriptor. In
* other words, it determines the maximum number of bind
* variables or select-list items in the SQL statement.
* The second parameter determines the maximum length of
* strings used to hold the names of select-list items
* or placeholders. The maximum length of column
* names in ORACLE is 30, but you can allocate more or less
* as needed.
* The third parameter determines the maximum length of
* strings used to hold the names of any indicator
* variables. To follow ORACLE standards, the maximum
* length of these should be 30. But, you can allocate
* more or less as needed.
if ((bind_dp =
SQLSQLDAAlloc(ctx, size, max_vname_len, max_iname_len)) ==
(SQLDA *) 0)
fprintf(stderr,
"Cannot allocate memory for bind descriptor.");
return -1; /* Have to exit in this case. */
if ((select_dp =
SQLSQLDAAlloc(ctx, size, max_vname_len, max_iname_len)) == (SQLDA *)
0)
fprintf(stderr,
"Cannot allocate memory for select descriptor.");
return -1;
select_dp->N = MAX_ITEMS;
/* Allocate the pointers to the indicator variables, and the
actual data. */
for (i = 0; i < MAX_ITEMS; i++) {
bind_dp->I = (short *) malloc(sizeof (short));
select_dp->I = (short *) malloc(sizeof(short));
bind_dp->V = (char *) malloc(1);
select_dp->V = (char *) malloc(1);
return 0;
int get_dyn_statement()
char *cp, linebuf[256];
int iter, plsql;
for (plsql = 0, iter = 1; ;)
if (iter == 1)
printf("\nSQL> ");
dyn_statement[0] = '\0';
fgets(linebuf, sizeof linebuf, stdin);
cp = strrchr(linebuf, '\n');
if (cp && cp != linebuf)
*cp = ' ';
else if (cp == linebuf)
continue;
if ((strncmp(linebuf, "EXIT", 4) == 0) ||
(strncmp(linebuf, "exit", 4) == 0))
return -1;
else if (linebuf[0] == '?' ||
(strncmp(linebuf, "HELP", 4) == 0) ||
(strncmp(linebuf, "help", 4) == 0))
help();
iter = 1;
continue;
if (strstr(linebuf, "BEGIN") ||
(strstr(linebuf, "begin")))
plsql = 1;
strcat(dyn_statement, linebuf);
if ((plsql && (cp = strrchr(dyn_statement, '/'))) ||
(!plsql && (cp = strrchr(dyn_statement, ';'))))
*cp = '\0';
break;
else
iter++;
printf("%3d ", iter);
return 0;
void set_bind_variables()
int i, n;
char bind_var[64];
/* Describe any bind variables (input host variables) */
EXEC SQL WHENEVER SQLERROR DO sql_error();
bind_dp->N = MAX_ITEMS; /* Initialize count of array elements. */
EXEC SQL DESCRIBE BIND VARIABLES FOR S INTO bind_dp;
/* If F is negative, there were more bind variables
than originally allocated by sqlald(). */
if (bind_dp->F < 0)
printf ("\nToo many bind variables (%d), maximum is %d\n.",
-bind_dp->F, MAX_ITEMS);
return;
/* Set the maximum number of array elements in the
descriptor to the number found. */
bind_dp->N = bind_dp->F;
/* Get the value of each bind variable as a
* character string.
* C contains the length of the bind variable
* name used in the SQL statement.
* S contains the actual name of the bind variable
* used in the SQL statement.
* L will contain the length of the data value
* entered.
* V will contain the address of the data value
* entered.
* T is always set to 1 because in this sample program
* data values for all bind variables are entered
* as character strings.
* ORACLE converts to the table value from CHAR.
* I will point to the indicator value, which is
* set to -1 when the bind variable value is "null".
for (i = 0; i < bind_dp->F; i++)
printf ("\nEnter value for bind variable %.*s: ",
(int)bind_dp->C, bind_dp->S);
fgets(bind_var, sizeof bind_var, stdin);
/* Get length and remove the new line character. */
n = strlen(bind_var) - 1;
/* Set it in the descriptor. */
bind_dp->L = n;
/* (re-)allocate the buffer for the value.
sqlald() reserves a pointer location for
V but does not allocate the full space for
the pointer. */
bind_dp->V = (char *) realloc(bind_dp->V, (bind_dp->L + 1));
/* And copy it in. */
strncpy(bind_dp->V, bind_var, n);
/* Set the indicator variable's value. */
if ((strncmp(bind_dp->V, "NULL", 4) == 0) ||
(strncmp(bind_dp->V, "null", 4) == 0))
*bind_dp->I = -1;
else
*bind_dp->I = 0;
/* Set the bind datatype to 1 for CHAR. */
bind_dp->T = 1;
return;
void process_select_list()
int i, null_ok, precision, scale;
if ((strncmp(dyn_statement, "SELECT", 6) != 0) &&
(strncmp(dyn_statement, "select", 6) != 0))
select_dp->F = 0;
return;
/* If the SQL statement is a SELECT, describe the
select-list items. The DESCRIBE function returns
their names, datatypes, lengths (including precision
and scale), and NULL/NOT NULL statuses. */
select_dp->N = MAX_ITEMS;
EXEC SQL DESCRIBE SELECT LIST FOR S INTO select_dp;
/* If F is negative, there were more select-list
items than originally allocated by sqlald(). */
if (select_dp->F < 0)
printf ("\nToo many select-list items (%d), maximum is %d\n",
-(select_dp->F), MAX_ITEMS);
return;
/* Set the maximum number of array elements in the
descriptor to the number found. */
select_dp->N = select_dp->F;
/* Allocate storage for each select-list item.
sqlprc() is used to extract precision and scale
from the length (select_dp->L).
sqlnul() is used to reset the high-order bit of
the datatype and to check whether the column
is NOT NULL.
CHAR datatypes have length, but zero precision and
scale. The length is defined at CREATE time.
NUMBER datatypes have precision and scale only if
defined at CREATE time. If the column
definition was just NUMBER, the precision
and scale are zero, and you must allocate
the required maximum length.
DATE datatypes return a length of 7 if the default
format is used. This should be increased to
9 to store the actual date character string.
If you use the TO_CHAR function, the maximum
length could be 75, but will probably be less
(you can see the effects of this in SQL*Plus).
ROWID datatype always returns a fixed length of 18 if
coerced to CHAR.
LONG and
LONG RAW datatypes return a length of 0 (zero),
so you need to set a maximum. In this example,
it is 240 characters.
printf ("\n");
for (i = 0; i < select_dp->F; i++)
char title[MAX_VNAME_LEN];
/* Turn off high-order bit of datatype (in this example,
it does not matter if the column is NOT NULL). */
sqlnul ((unsigned short *)&(select_dp->T), (unsigned short
*)&(select_dp->T), &null_ok);
switch (select_dp->T)
case 1 : /* CHAR datatype: no change in length
needed, except possibly for TO_CHAR
conversions (not handled here). */
break;
case 2 : /* NUMBER datatype: use sqlprc() to
extract precision and scale. */
sqlprc ((unsigned int *)&(select_dp->L), &precision,
&scale);
/* Allow for maximum size of NUMBER. */
if (precision == 0) precision = 40;
/* Also allow for decimal point and
possible sign. */
/* convert NUMBER datatype to FLOAT if scale > 0,
INT otherwise. */
if (scale > 0)
select_dp->L = sizeof(float);
else
select_dp->L = sizeof(int);
break;
case 8 : /* LONG datatype */
select_dp->L = 240;
break;
case 11 : /* ROWID datatype */
case 104 : /* Universal ROWID datatype */
select_dp->L = 18;
break;
case 12 : /* DATE datatype */
select_dp->L = 9;
break;
case 23 : /* RAW datatype */
break;
case 24 : /* LONG RAW datatype */
select_dp->L = 240;
break;
/* Allocate space for the select-list data values.
sqlald() reserves a pointer location for
V but does not allocate the full space for
the pointer. */
if (select_dp->T != 2)
select_dp->V = (char *) realloc(select_dp->V,
select_dp->L + 1);
else
select_dp->V = (char *) realloc(select_dp->V,
select_dp->L);
/* Print column headings, right-justifying number
column headings. */
/* Copy to temporary buffer in case name is null-terminated */
memset(title, ' ', MAX_VNAME_LEN);
strncpy(title, select_dp->S, select_dp->C);
if (select_dp->T == 2)
if (scale > 0)
printf ("%.*s ", select_dp->L+3, title);
else
printf ("%.*s ", select_dp->L, title);
else
printf("%-.*s ", select_dp->L, title);
/* Coerce ALL datatypes except for LONG RAW and NUMBER to
character. */
if (select_dp->T != 24 && select_dp->T != 2)
select_dp->T = 1;
/* Coerce the datatypes of NUMBERs to float or int depending on
the scale. */
if (select_dp->T == 2)
if (scale > 0)
select_dp->T = 4; /* float */
else
select_dp->T = 3; /* int */
printf ("\n\n");
/* FETCH each row selected and print the column values. */
EXEC SQL WHENEVER NOT FOUND GOTO end_select_loop;
for (;;)
EXEC SQL FETCH C USING DESCRIPTOR select_dp;
/* Since each variable returned has been coerced to a
character string, int, or float very little processing
is required here. This routine just prints out the
values on the terminal. */
for (i = 0; i < select_dp->F; i++)
if (*select_dp->I < 0)
if (select_dp->T == 4)
printf ("%-*c ",(int)select_dp->L+3, ' ');
else
printf ("%-*c ",(int)select_dp->L, ' ');
else
if (select_dp->T == 3) /* int datatype */
printf ("%*d ", (int)select_dp->L,
*(int *)select_dp->V);
else if (select_dp->T == 4) /* float datatype */
printf ("%*.2f ", (int)select_dp->L,
*(float *)select_dp->V);
else /* character string */
printf ("%-*.*s ", (int)select_dp->L,
(int)select_dp->L, select_dp->V);
printf ("\n");
end_select_loop:
return;
void help()
puts("\n\nEnter a SQL statement or a PL/SQL block at the SQL> prompt.");
puts("Statements can be continued over several lines, except");
puts("within string literals.");
puts("Terminate a SQL statement with a semicolon.");
puts("Terminate a PL/SQL block (which can contain embedded
semicolons)");
puts("with a slash (/).");
puts("Typing \"exit\" (no semicolon needed) exits the program.");
puts("You typed \"?\" or \"help\" to get this message.\n\n");
int connect_database()
err_sql = SQL_SUCC;
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
EXEC SQL CONTEXT ALLOCATE :ctx;
EXEC SQL CONTEXT USE :ctx;
EXEC SQL CONNECT :db_uid;
if(err_sql != SQL_SUCC){
printf("err => connect database(ctx:%ld, uid:%s) failed!\n", ctx, db_uid);
return -1;
return 1;
int disconnect_database()
err_sql = SQL_SUCC;
EXEC SQL WHENEVER SQLERROR DO sql_error();
EXEC SQL WHENEVER NOT FOUND DO sql_not_found();
EXEC SQL CONTEXT USE :ctx;
EXEC SQL COMMIT WORK RELEASE;
EXEC SQL CONTEXT FREE:ctx;
return 1;
void sql_error()
printf("err => %.*s", sqlca.sqlerrm.sqlerrml, sqlca.sqlerrm.sqlerrmc);
printf("in \"%.*s...\'\n", oraca.orastxt.orastxtl, oraca.orastxt.orastxtc);
printf("on line %d of %.*s.\n\n", oraca.oraslnr, oraca.orasfnm.orasfnml,
oraca.orasfnm.orasfnmc);
switch(sqlca.sqlcode) {
case -1: /* unique constraint violated */
err_sql = SQL_UNIQUE;
break;
case -1012: /* not logged on */
case -1089:
case -3133:
case -1041:
case -3114:
case -3113:
/* �6�Ŭ�� shutdown�ǰų� �α��� ���°� �ƴҶ� ��b�� �õ� */
/* immediate shutdown in progress - no operations are permitted */
/* end-of-file on communication channel */
/* internal error. hostdef extension doesn't exist */
err_sql = SQL_DISCONNECT;
break;
case -1400:
err_sql = SQL_NOTNULL;
break;
default:
err_sql = SQL_ERR;
break;
EXEC SQL CONTEXT USE :ctx;
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL ROLLBACK WORK;
void sql_not_found()
err_sql = SQL_NOTFOUND;Hi Jane,
What version of Berkeley DB XML are you using?
What is your operating system and your hardware platform?
For how long have been the application running?
What is your current container size?
What's set for EnvironmentConfig.setThreaded?
Do you know if containers have previously not been closed correctly?
Can you please post the entire error output?
What's the JDK version, 1.4 or 1.5?
Thanks,
Bogdan -
Creating a task field list in c# project
Hi All,
I am writing a small application to simply my monthly forecasting and reporting. I'm extracting data from my msProject file into a c# application with a local database. I want the user to be able to select which task data fields to extract into
the database at run time. To achieve this I'm trying to extract from msProject a list of all used fields.
Following advice from some forum posts I've been able to create a list of fields, based on looping through each Table and taking the TableField names. The field names are stored as strings. Enterprise field are string representations of integers.
I now want to be able to get the data for each task for the fields selected by the user.
I'm having trouble using "FieldNameToFieldConstant" to GetField value. I can use it perfectly well in a VBA macro but can find how to use the function in a C# application. I found a post where someone reporting using...
task.GetField(msProject.Application.FieldNameToFieldConstant(fieldName,...)
I can't get to work for me though, when I try msProject.Application. my only available choices are "Equals" and "ReferenceEquals".
So to sum up, how do I us "FieldNameToFieldConstant" in a c# application or if someone has a better way to create a list of fields that would be great.
Thanks in advanceOK, so I worked it out, answer provided below for anyone else who is interested.
The answer to my first questions is that FieldNameToFieldConstant is access via an instance of msProject.Application, in my code below MSP.Application app = new MSP.Application();
My Code now searches through every table, and for every field in each table creates a custom object which contains the field name and ID number, each new custom field is tested against the contents of the List<clsFieldList> and if its unique its added
to the list. At the end of the process I have a list of all unique fields from all tables in the project file.
Hope this is helpful to someone.
Cheers
using MSP = Microsoft.Office.Interop.MSProject; public static List<clsFieldList> FieldsFromTables()
//TODO: move this method to a new thread.
//this method searches through each table in the project
//gathers a collection of all unique fields in the tables
//calling method must ensure that MSProject is open with an project file loaded.
List<clsFieldList> fldNames = new List<clsFieldList>(); ;
MSP.Application app = new MSP.Application();
MSP.Project proj = app.ActiveProject;
MSP.Tables taskTables = proj.TaskTables;
int progress = 0;
int i = 0;
//loop through each table
foreach (MSP.Table tskTable in taskTables)
//loop through each field in each table
foreach (MSP.TableField tskTableField in tskTable.TableFields)
//prepare to create a new clsFieldList object
string title = GetFieldName(tskTableField);
long fldID = (long)tskTableField.Field;
string fldType = tskTable.GetType().ToString();
//create the new object and check if it exists already in the List
clsFieldList newField = new clsFieldList(MSP.PjFieldType.pjTask, fldID, title, fldType);
if (!fldNames.Contains(newField))
//TODO: convert the DataType to string, long etc
fldNames.Add(newField);
//fldNames now contains a list of clsFieldList which represent the fields used in every table in the active project.
return fldNames;
private static string GetFieldName(MSP.TableField tblFld)
//This method is a C# conversion of a VBA example I found on the internet. I'd give credit where its due here but I printed out the code and now can't find it again.
MSP.Application app = new MSP.Application();
//find the field name (actually column heading) for a field in a data table
long lngFieldID;
string strResult = "";
lngFieldID = (long)tblFld.Field;
//if the Field Title is not null then set that as the field name.
if (tblFld.Title != null)
strResult = tblFld.Title.Trim();
if(strResult.Length == 0)
//if strResult is still zero length then the field title must have been null, check if its a custom field
try
//try to get the custome field name - this will come back blank if its not a custom field
strResult = app.CustomFieldGetName((MSP.PjCustomField)lngFieldID).Trim();
catch { }
finally
strResult = app.FieldConstantToFieldName((MSP.PjField)lngFieldID).Trim(); //use the field name
return strResult; -
User defined function in materialized view over db link
I am working in Oracle 10g. Trying to create a materialized view to populate a reporting warehouse from a transactaional database (also oracle 10g).
In SQL plus I can access a function in a package on the remote database but when I try to use the "working" sql statement in a materialized view I get an invalid identifier error.
Basically my select statement is ...
select
ColA,
ColB,
PackageName.Function@db_link(parameters)
from
SourceTable@db_link .....
The select statement works but when I use it within a create materialized view statement I get ora-00904: PackageName.Function: invalid identifier.
Any help is appreciated.
Tx,What about the error message doesn't make sense?
The identifier is valid when used in the SQL statement outside of the Create Materailized view. It is my understanding that "most any" valid SQL statement should be usable in an MV.
Put the function in the local schema?
I tried that. If the function does not have any input parameters it works. But if it has input parameters the create view statement complains about ORA-00997: illegal use of LONG datatype.
I made a real simple function Pkg.ASTRING - no input parameters just returns the string 'ABC' -- that worked.
Then I added an input parameter Pkg.ASTRING (TheInString VARCHAR2) that returns the same 'ABC' string.
When I include it in the create MV statement Pkg.ASTRING('XYZ') I get the illegal use of LONG datatype.
What LONG datatype?
Maybe you are looking for
-
Icloud is not working on my mac
Hi, Im having problems with my icloud - my mac will not play the music I have uploaded. This is the first time it has happened, and I have used icloud for months (maybe a year now). Any help ?
-
I want to create an applet, Please Help...
HI all, I want to create an applet which should be able to display text and images... To display text in an applet I am using ... import java.awt.*; import java.applet.*; public class SimpleApplet extends Applet public void paint(Graphics g)
-
What is the best internet security for mac
what is the best internet security for mac
-
Add a second series to a scatter plot.
I have two tables, each with non-adjacent x and y data columns. I would like to plot both series on one plot as separate series. I have read the pdf help file, and searched through past discussions here. Non of the tips in those locations work. An
-
Adobe Flash Player will not install on my xp
Adobe Flash Player doesnot install on my old xp