Home > database >  Read the file to create data stored procedure
Read the file to create data stored procedure

Time:09-20

String ls_sql, ls_fileName
Int li_fileNo, ll_number
Long ll_fileLength
The SQLCA. The AUTOCOMMIT=TRUE
Ls_fileName=trim (" procedure. SQL ")
Ll_fileLength=FileLength (ls_fileName)
IF ll_fileLength & gt; THEN 32765
St_7. Text="script file is too big!"
DISCONNECT the USING the SQLCA;
RETURN
ELSEIF ll_fileLength & gt; 0 THEN
Li_fileNo=FileOpen (ls_fileName StreamMode!)
Ll_number=FileRead (li_fileNo ls_sql)
IF ll_number & gt; 0 AND ll_number & lt; THEN=32765
The SQLCA. The AutoCommit=True
The EXECUTE IMMEDIATE: ls_sql Using SQLCA;
The SQLCA. The AutoCommit=False
St_7. Text="create database structure success!"
END the IF
FileClose (li_fileNO)
The ELSE
St_7. Text="error opening script file, please input the correct table structure script file name!"
DISCONNECT the USING the SQLCA;
RETURN
END the IF

The EXECUTE IMMEDIATE: ls_sql USING SQLCA;

The SQLCA. The AUTOCOMMIT=FALSE
Above is my a piece of code, no error, but in the database stored procedure did not create success, students in you to help me have a look, thank you!

CodePudding user response:

The
refer to the original poster zbx1219 response:
string ls_sql, ls_fileName
Int li_fileNo, ll_number
Long ll_fileLength
The SQLCA. The AUTOCOMMIT=TRUE
Ls_fileName=trim (" procedure. SQL ")
Ll_fileLength=FileLength (ls_fileName)
IF ll_fileLe...


Ll_fileLength judgment script length should be read the file before you judge, you start to judge didn't read the file?

CodePudding user response:

The FileLength ()
Function to get the length of the specified file (in bytes),
Not before open can also work out the length of the file you

CodePudding user response:

Have you ever debug?

CodePudding user response:

One, before the EXECUTE, check ls_sql value
MessageBox (" SQL ", ls_sql), have a look at the content of the reading is correct

. Two, after the execution of the EXECUTE, according to the SQLCA SQLDBCode and SQLCA SQLErrText value, whether to perform is wrong, and wrong information

Believe that there are more than the second step, should be able to solve your problem
  • Related