Stored Procedures - Criando no DDT e utilizando no BO - Dúvidas


Author
Message
Marcelo Blank
Marcelo Blank
StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)
Group: StrataFrame Users
Posts: 0, Visits: 414
Ivan,

Criei tabelas no DDT, com as SP´s padrôes para insert, update e delete.

Atualizei a base de dados, criei o BO no projeto, etc.

Estou utilizando este BO em uma classe para gravação de uma arquivo TXT da Bovespa. Faço a leitura dos registros e gravo os dados...

No BO configurei que a gravação será feita por SP, e o nome da SP (deixei em branco por ser padrão).

Na classe em que leio os registro do TXT faço uma chamada para o BO, que possui um método para gravação na Tabela relacionada.

Este método recebe os parâmetros passados da rotina que lê o TXT.

1 - Quando utilizo :

Add()

BO.Codigo = codigo

BO.XXX = XXX

Save()

ocorre um erro que nao pode ser gravado no ROW =-1 (ou seja, não criou registro ??)

2 - Como faço para gravar como SP (a que foi criada pelo SF) ao invés do método acima ?

Não encontrei nenhum exemplo . Utilizo a chamada normal para gravar uma sP e utilizo a sp criada pelo DDT (ai meu ganho seria a codificação da SP) ou existe uma maneira mais direta ? Poderia me passar um exemplo ?

Obrigado,

Marcelo Blank
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Olá Marcelo.

Não há necessidade de nenhuma chamada às SPs no caso de INSERT, UPDATE ou DELETE. Isto será feito pelo framework.

Sem ver um pouco mais a fundo sua lógica eu não tenho muita certeza, mas experimente usar NewRow() ao invés de Add() para criar o novo registro. Aqui vai um texto do Help:

Adding Records

There are three ways to add a new record to a business object:
  • NewRow() - Business Object - The NewRow() method on a business object will create the new record, and will then update CurrentRow to point to that new record. However, the editing state will not be affected, nor will any controls bound to the business object be refreshed or updated with the new row values. As such, the NewRow() method is recommended when programmatically adding new records to the business object and there is no UI interface that needs to be refreshed.

  • Add() - Business Object - The Add() method on a business object will first call the NewRow() method (described above), and will then perform the following actions:

    1. Set the editing state of the business object to Adding.

    2. Raise the EditingStateChanged event.

    3. Refresh the bound controls.

  • Add() - Form - The Add() method on a StrataFrame form will add a new record by calling the Add() method on the primary business object. No additional actions will take place.


Marcelo Blank
Marcelo Blank
StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)
Group: StrataFrame Users
Posts: 0, Visits: 414
Ivan,

Quer dizer que quando indico para o BO utilizar SP, o código é o mesmo que o passado anterior. O SF controla internamente ?

Só tenho que vincular os parâmetros com os atributos da tabela (e sp) ?

Blank
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Quando você estiver na tela de Table Properties do DDT, após entrar com o nome da tabela, basta clickar nos itens "Create INSERT Stored Procedure", "Create UPDATE..." e assim por diante, como na figura abaixo:

http://forum.strataframe.net/Uploads/Images/3730552a-87e8-4b2f-b832-922a.png


Depois, após criar o BO e mapeá-lo usando o Business Object Mapper (não se esqueça de fazer o Build Partial, vá às Propriedades do BO e configure o CRUD:

http://forum.strataframe.net/Uploads/Images/cb027f58-3adc-458d-aab8-6f99.png


É isto. Daí em diante o INSERT, UPDATE e DELETE vão ser cuidados pelo framework para você. Caso não tenha feito o Tutorial, tente fazê-lo. É rapidinho e te dá uma noção geral de utilização das ferramentas.
Marcelo Blank
Marcelo Blank
StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)StrataFrame Novice (62 reputation)
Group: StrataFrame Users
Posts: 0, Visits: 414
Ivan,

Isto é muito fácil .... só isso ?

Cadê a chatice de ter que ficar criando rotinas para gravação ???!!!!


Funcionou beleza ....

Abraços e obrigado pela força.

Blank
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)Strategic Support Team Member (2.2K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Legal que conseguiu, Marcelo. http://forum.strataframe.net/Skins/Classic/Images/EmotIcons/Cool.gif
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search