Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Convert CHAR to BLOB?

Re: Convert CHAR to BLOB?

From: Hexathioorthooxalate <ruler_at_removemetoemail.clara.co.uk>
Date: Mon, 6 Jun 2005 20:14:30 +0100
Message-ID: <1118085230.14028.0@nnrp-t71-03.news.uk.clara.net>


The error says it all. Below is one way you could use to get you on the right track
Regards
Hex

SQL>
SQL>
SQL> CREATE OR REPLACE PROCEDURE fred(a IN BLOB) IS
  2 b BLOB;
  3 BEGIN
  4 b:=a;
  5 IF 0=DBMS_LOB.GETLENGTH(b) THEN
  6 b:=TO_BLOB(UTL_RAW.CAST_TO_RAW('P_at_ssw0rd'));   7 END IF;
  8
  9 --Whatever, here I am outputting the size here  10 DBMS_OUTPUT.PUT_LINE('Your blob contains ' || TO_CHAR(DBMS_LOB.GETLENGTH(b)) || ' bytes');  11
 12 END;
 13 /

Procedure created.

SQL>
SQL>
SQL> EXEC fred(UTL_RAW.CAST_TO_RAW('four'));
Your blob contains 4 bytes

PL/SQL procedure successfully completed.

SQL> --8 bytes is the length of 'P_at_ssw0rd' SQL> EXEC fred(EMPTY_BLOB());
Your blob contains 8 bytes

PL/SQL procedure successfully completed.

SQL>
SQL> SELECT *
  2 FROM V$VERSION; BANNER



Personal Oracle Database 10g Release 10.1.0.2.0 - Production PL/SQL Release 10.1.0.2.0 - Production
CORE 10.1.0.2.0 Production
TNS for 32-bit Windows: Version 10.1.0.2.0 - Production NLSRTL Version 10.1.0.2.0 - Production

SQL> <raedwa01_at_gmail.com> wrote in message
news:1118077955.527937.65990_at_g44g2000cwa.googlegroups.com...
>I have a stored procedure that takes a blob as an input parameter. I
> check to see if the parameter is null by using CURSOR passCur IS
> SELECT NVL(PASSWORD, 'P_at_ssw0rd')
> FROM DUAL;
>
> PASSWORD is my Blob (it's a bytestream of a hashed password). If
> nothing is provided, i want to put the word P_at_ssw0rd into the field.
>
> I open the cursor and try to fetch the result into a temporary variable
> and always get this error.
> Error -932: ORA-00932: inconsistent datatypes: expected BLOB got CHAR
>
> Is there something i can do to make sure i put in a BLOB value?
>
> Thanks,
> Rob
>
Received on Mon Jun 06 2005 - 14:14:30 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US