免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 3697 | 回复: 11
打印 上一主题 下一主题

在cl里用什么命令实现往数据库里写记录? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-01-12 10:27 |只看该作者 |倒序浏览
我想在cl里写一段代码,往一个数据库里写记录,不知道有没有这样的命令?

论坛徽章:
0
2 [报告]
发表于 2007-01-12 13:09 |只看该作者
为何不用用RPG/RPGLE?很方便啊

论坛徽章:
0
3 [报告]
发表于 2007-01-12 16:18 |只看该作者
只是想知道怎么写

论坛徽章:
0
4 [报告]
发表于 2007-01-12 18:00 |只看该作者
WRTSRC       WRITE SOURCE STATEMENTS TO A SOURCE MEMBER      TAASRCG





The Write  Source  command allows  writing a  source  statement into  a
source member.   An entire record  can be added or  updated.  Positions
within  the record can also  be specified to allow  an easier entry for
fixed form languages.

No delete function  is supported (you  could consider making a  comment
out of an existing statement).

WRTSRC can  be of  value when  you have some  minimal amount  of source
that  must be created  or modified from  within a CL  program.  Typical
source types to  be modified would be  DDS or Reformat  specifications.

Assume you want  to dynamically create a  file using the format  of the
DSPFD  member output file  and specify a  key on the  number of records
field (MBNRCD)  in descending  sequence.   The model  file in  QSYS  is
QAFDMBR with a  format name of QWHFDMBR.   You must have a  source file
and  add a  member to  it.   Then  you can  use the  WRTSRC  command to
create the DDS.  Typical coding would be as follows:

      CRTSRCPF    FILE(QTEMP/SOURCE)
      ADDPFM      FILE(QTEMP/SOURCE) MBR(MBRFIL)
      WRTSRC      SRCFILE(QTEMP/SOURCE) MBR(MBRFIL) ACTION(*ADD) STMT('-
      A          R QWHFDMBR                  FORMAT(QSYS/QAFDMBR)')
      WRTSRC      SRCFILE(QTEMP/SOURCE) MBR(MBRFIL) ACTION(*ADD) STMT('-
      A          K MBNRCD                    DESCEND')
      WRTSRC      SRCFILE(QTEMP/SOURCE) MBR(MBRFIL) ACTION(*END)
      CRTPF       FILE(QTEMP/MBRFIL) SRCFILE(QTEMP/SOURCE)
      DSPFD       FILE(xxx) TYPE(*MBR) OUTPUT(*NONE) FILEATR(*PHY) +
                    OUTFILE(QTEMP/MBRFIL)

The  source  file is  created and  a member  is added.   The  first two
WRTSRC commands  write DDS specifications  to the  file for the  format
and key  record.  The WRTSRC command  assumes that you are  going to do
more  than  one  operation,  so  the  third  WRTSRC  command  specifies
ACTION(*END) which  closes the  file/member.   The  CRTPF command  then
creates the file and the DSPFD command outputs into the file.

The DDS that was created would look like:

      A          R QWHFDMBR                  FORMAT(QSYS/QAFDMBR)
      A          K MBNRCD

In the  previous, example  the STMT  parameter was  used on WRTSRC  and
the  statement was  written with  the exact  number of  blanks required
for the fixed format entry of DDS.   Another alternative is to use  the
POSn and  TXTn keywords on  the WRTSRC command.   The first  two WRTSRC
commands could have been written as:

      WRTSRC      SRCFILE(QTEMP/SOURCE) MBR(MBRFIL) ACTION(*ADD) +
                    POS1(6)  TXT1('A') +
                    POS2(17) TXT2('R QWHFDMBR') +
                    POS3(45) TXT3('FORMAT(QSYS/QAFDMBR)')
      WRTSRC      FILE(QTEMP/SOURCE) MBR(MBRFIL) ACTION(*ADD) +
                    POS1(6)  TXT1('A') +
                    POS2(17) TXT2('K MBNRCD')
                    POS3(45) TXT3('DESCEND')

When the  POSn and TXTn  keywords are used,  the statement is  built up
in  a work area and then written to the  source file.  Up to 4 POSn and
TXTn keywords may  be specified.   Each TXTn field can  be 29 bytes  in
length  and is  truncated  to the  last  character entered.   The  STMT
keyword  can also be used.   The STMT value becomes  the base entry for
the statement and the TXTn values overlay the statement.

Multiple member processing
--------------------------

WRTSRC  will  allow  you  to  update  multiple  members  without  using
ACTION(*END).  For example,  you can change a record  in MBR1, change a
record  in  MBR2,  and  then use  ACTION(*END)  to  each  member.   The
updating program has only one  file open at a  time, but senses that  a
change in lib/file/member has  occurred.  It would close  the currently
open file and reopen the new file.

Command parameters                                    *CMD
------------------

    SRCFILE       The  qualified name  of the  source  file to  be used.
                  The  library defaults to *LIBL.   The source file must
                  exist prior to  the use of  WRTSRC.  The maximum  size
                  source  file  of 240  bytes  (228  bytes  of data)  is
                  supported.

    MBR           The  member to be used.   The member must exist before
                  the use of WRTSRC.

    RELRCD        The relative  record  number  of  the  source  record.
                  The default is  *NEXT which works in  conjunction with
                  the  ACTION(*ADD) default to  add a new  record to the
                  file.     A  relative   record  number   is   normally
                  specified for update operations.

                  For update  operations, if  your SEU sequence  numbers
                  all end  in .00 such  as 86.00 and you  want to update
                  that  record,  the  parameter should  be  specified as
                  RELRCD(86).

    ACTION        The action  code  to be  used.   The  default is  *ADD
                  meaning to add a record at the end of the member.

                  *UPD  allows an existing  record to  be updated.   You
                  may  specify one or more of  the POSn/TXTn keywords to
                  modify some  of the  positions of  an existing  source
                  record.

                  *RPL may be  specified to totally replace  an existing
                  source record.

                  *END  should  be  specified  when  there  are no  more
                  changes to  be made  to the  member.   When the  first
                  use  of  WRTSRC  occurs,  the  member  is  opened  and
                  remains  open  for   other  records  to  be  added  or
                  changed.     When  no  more  action  is  desired,  the
                  ACTION(*END) specification  should  be used  to  cause
                  the file be closed normally.

    STMT          The  source statement  to be  used.   This  acts as  a
                  base  statement which can  be further  modified by the
                  POSn/TXTn  parameters.     The  POSn/TXTn   parameters
                  overlay the  STMT value  for the  positions specified.
                  If  STMT is  specified  with ACTION(*UPD),  the entire
                  statement will  be replaced.   Normally,  STMT  should
                  not be  used with  ACTION(*UPD).   If a total  replace
                  of   an   existing   statement  is   needed,   specify
                  ACTION(*RPL).

    POS2          The  first  position  to be  modified  with  the value
                  from the TXT1 parameter.

    TXT1          The value to  be placed  into the statement  beginning
                  at  the POS1 parameter  value.   The value  entered is
                  scanned   from  the  right   to  determine  the  first
                  non-blank position.   This  determines the  number  of
                  positions  to be  moved.    See the  later  discussion
                  about  overlaying data.   Up to  29 characters  may be
                  entered.

    POS2          The second position to be modified.

    TXT2          The second value to be placed in the record.

    POS3          The third position to be modified.

    TXT3          The third value to be placed in the record.

    POS4          The fourth position to be modified.

    TXT4          The fourth value to be placed in the record.

If the STMT  keyword is  used, the  value is used  as a  base to  begin
building the  source  statement from.   If  ACTION(*UPD) is  specified,
the existing source statement is used as a base.

The TXTn keywords  are processed in order so  it is possible to overlay
the  results of one  with the next TXTn.   If you  request to move data
beyond position 228 of the statement, an escape message will occur.

Restrictions
------------

None.

Prerequisites
-------------

The following TAA Tools must be on your system:

            SNDESCMSG     Send escape message

Implementation
--------------

None, the tool is ready to use.

Objects used by the tool
------------------------

    Object        Type       Attribute      Src member     Src file
    ------        -----      ---------      ----------     -----------

    WRTSRC        *CMD                      TAASRCG        QATTCMD
    TAASRCGC      *PGM          CLP         TAASRCGC       QATTCL
    TAASRCGR      *PGM          RPG         TAASRCGR       QATTRPG

论坛徽章:
0
5 [报告]
发表于 2007-01-12 18:03 |只看该作者
CALL QZDFMDB2 ('INSERT INTO TOML.QCUSTCDT (CUSNUM, LSTNAM, INIT) VALUES(876543, ''Liotta'', ''T'') ')
http://jplamontre.free.fr/AS400/EXECUTESQL.htm

论坛徽章:
0
6 [报告]
发表于 2007-01-12 18:14 |只看该作者
PS:上面的英文我也没仔细看。呵呵

论坛徽章:
0
7 [报告]
发表于 2007-01-16 15:33 |只看该作者
看来我的好好补一补英语了

论坛徽章:
0
8 [报告]
发表于 2007-01-16 15:36 |只看该作者

回复 6楼 utirei 的帖子

辛苦了

论坛徽章:
0
9 [报告]
发表于 2007-01-16 16:18 |只看该作者
CLP对文件的操作功能很弱,所以才要CLP结合RPG来使用

论坛徽章:
0
10 [报告]
发表于 2007-01-16 20:44 |只看该作者
原帖由 xuguopeng 于 2007-1-16 16:18 发表
CLP对文件的操作功能很弱,所以才要CLP结合RPG来使用


记不清楚了,你可以查一下,有个命令好像是什么runsql 之类 可以
在CLP语句中调用,直接可以写SQL语句
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP