Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Oracle8: Insert a long RAW Value
Oracle8: Insert a long RAW Value [message #26742] Tue, 25 May 2010 11:23 Go to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello All,

Can anybody help me how to insert in Oracle Long RAW value?

I want to import image in a table!

Thanks in advance!

[Updated on: Tue, 25 May 2010 11:37]

Report message to a moderator

Re: Oracle8: Insert a long RAW Value [message #26743 is a reply to message #26742] Tue, 25 May 2010 14:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
		SQL.Execute("update TABLE set DATA = ? where ID = ?", SqlRaw(data), q);


You cannot use SqlExp for this. That is why I usually split the process into two parts: I use SqlExp to do the insert, then update to set longraw value.

Mirek
Re: Oracle8: Insert a long RAW Value [message #26745 is a reply to message #26743] Tue, 25 May 2010 15:00 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

luzr wrote on Tue, 25 May 2010 15:24

		SQL.Execute("update TABLE set DATA = ? where ID = ?", SqlRaw(data), q);


You cannot use SqlExp for this. That is why I usually split the process into two parts: I use SqlExp to do the insert, then update to set longraw value.

Mirek


in oracle8 you use SqlRaw?
I see only in Oracle7 it is processed!
Re: Oracle8: Insert a long RAW Value [message #26748 is a reply to message #26745] Tue, 25 May 2010 16:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
tojocky wrote on Tue, 25 May 2010 09:00

luzr wrote on Tue, 25 May 2010 15:24

		SQL.Execute("update TABLE set DATA = ? where ID = ?", SqlRaw(data), q);


You cannot use SqlExp for this. That is why I usually split the process into two parts: I use SqlExp to do the insert, then update to set longraw value.

Mirek


in oracle8 you use SqlRaw?
I see only in Oracle7 it is processed!


Yes, I am using Oracle7 Smile (It works all the way up).

"7" is minimal requirement. They have changed C api in Oracle 8 and it does not support LONGRAW anymore (if I remember well), replacing it with BLOBs.

Mirek
Re: Oracle8: Insert a long RAW Value [message #26761 is a reply to message #26748] Wed, 26 May 2010 13:52 Go to previous messageGo to next message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

luzr wrote on Tue, 25 May 2010 17:49

tojocky wrote on Tue, 25 May 2010 09:00

luzr wrote on Tue, 25 May 2010 15:24

		SQL.Execute("update TABLE set DATA = ? where ID = ?", SqlRaw(data), q);


You cannot use SqlExp for this. That is why I usually split the process into two parts: I use SqlExp to do the insert, then update to set longraw value.

Mirek


in oracle8 you use SqlRaw?
I see only in Oracle7 it is processed!


Yes, I am using Oracle7 Smile (It works all the way up).

"7" is minimal requirement. They have changed C api in Oracle 8 and it does not support LONGRAW anymore (if I remember well), replacing it with BLOBs.

Mirek


Mirek,

I tried Oracle7 but without success:

It remain on execution command: oci7.oexec(&cda); from bool OCI7Connection::Execute() on second(last) call.
Can you help me with this? Maybe i did something wrong!

I uploaded image from file direct from file like this:
String v_img_data(LoadFile(p_image_location));
	curr_st.SetParam(1, SqlRaw(v_img_data));

is it correct?

according by this documentation The method OCIDefineByPos support long raw type (SQLT_LBI).

Thank you in advance

[Updated on: Wed, 26 May 2010 15:27]

Report message to a moderator

Re: Oracle8: Insert a long RAW Value [message #26763 is a reply to message #26761] Wed, 26 May 2010 15:17 Go to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

OK!
The problem is resolved! the problem was: I lock the table in TORA.

Thank you Mirek for help!

I propose to include SqlRaw in Oracle8 class!

The patch is here:
Index: uppsrc/Oracle/Oci8.cpp
===================================================================
--- uppsrc/Oracle/Oci8.cpp	(revision 2421)
+++ uppsrc/Oracle/Oci8.cpp	(working copy)
@@ -69,7 +69,7 @@
 	struct Item {
 		T_OCI8&        oci8;
 		int            type;
-		int16          len;
+		int            len;
 		sb2            ind;
 		ub2            rl;
 		ub2            rc;
@@ -142,6 +142,7 @@
 	void      SetParam(int i, Date d);
 	void      SetParam(int i, Time d);
 	void      SetParam(int i, Sql& refcursor);
+	void      SetRawParam(int i, const String& s);
 
 	void      AddColumn(int type, int len);
 	void      GetColumn(int i, String& s) const;
@@ -296,6 +297,13 @@
 	PrepareParam(i, r.GetOraType(), r.GetMaxLen(), 0, r.GetType());
 }
 
+void OCI8Connection::SetRawParam(int i, const String& s) {
+	int l = s.GetLength();
+	Item& p = PrepareParam(i, SQLT_LBI, l, 0, VOID_V);
+	memcpy(p.Data(), s, l);
+	p.ind = l ? 0 : -1;
+}
+
 class Oracle8RefCursorStub : public SqlSource {
 public:
 	Oracle8RefCursorStub(SqlConnection *cn) : cn(cn) {}
@@ -320,6 +328,9 @@
 		SetParam(i, String());
 	else
 		switch(q.GetType()) {
+		case SQLRAW_V:
+			SetRawParam(i, SqlRaw(q));
+			break;
 		case STRING_V:
 		case WSTRING_V:
 			SetParam(i, String(q));

[Updated on: Wed, 26 May 2010 15:19]

Report message to a moderator

Previous Topic: SQLITE3: Bind parameter by name
Next Topic: Access violation since rev 2407
Goto Forum:
  


Current Time: Fri Apr 19 09:43:51 CEST 2024

Total time taken to generate the page: 2.96454 seconds